Specifying A Page’s Language

While saving with the proper encoding and declaring that encoding is essential, it can also be useful to specify the main language in which your page is written. This information may be used by search engines to determine which pages satisfy a language-limited match, or perhaps by a server so that it can serve the appropriate version of a document.

To specify a page’s language:

In XHTML, within the opening html tag, type xml:lang= "code" lang="code", where code is the abbreviation for your page’s main language, as well as any subtags you may want to specify.

✓ Tips

  • The value of xml:lang overrides the value for lang.

  • For HTML, use only the lang attribute. For XHTML served as XHTML, use only the xml:lang attribute. ...

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.