When serving XHTML 1.x or polyglot pages as text/html, use both the lang attribute and the xml:lang attribute together every time you want to set the language. The xml:lang attribute is the standard way to identify language information in XML. The lang attribute helps people in multiple ways, such as making it easier for translation apps to identify the language of a section of text.

Understanding the Context

Another is with regards to accessibility. Pregunta ¿Cómo debo establecer el idioma del contenido de mi página HTML? Respuesta rápida Use siempre un atributo de idioma en la etiqueta html para declarar el idioma predeterminado del texto de la página. Cuando la página tenga contenido en otro idioma, agregue un atributo de idioma a un elemento que rodee a ese contenido.

Key Insights

Use el atributo lang para páginas servidas como HTML, y el ... Language tags are used to indicate the language of text or other items in HTML and XML documents. Use the lang attribute to specify language tags in HTML, and the xml:lang attribute for XML. In both cases, language information is inherited by elements inside the one where the declaration was made, unless one of those elements declares a different language (in the same way). The lang (or sometimes the xml:lang ) attribute specifies the natural language of the content of a web page.

Final Thoughts

An attribute on the html tag sets the language for all the text on the page. If part of the page uses text in a different language, you can add a language attribute with a different value to the element that surrounds that content. The objective of this technique is to identify the default language of a document by providing the lang attribute on the html element. Identifying the language of the document is important for a number of reasons: It allows braille translation software to substitute control codes for accented characters, and insert control codes necessary to prevent erroneous creation of Grade 2 braille ... H57: Using the language attribute on the HTML element | WAI | W3C The lang attribute's value is a language code that identifies a natural language spoken, written, or otherwise used for the communication of information among people.