HTML and CSS Reference
In-Depth Information
Introduce lang Attributes
Add lang and xml:lang attributes to each root element identifying the primary language of the document. Add
superseding lang and xml:lang attributes to any element in that document that is written in a different
language.
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>Pierre shouted, "Vive la France!"</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US" xml:lang="en-US">
<body>
<p>Pierre shouted,
"<span lang="fr" xml:lang="en-US">Vive la France!</span>"
</p>
</body>
</html>
Motivation
Proper language identification is important for pronunciation by screen readers.
Language identification also assists search engines. Your French pages are more likely to be picked up by
google.fr and your German pages by google.de if the content is properly tagged.
Finally, language identification assists you when authoring pages, especially when working in something other
than a system's primary language. It enables editors to choose the proper dictionary for spell checking.
Potential Trade-offs
None. This is only for the good.
Mechanics
If you know none of your documents already contains a lang or xml:lang attribute, and that they're all written
in the same language, it's easy to search for <html and replace it with <html lang='en' xml:lang='en' .
If you aren't certain whether there are any such attributes already, try searching for lang\s*=\s*['"a-zA-z] .
If nothing turns up, it's highly likely that there aren't any.
If you do find that some of your documents have such attributes already and some don't, the following regular
Search WWH ::




Custom Search