The page’s language is the language the majority of the page’s content is in.
Watch the video below to learn:
- Why page language matters
- How to declare the page’s language in the HTML
- What language subtags are
Transcript
The page’s language is the language the majority of the page’s content is in.
In this video, we’ll go over why page language matters, how to declare the page’s language in the HTML, and what language subtags are.
Why page language matters
The page’s language matters for several reasons. First, it’s an accessibility requirement. The reason it’s so important for accessibility is assistive technologies like screen readers use the language to determine how to pronounce text. For example, a screen reader set to English will pronounce words differently than one set to Spanish.
The second reason page language matters is the browser uses the language to help support spell-checking and automatic translation.
Lastly, search engines like Google use the language to understand your content and show it to the right audience.
How to declare page language
Let’s learn how to declare your page’s language.
To set the language for an entire page, you add the language attribute to the HTML element. For example, a page in English would look like this: the html element at the top of the code followed by the language attribute, which is lang. Then the attribute equals en for English.

The lang attribute can be added to any HTML element. So, if there are paragraphs or words that use a different language than the page’s primary language, you can add the lang attribute to the paragraph or span element.
For example, let’s say there’s a page in English, but there is some text in Spanish. The code might look like this: the span element with the lang attribute set to es for Spanish wrapped around the text in Spanish.

So, we use the lang attribute and language subtags to declare the page’s primary language. We also use them to define language changes in the content.
What language subtags are
Language subtags are the code that determines the language. The en and es for English and Spanish are the language subtag. There are thousands of language subtags you can use and combine to identify the language.

Some languages can use additional subtags to make it more specific. For example, en-US would be United States English which might have different spelling and pronunciation than en-GB, which is Great Britain English.

For the most part, using additional language subtags isn’t recommended unless it adds additional spelling or pronunciation information.
You can find language subtags and check combinations in the Official Language Subtag Directory or the Language Subtag Lookup tool – both linked below.

You’re ready to define page language on your website.