Lang Meta Tag: How to Set the Correct HTML Language Attribute

Quick Answer
A lang meta tag is the common name people use when searching for an HTML declaration that identifies a webpage's language. However, the correct implementation is not a special meta element. Use the lang attribute on the opening HTML element, such as <html lang="en-US"> for a US English webpage. This helps browsers and assistive technologies interpret the page's language correctly.
Key Takeaways
- The HTML
langattribute, not a dedicated meta tag, declares the default language of a webpage. - Place the attribute on the opening
<html>element. - Use a valid BCP 47 language identifier, such as
en-US,en-GB, orbn-BD. - Apply additional
langattributes to individual elements when their content changes language. - Correct language declarations support accessibility, including appropriate screen-reader pronunciation.
- Google's documented language detection relies on page text rather than HTML
langannotations. - Do not confuse
langwithhreflang, HTTPContent-Language, or character encoding.
What Is a Lang Meta Tag in HTML?
When website owners search for a lang meta tag, they usually want to tell browsers and other software which language a webpage uses. The terminology is understandable, but technically, HTML handles this through a global attribute called lang.
An HTML attribute provides additional information about an element. A meta element, by comparison, supplies document metadata, typically inside the <head> section.
The lang attribute identifies the language of an element's text content. It can appear on the main HTML element or on individual elements within the page.
For example:
<html lang="en-US">
This declares that the document's default language is US English.
The attribute follows the HTML global-attribute model, meaning it can be used on different HTML elements rather than being restricted to one particular element.
According to MDN's documentation on the HTML lang global attribute, language identifiers follow the BCP 47 standard. The WHATWG HTML Standard also defines how the attribute identifies an element's language.
The important distinction is that you do not need to create a separate language meta element to declare the default language of an HTML document.
How to Add the Lang Attribute to Your HTML Page
The recommended approach is to place the lang attribute directly inside the opening <html> tag.
Here is a complete example for a US English webpage:
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Example Website</title>
</head>
<body>
<h1>Welcome to Our Website</h1>
<p>This page is written in US English.</p>
</body>
</html>
Notice the position of the language declaration:
<html lang="en-US">
It appears before the <head> and <body> elements because it belongs to the root HTML element.
The declaration establishes the default language for the document. Descendant elements generally inherit that language unless another language is explicitly declared on an element.
Why Does the Attribute Belong on the HTML Element?
The opening <html> element represents the root of an HTML document. Declaring its language provides a default that language-aware software can use throughout the page.
This is preferable to declaring the language only on a heading, paragraph, or another individual element because those declarations do not establish the language of the entire document.
The W3C guide to declaring language in HTML recommends using the lang attribute on the HTML element for the default document language.
What If You Use WordPress or Another CMS?
Many content management systems and website frameworks generate HTML automatically. Depending on the platform, theme, configuration, or language settings, the published document may already contain a language declaration.
Before adding custom code, inspect the rendered HTML of your published page.
Look for the opening HTML element:
<html lang="en-US">
If the correct declaration is already present, you generally do not need to add another one. If it is missing or incorrect, investigate the relevant language configuration or template responsible for generating the document.
The important thing is the final HTML delivered to visitors, not simply the setting displayed in your website dashboard.
Which Language Code Should You Use?
HTML language declarations use identifiers based on BCP 47, a standard system for identifying languages and optional variations such as regional differences.
You can use a general language identifier or a more specific one when the distinction is useful.
For example, en identifies English, while en-US identifies English as used in the United States.
Here are common examples:
| Language or variation | HTML language value |
|---|---|
| English | en |
| US English | en-US |
| British English | en-GB |
| Bengali | bn |
| Bengali for Bangladesh | bn-BD |
| French | fr |
| Canadian French | fr-CA |
| German | de |
These identifiers describe language and regional variations. They are not SEO keywords or geographic targeting instructions.
Should You Use En or En-US?
Both can be appropriate, depending on your content.
Use:
<html lang="en">
when a general English declaration accurately describes the document.
Use:
<html lang="en-US">
when you want to identify US English more specifically.
For a website primarily serving US readers with American English content, en-US is a sensible choice.
Similarly, a British English website can use en-GB.
A regional identifier should reflect the actual language variation being declared. Do not choose a different language tag merely because you want to attract visitors from another country.
Common Language-Code Mistakes
A few simple mistakes can make a declaration invalid or misleading.
| Incorrect or unsuitable example | Better approach |
|---|---|
lang="english" |
lang="en" |
lang="en_US" |
lang="en-US" |
lang="US" |
lang="en-US" when the content is US English |
lang="fr" on an English-only page |
Use the language that actually describes the content |
Use standard BCP 47 identifiers rather than inventing abbreviations. Language tags are case-insensitive, although the conventional presentation uses lowercase language subtags and uppercase two-letter region subtags.
You can consult the IANA Language Subtag Registry when checking registered language identifiers.
Can One Webpage Have More Than One Language?
Yes. A webpage can contain multiple languages while maintaining one default document language.
The HTML lang attribute supports this through inheritance and local overrides.
Suppose your website is primarily written in US English but includes a French quotation. You can declare the French passage separately:
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Multilingual Example</title>
</head>
<body>
<h1>Welcome to Our Website</h1>
<p>This paragraph is written in English.</p>
<p lang="fr">
Bienvenue sur notre site.
</p>
</body>
</html>
The document's default language remains English. The second paragraph explicitly identifies its content as French.
You can also use the attribute on smaller elements:
<p>
The French greeting is
<span lang="fr">Bonjour</span>.
</p>
This is useful for multilingual websites, quotations, translated passages, product descriptions, and language-learning content.
Why Are Local Language Declarations Important?
A screen reader may use the declared language to select appropriate pronunciation rules and speech processing.
Without an accurate language declaration, a screen reader could attempt to pronounce foreign-language text using the default language's pronunciation rules.
The same principle applies to other language-aware software that interprets or processes text.
Accordingly, identifying the main document language and meaningful changes within it is an important accessibility practice.
The MDN lang attribute reference explains how language declarations apply to individual elements and how they support accessibility.
Lang Attribute vs. Meta Content-Language, HTTP Header, and Hreflang
Several HTML and HTTP mechanisms contain language-related information. They are not interchangeable, even though their names can appear similar in website documentation and SEO tutorials.
The easiest way to avoid implementation mistakes is to understand what each mechanism actually does.
HTML Language Declaration Decision Matrix
| Mechanism | Example | Main purpose | Recommended use |
|---|---|---|---|
HTML lang |
<html lang="en-US"> |
Identifies the default document language | Use on the root HTML element |
Local lang |
<span lang="fr"> |
Identifies a particular passage's language | Use when content changes language |
| Meta Content-Language | <meta http-equiv="content-language" content="en"> |
Historical HTML language declaration approach | Do not use as the modern document-language declaration |
| HTTP Content-Language | Content-Language: en |
Provides HTTP-level language or audience metadata | Configure separately where appropriate |
| Hreflang | <link rel="alternate" hreflang="fr" href="https://example.com/fr/page/"> |
Identifies an alternate localized URL | Use for relevant international SEO configurations |
| Character encoding | <meta charset="UTF-8"> |
Identifies how document characters are encoded | Declare separately from language |
The differences become clearer when each mechanism is examined individually.
1. HTML Lang Attribute
The HTML lang attribute identifies the language of the text within an element.
Example:
<html lang="en-US">
Use it to establish the default language of an HTML document. Add local declarations when sections or passages use different languages.
This is the recommended mechanism for declaring the document language.
2. The Deprecated Meta Content-Language Declaration
Some older tutorials recommend this syntax:
<meta http-equiv="content-language" content="en-US">
Although you may still encounter it in older websites and documentation, it is not the recommended modern HTML method for declaring the language of document text.
The W3C explains that using this meta declaration for the default language of HTML text is deprecated by the HTML specification.
Instead of copying an outdated example, use:
<html lang="en-US">
See the W3C explanation of HTTP headers, meta elements, and language information for the distinction.
3. HTTP Content-Language Header
HTTP provides a separate mechanism called the Content-Language response header.
For example:
Content-Language: en
This is an HTTP-level declaration, not an HTML attribute or a meta element.
The header can describe the language or intended audience associated with a response. Its meaning is not identical to identifying the language of every passage in an HTML document.
For that reason, it should not be treated as a replacement for the HTML lang attribute.
You can read more in MDN's Content-Language HTTP header documentation.
4. Hreflang for International SEO
The hreflang annotation serves a different purpose from lang.
It helps search engines identify alternate versions of a webpage intended for different languages or regional audiences.
For example:
<link rel="alternate"
hreflang="fr"
href="https://example.com/fr/page/">
This tells search engines about a French-language alternative URL. It does not declare that the current HTML document is written in French.
A localized website might have the following structure:
<!-- English version -->
<html lang="en-US">
<!-- French version -->
<html lang="fr">
The pages can also use appropriate alternate-language annotations to identify their relationship.
Google recommends consistent alternate-page annotations, including appropriate self-referencing and reciprocal references between localized versions.
For implementation details, see Google Search Central's guide to localized versions of webpages.
One important distinction: hreflang helps identify alternate URLs, but it does not determine the actual language of their content.
5. Character Encoding Is Different Too
Another common source of confusion is the charset declaration.
For example:
<meta charset="UTF-8">
This identifies the character encoding used by the document. UTF-8 supports characters from many writing systems, including English, Bengali, French, and other languages.
However, character encoding does not identify which language the webpage uses.
Compare the two declarations:
<html lang="en-US">
<meta charset="UTF-8">
The first identifies the document language. The second declares character encoding.
A correctly configured webpage may need both, because they solve different technical problems.
For a broader explanation of common HTML metadata, see our guide to blog meta tags and how to check them.
Does the Lang Meta Tag Help Google SEO?
The HTML lang attribute is useful for accessibility and language-aware processing, but Google does not document it as a direct ranking improvement or rely on it to determine a webpage's language.
This distinction matters because many older SEO tutorials suggest that adding a language declaration automatically tells Google which language a page targets.
Google's documentation provides a more specific explanation.
According to Google Search Central's documentation on supported meta tags and attributes, Google determines the language of a page from its textual content rather than relying on HTML language annotations such as lang.
In practical terms:
- Adding
lang="en-US"does not force Google to classify a page as US English. - Adding a language declaration is not a documented direct Google ranking shortcut.
- Incorrect language markup should not be used to disguise the actual language of the content.
- Writing genuinely relevant content in the intended language remains important.
- Correct
langdeclarations still provide meaningful accessibility and technical benefits.
Does Google Ignore the Lang Attribute Completely?
For Google's documented page-language detection, HTML lang annotations are not the determining mechanism.
That does not make the attribute unnecessary.
Its primary purpose is to communicate language information to browsers, assistive technologies, and other software that can use it.
A technically well-structured webpage should not omit useful accessibility information simply because Google does not rely on that information for language detection.
What Should You Use for Multilingual SEO?
If your website publishes different language versions at separate URLs, consider the appropriate hreflang configuration.
For example:
https://example.com/en/for an English version.https://example.com/fr/for a French version.
Each page should have accurate language content and its own appropriate HTML lang declaration. The alternate-page relationships can be identified separately through hreflang annotations.
Google's localized versions documentation explains the supported methods for communicating these relationships.
Do not confuse this process with declaring the language of an individual document. Both mechanisms can be useful, but they have different jobs.
How to Check Whether Your Lang Attribute Is Correct
After adding a language declaration, inspect the actual published webpage rather than assuming your HTML or CMS settings are correct.
Use this practical checklist.
Step 1: Identify the Main Content Language
Determine which language is actually used in the main content.
For a webpage written in American English, en-US is an appropriate example. For a Bengali-language page intended for Bangladesh, bn-BD may be suitable.
Choose a declaration that describes the content accurately.
Step 2: Inspect the Opening HTML Element
Open the published page and inspect its HTML source or DOM using your browser's developer tools.
Find the opening HTML element:
<html lang="en-US">
Check that the attribute exists and that its value is appropriate.
If the declaration is missing, investigate the template or CMS configuration responsible for generating the page.
Step 3: Check the Language Identifier
Verify that the language value follows BCP 47 conventions.
Avoid invented language abbreviations, country-only values, and underscore-separated regional identifiers.
Use the IANA Language Subtag Registry when you need to confirm a registered language subtag.
Step 4: Inspect Multilingual Passages
If your page contains substantial content in another language, check whether the relevant element has its own language declaration.
For example:
<p lang="fr">Bienvenue sur notre site.</p>
The main document language and the language of a particular passage do not have to be identical.
Step 5: Keep Related Mechanisms Separate
Check that you have not confused the following declarations:
langfor document and element language.hreflangfor alternate localized URLs.- HTTP
Content-Languagefor response-level language or audience information. charsetfor character encoding.
Avoid adding obsolete meta Content-Language examples just because they appear in older tutorials.
Step 6: Consider Accessibility Testing
Where possible, test the page with assistive technology, including a screen reader.
Check whether the main language and meaningful language changes are communicated appropriately.
A correct HTML declaration is an important part of accessibility, but it does not guarantee that every aspect of a page is accessible. The content, structure, labels, navigation, and other implementation details also matter.
Frequently Asked Questions
Is a Lang Meta Tag the Same as the HTML Lang Attribute?
No. A lang meta tag is a common search phrase, but the correct HTML mechanism is the lang attribute. It is normally placed on the opening <html> element to identify the default language of the document.
Should I Use Lang="En" or Lang="En-US"?
Both are valid language identifiers. Use en for general English and en-US when you want to specify US English. Choose the identifier that accurately describes the webpage's language.
Does the Lang Attribute Directly Improve Google Rankings?
Google states that it determines webpage language from textual content rather than relying on HTML lang annotations. The attribute is still valuable for accessibility and language-aware software, but you should not expect a direct ranking improvement from adding it.
Can I Use Multiple Lang Attributes on One Page?
Yes. Set a default language on the root <html> element, then use additional lang attributes on individual elements when their content is written in another language.
Is Meta HTTP-Equiv="Content-Language" Still Recommended?
No. The W3C identifies this historical meta declaration as deprecated for declaring the default language of HTML text. Use the HTML lang attribute instead.
What Is the Difference Between Lang and Hreflang?
lang identifies the language of the current document or an individual element. hreflang identifies alternate localized versions of a URL for search engines. They are different mechanisms and can be used together.
Where Should I Put the HTML Lang Attribute?
Place the default language declaration on the opening <html> element, before the <head> element. For example, <html lang="en-US">.
Does Every Webpage Need a Lang Attribute?
For accessible HTML documents, declaring the default language is an important practice. WCAG Success Criterion 3.1.1 requires the language of a page to be programmatically determinable. Use an accurate language declaration rather than leaving the language unspecified when it is known.
Final Thoughts
The most important thing to understand about a lang meta tag is that the correct HTML implementation is an attribute, not a dedicated meta element.
For a US English webpage, start with <html lang="en-US">. Use valid BCP 47 language identifiers, declare meaningful language changes within the page, and keep language identification separate from character encoding and international SEO annotations.
Correct language markup helps assistive technologies interpret your content appropriately. Although Google does not rely on the attribute for its page-language detection, it remains an important part of well-structured, accessible HTML.