Specify each HTML document’s main natural language
Always specify which natural language (spoken, written or signed human language) is used for a document’s content.
For HTML documents that only use a single natural language, specify that language by setting the lang
attribute on the HTML element. If you are using XHTML, use xml:lang
. If you use XHTML served as text/html
(you most likely do), use both lang
and xml:lang
.
The natural language of most pages on this site is English, which is specified like this in HTML:
<html lang="en">
Further reading
Internationalization Best Practices: Specifying Language in XHTML & HTML Content
Language information is useful for things such as authoring tools, translation tools, accessibility, font selection, page rendering, search, and scripting.
- Language tags in HTML and XML
- WCAG 1.0 Checkpoint 4.3
Understanding WCAG 2.0 3.1.1, Language of Page
Both assistive technologies and conventional user agents can render text more accurately when the language of the Web page is identified. Screen readers can load the correct pronunciation rules. Visual browsers can display characters and scripts correctly. Media players can show captions correctly. As a result, users with disabilities will be better able to understand the content.
- XHTML 1.0 HTML Compatibility Guidelines, The lang and xml:lang Attributes
This post is a Quick Tip. Background info is available in Quick Tips for web developers and web designers.