Setting a default language for the HTML tag

  • Updated

The HTML lang attribute can be used to declare the language of a Web page or a portion of a Web page. This is meant to assist search engines and browsers.

According to the W3C recommendation you should declare the primary language for each Web page with the lang attribute inside the <html> tag, like this:

<html lang="en">
...
</html>

In XHTML, the language is declared inside the <html> tag as follows:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...
</html>
 
 

As you can not inject this through the CMS, you'll need to edit each template you want to add the tag to.  Simply modify the <HTML> tag to list the language you want.  If you are not sure of what the country language code to use is, you can find a list here:

 

https://www.w3schools.com/tags/ref_language_codes.asp