How to set language tags for html web pages

 Author: Shengtao Zhou       Created: 1/16/2019 8:53:01 AM       Modified: 2/2/2019 5:36:12 AM   More...

By W3C recommendation, web pages should always have language tag defined.


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.

In short, use "lang" tag for html, "xml:lang" and "xmlns" for html. Here's an example,

If you have some content text that using a different language, you can indicate it like this,

In HTML5, the lang attribute can be used on any HTML element. There were some restrictions in HTML 4.01

The "lang" tag gives browser clue to display language code correctly, without the needs of user interaction to choose the proper language manually on a browser. Search engines also use it to targeting the correct readers. Bing is checking "lang" tags. But Google seems to ignore "lang" tag. 

Google is using "hreflang" language tags instead to help with indexing the page.  You should use separate links for each language you support and indicate the URL for the language. Also, it's better to include an "x-default" link, to indicate which URL to use if a browser does not use the languages you indicated.

Here is the page from Google, about how to tell Google the localized versions of your page:

More...          Back to List          

(Please enter you comments between 100 to 2000 characters. Thanks for your contribution.) 

         Created:       Modified: 

Editing a comment

       (Please enter you comments between 100 to 2000 characters. Please login before edit comment.) 

div class="col-md-2">