What is the ‘lang’ attribute of the tag used for?

I am quoting this from W3C:

Declaring language in HTML

Always use a language attribute on the html tag to declare the default language of the text in the page. When the page contains content in another language, add a language attribute to an element surrounding that content.

Use the lang attribute for pages served as HTML, and the xml:lang attribute for pages served as XML. For XHTML 1.x and HTML5 polyglot documents, use both together.

Use language tags from the IANA Language Subtag Registry.

Also a good read is Why use the language attribute?.

Leave a Comment