Writing Code
Language Declaration
Identify the primary natural language of a document and language changes. Identifying the language of the document is important for screen readers.
Techniques
- Immediately following the doctype declaration should be the <html> tag
with attributes declaring the language of the document. Example: <html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
The two language attributes specify the version of xml is written in English and that the document is written in English. - If you are just indicating a language change on a phrase or word use a <span> or <div> tag with the lang attribute. Example: <span lang="es" xml:lang="es">Espanol</span>
- Language codes may be found at the Library of Congress.
