4 ms·
I also found that odd. I've always placed mine in the HTML tag. <html lang="en"> tough, I don't know what the difference is.
by Teichopsia 9y ago
I also found that odd. I've always placed mine in the HTML tag.
<html lang="en">
tough, I don't know what the difference is.
- robin_reala 9y agoPutting it on <html> is better as that defines the language for <title> as well. The lang attribute defines the language of the tree that the element is the root node of.
- franze 9y agostill, who uses it for what? browsers dont change behaviour because of it, search engines ignore it, users dont see it.
- robin_reala 9y ago1. The main reason is screen readers. Imagine a screen reader trying to pronounce ‘Je ne regrette rien’ with an English voice, then imagine the same with a French voice. 2. I’d be surprised if search engines didn’t use it at least as a flag for content language (although I’m sure that it‘s only supplemental at best). 3. Styling based on language. CSS has a :lang() pseudoclass selector so you can do p:lang(en) { color: red; } p:lang(fr) { color: blue; } . Or tie quote styles to language based on generated content. Or most usefully adjust font metrics based on language for multilingual sites (typically you’d want to boost the font size a little for Chinese or Japanese as there are less characters for same information, but each character is a little more dense).
- ozaark 9y agoActually, browsers do change behavior because of it[1], and users do get affected by it[2]. Google have said last year they ignore the lang tag but they do use the hreflang attribute[3] [1] https://www.w3.org/International/tests/repo/results/the-lang-attribute#basics https://www.w3.org/International/tests/repo/results/the-lang... [2] http://accessibility.psu.edu/foreignlanguages/langtaghtml/#about http://accessibility.psu.edu/foreignlanguages/langtaghtml/#a... [3] https://www.seroundtable.com/google-ignores-the-html-lang-attribute-22974.html https://www.seroundtable.com/google-ignores-the-html-lang-at...