Move lang attribute from html to body #286

Closed
davidmurdoch opened this Issue Jan 19, 2011 · 14 comments

Projects

None yet

4 participants

@davidmurdoch
Contributor

Can we move the html element's lang attribute to the body?

I don't think we need to specify the (human) language of our css and javascript resources.

<body lang="en"></body>

...should be perfectly valid.

It will DRY things up a bit and help the charset meta element to be within the first 512 bytes if a developer needs to add additional attributes to the html tag(s).

@paulirish
Member

Just looked at the spec and surrounding documentation about @lang ...

This looks legit. I'd be happy with this one. :)

good call.

@paulirish
Member

move @lang attribute from HTML elem to BODY. closed by 16e9b7d

thx davidmurdoch

@richardcornish
Contributor

I know this is closed and committed, but doesn't it make sense to keep the lang attribute on the <html> element because of the <title> element? That's text people read and search engines crawl.

@paulirish
Member

hixie's preference is for the lang to stay on the HTML tag...

reopening... :/

@paulirish
Member

Okay it's a bit redundant but....
How about setting the lang on both <head> and <body> elems?

@richardcornish
Contributor

It works, but wasn't the point of this fix to be more DRY? I would leave well enough alone and keep on html.

@davidmurdoch
Contributor

@richardcornish: putting it on the html would make it less DRY because of the conditional comments.

Can we put it on head and body tags? Leaving it in the html tag repeats it 4 times rather than 2.

Come to think of it, Content-Language is an acceptable http-header that we may be able to set as a meta tag: <meta http-equiv="Content-Language" content="en">. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12

@richardcornish
Contributor

@davidmurdoch There would be two instances of lang="en", but in different places. It would be easier to see it all on <html> at the top, even if it's four times instead of two. It'll depend on your CMS or template system at that point.

I like the <meta> solution because it's document centric instead of element centric. It really makes more sense to declare a language at a document level, then use the lang attribute on more granular elements. Ultimately I would chose whichever method more user agents would support at that point, and I haven't seen one method favored over the other.

@nimbupani
Member

I prefer it on html tag than on body for same reasons Hixie mentions.

@davidmurdoch
Contributor

Divya, how do you feel about using the meta tag?

@nimbupani
Member

This is what I wrote about it when I was researching language attributes: http://nimbupani.com/declaring-languages-in-html-5.html

@nimbupani
Member

moving lang back to html, also consistent spacing in css. closed by 2a2f1d6

@davidmurdoch
Contributor

meh, things just got WET.

@paulirish
Member

Yup. they did. But here arent any great solutions here. :/

@dustinwhittle dustinwhittle pushed a commit that referenced this issue Apr 18, 2011
@paulirish paulirish move @lang attribute from HTML elem to BODY. fixes #286
thx davidmurdoch
16e9b7d
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment