homepage Welcome to WebmasterWorld Guest from 54.226.43.155
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Issue with HTML tag and HTML5
toplisek




msg:4643232
 10:05 am on Feb 7, 2014 (gmt 0)

I have noticed that bootstrap uses:
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<head>

1. What will happen if there is other than en language like Russian or many languages. Which lang should be used in unicode?

2. Can we use just <html lang="en"> as it is used modernizr.js

 

drhowarddrfine




msg:4643300
 3:51 pm on Feb 7, 2014 (gmt 0)

Then you have to change the lang attribute. Unicode doesn't care if you enter the unicode character points for the other languages.

mattur




msg:4643304
 4:06 pm on Feb 7, 2014 (gmt 0)

1. Use the appropriate lang code for the primary language on your html element. So for russian I think that would be <html lang="ru">. *Always* publish web pages as UTF-8.

There's lots of information about languages on the web on the W3C website:

Choosing a Language Tag
[w3.org...]

Why use the language attribute?
[w3.org...]

Declaring language in HTML
[w3.org...]

2. The bootstrap code quoted above is doing a specific thing: it's adding different classes to the html tag for old versions of IE, so they can be styled differently.

So IE8 sees the <html lang="en" class="ie8"> tag. IE9 sees <html lang="en" class="ie9"> and all other browsers see the <html lang="en">. This is so authors can create IE8 or IE9 specific styles eg .ie8 .mystyle{}, .ie9 .mystyle{}.

If you don't need IE8 and IE9 specific styles, you can just use:

<!DOCTYPE html>
<html lang="en">
<head>

toplisek




msg:4643328
 5:07 pm on Feb 7, 2014 (gmt 0)

Interesting is that bootstrap examples do not include
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->

But templates based on this use above code.I'm not sure
1. if I can add on my own if bootstrap examples avoid them...
2. Will <html lang="en"> by default on all pages avoid UTF-8 characters even there is Russian language or Spanish or German?

drhowarddrfine




msg:4643507
 4:44 pm on Feb 8, 2014 (gmt 0)

2) No. Browsers will display English characters as they should be and do the best it can with the others though I don't know what issues will arise, if any.

You can, if you want to bother with it, do things like <p lang="ru"></p>.

toplisek




msg:4643524
 6:16 pm on Feb 8, 2014 (gmt 0)

ok, so, using
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->

will not effect an language even other is there.All UTF characters should be displayed in the correct way.

lucy24




msg:4643542
 6:57 pm on Feb 8, 2014 (gmt 0)

Which lang should be used in unicode?

The two have nothing to do with each other. Is it possible you're confusing lang with charset? All pages need a charset declaration if you don't do it globally with an AddCharset or similar.

toplisek




msg:4644148
 10:47 am on Feb 11, 2014 (gmt 0)

As I understand lang attribute assists search engines...


Assisting search engines

Assisting speech synthesizers

Helping a user agent select glyph variants for high quality typography

Helping a user agent choose a set of quotation marks

Helping a user agent make decisions about hyphenation, ligatures, and spacing

Assisting spell checkers and grammar checkers

It will not be mistake to put <html lang="en"> even you have a Chinese encoding.

So, correct way is to use simple
<!DOCTYPE html>
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if IE 9]> <html class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
<head>
Is this ok?

drhowarddrfine




msg:4644312
 8:28 pm on Feb 11, 2014 (gmt 0)

Why are you doing that part that way?

<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if IE 9]> <html class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->

toplisek




msg:4644526
 5:37 pm on Feb 12, 2014 (gmt 0)

First: Bootstrap templates use this even examples inside bootstrap avoid this option.
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if IE 9]> <html class="ie9"> <![endif]-->
Second: lang attribute assists search engines but <html> will be translated inside search engine in the correct way as use of <html lang="en"> defines rule for all search engines even it is not connected to UTF-8: even you have a Chinese encoding you can use.
Third: <html> should be there as validation needs </html>


This question is actually for developers of framework.

drhowarddrfine




msg:4644550
 7:53 pm on Feb 12, 2014 (gmt 0)

Just wanted to make sure you knew that and were using bootstrap and not just copy/pasting from somewhere else.

The html tag is optional and need not be there for validation.

lucy24




msg:4644575
 10:14 pm on Feb 12, 2014 (gmt 0)

validation needs </html>

I once learned by direct personal (unintentional) experience that </body> and </html> aren't needed for validation. At least not in html 4, where a surprising number of elements don't absolutely require formal closing. Not even in the w3 validator, which is stricter than the(ir own) official standard :)

toplisek




msg:4644717
 8:45 am on Feb 13, 2014 (gmt 0)

I have not validated by w3 validator, but I have checked inside updated Mozilla. It will report red marked </html> as it is missing inside browser validation. If your comment were correct than browser validation do not support HTML5 as they will not report an issue inside validation. Interesting how is seen inside Google browser.I'm not sure.

drhowarddrfine




msg:4644814
 2:39 pm on Feb 13, 2014 (gmt 0)

Never, EVER use a browser to validate your markup. The validator follows the spec. Browsers try to catch up with the spec. Some browsers catch up better than others.

A missing end tag will ALWAYS be flagged.

toplisek




msg:4645333
 6:49 pm on Feb 14, 2014 (gmt 0)

Thank you for your replies. Good posts.

toplisek




msg:4646602
 10:21 am on Feb 19, 2014 (gmt 0)

I have last question how to set in the correct way. Example:
<!DOCTYPE html>
<html>
<head>
</html>

will be mistake due to html which is already inside <!DOCTYPE html> or it is correct

<!DOCTYPE html>
<!--[if !IE]><!--> <html> <!--<![endif]-->`
<head>
</html>
and this is 100% correct?

drhowarddrfine




msg:4646683
 3:59 pm on Feb 19, 2014 (gmt 0)

<!--[if !IE]>

That line is a conditional comment only IE understands but it says, "if not IE", so who is that for? No other browser will use the contents cause it's all in a comment and will be ignored. iow, all browsers will ignore the contents.

Now, potentially, I'm forgetting how the hack works where only non-IE browsers can read that but I don't think this is it.

Fotiman




msg:4646786
 9:01 pm on Feb 19, 2014 (gmt 0)

@toplisek, the "html" that appears in the DOCTYPE is totally unrelated to the <html> element, and the <html> element is still required.

And your conditional comment appears to be incorrect. If you're not doing any special handling for specific versions of IE, then remove the conditional comments entirely. End result:

<!DOCTYPE html>
<html>
<head>
...
</head>
</html>

toplisek




msg:4646791
 9:10 pm on Feb 19, 2014 (gmt 0)

Ok, thank you.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved