Language Specification
Authors are strongly urged to specify the language for all HTML and XHTML documents. To specify a language
for XHTML documents, use the xml:lang
attribute in the html root element.
HTML documents use the lang attribute
for the same purpose . To ensure backward compatibility, the convention is
simply to use both attributes, as shown in this example, which specifies
the language of the document as French.
<htmlxml:lang="fr" lang="fr" xmlns="http://www.w3.org/1999/xhtml" >Tip
Users can set language preferences in their browsers. This language preference information is passed to the server when the user makes a request for a document. The server may use it to return a document in the preferred language if there is a document available that matches the language description.
The language attributes may be used in a particular element to override the language declaration for the document. In this example, a long quotation is provided in Norwegian.
<blockquotexml:lang="no" lang="no">...</blockquote>Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access