Specifying A Page's Language

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.


  • 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.

  • You may add the xml:lang and lang attributes to almost any element to define the language for that element and override the language noted in the html tag.

  • Browsers may use this information to determine hyphenation, assist spell checkers and speech synthesizers, etc.

  • Search engines may use this information, but they also use proprietary algorithms to determine which language a page is in.

  • Note that since encodings often encompass more than one language, this tag lets you be more explicit about which language you've actually used.

  • You can find more information about language codes at: http://www.w3.org/International/articles/language-tags/

Figure. Specify the principal language in the html tag. Here I've used fr for French. You can override that value in individual elements, as I've done for the English paragraph at the bottom of this Web page.

21. Internet Explorer for Mac displays guillemet quotes when the language specified is French but curly quotes if the language is English.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows