How to specify country and language codes in HTML

Overview

Ever wondered how Google Chrome translates a page from one language to another? In this shot, we’ll learn how to specify the language of our website and its country code. Google Chrome translates the content of a website from one language to another. First, it detects the language of the website. It does so by checking the lang attribute in the html tag.

In <html lang="en-US">, the first letter tells Google Chrome the language that the site was coded in (not the programming language), and the last two letters tell Google Chrome the country. We can have U.S English, or U.K English.

How to specify the language and the country

We place the language code and country code in the lang attribute of the <HTML> tag.

Syntax

<html lang="en-US">

For the list of country codes, click here. For the list of language codes, click here.

Free Resources