Get Your Free Accessibility & Inclusion Toolkit
Download NowOne of the simplest yet most powerful web accessibility tools at a developer’s disposal is the HTML lang attribute. But what exactly does the lang attribute do? And how does it make the web more accessible for users across the globe?
In this article we will explore the importance of language tags in HTML, particularly their role in accessibility, SEO, and screen reader functionality. We’ll also walk through examples and best practices so you can confidently apply this knowledge to your own website.
Why are HTML lang attributes important and who do they help?
The HTML lang attribute is used to declare the language of a webpage or a specific element within a page. Its primary purpose is to help assistive technologies, like screen readers, interpret and pronounce content correctly for users who rely on these tools.

For example, someone using a screen reader in the US might expect content to be read in English. But if a paragraph on your page is in Spanish and not properly marked, the screen reader will try to pronounce the Spanish text as if it were English, causing confusion for the person.
Who benefits from lang attributes?
- Screen reader users, including people who are blind or visually impaired.
- People using translation tools. The lang attribute allows browser extensions and other software to correctly translate and display content in different languages.
- Search engines, which use language tags for indexing and relevancy.
In short, the lang attribute improves the experience for both users and technology interacting with your content.
Get a free automated accessibility check of your websites homepage. This will identify and highlight any compliance issues on your website. Followed by recommendations on how to implement the necessary changes to make your website more accessible.

How do HTML lang tags impact screen readers and text-to-speech software?
Screen readers and text-to-speech (TTS) tools rely on the lang attribute to know how to pronounce content. These tools come equipped with language-specific pronunciation rules and voice settings. Without the proper language indicator, they might default to the wrong voice or inflection.

This is particularly crucial for:
- Websites with bilingual or multilingual content. Blogs, international news outlets, or educational resources often contain content in more than one language. Accurate language tagging ensures seamless switching between languages for users with assistive technology.
- Pages including foreign quotes, terms, or idioms. Even a single word or phrase in another language should be wrapped in a lang tag. This helps preserve the integrity of the original expression and ensures correct pronunciation.
- Documents for international audiences. Global businesses, government publications, or academic journals often serve diverse audiences.
In essence, screen readers don’t “understand” languages the way humans do, instead they rely on the lang attribute to provide instructions. Without it, even the most well-written content can become unintelligible to someone using assistive technology.
What are the best practices for using lang attributes on your website?
To get the most benefit from language tagging, you should follow a few best practices. These help ensure your use of language tags is consistent, enhances usability and complies with accessibility standards like the Web Content Accessibility Guidelines (WCAG).
Declare the page’s primary language in the <html> tag
This lets assistive technologies know the default language of the document. Some pages include content in multiple languages, such as government websites that are legally required to provide information in more than one language. In these cases, the lang attribute on the <html> tag should reflect the most dominant language used throughout the page.
You can find the complete list of valid language codes here at W3.

Be consistent.
Avoid having contradictory or missing lang attributes. If the document is in English, but your <html> tag says lang=”fr”, it will confuse screen readers and search engines.
Validate with accessibility tools.
Use a screen reader to read out content across your website to check if your language declarations are working as expected.

Mark inline foreign phrases or sections with lang
For snippets of another language within a sentence, use the lang attribute on the appropriate element. This instructs assistive technologies to switch languages temporarily, ensuring accurate pronunciation and a smoother user experience.
The <span> element is a commonly used inline HTML container that allows you to apply attributes like lang to a specific portion of text without changing the layout or structure of the content.
Use language subtags when appropriate
So instead of just lang=”en” (English) , consider lang=”en-gb” (British English) or lang=”en-us” (American English) to specify dialects when needed. This helps with regional spelling differences (e.g., “color” vs “colour”) and localised screen reader voices.
Will using language attributes improve website visibility in search engines?
While the lang attribute isn’t a direct ranking factor for SEO, accessibility improvements often align with SEO best practices, and language tagging is no exception. It helps search engines better categorise content, improves user experience with translation tools, and contributes to higher accessibility scores. When combined with other SEO elements, lang helps to strengthen both accessibility and search visibility.
Lang Attributes Vs HREFLang
When it comes to multilingual indexing, search engines like Google tend to prioritise the hreflang attribute over lang.
So it’s important to understand the difference:
- The lang attribute defines the language of the on-page content. It primarily benefits assistive technologies and user agents.
- The hreflang attribute is used in the page’s <head> section (or HTTP headers) to tell search engines which version of a page to show to users based on their language and region preferences.

They serve different purposes, but they work best together. Each page should declare its language with a lang attribute and include appropriate hreflang tags if you offer alternate versions for different regions or languages.
Having both ensures accessibility and search discoverability are optimised, and while it may only have a minor direct impact on rankings, it greatly improves user experience and content relevance across audiences.
Examples of lang tag attributes in different scenarios
Below are a few real-world examples that illustrate how to use the lang attribute correctly depending on the type of content you’re serving.
Single language document
Use this setup when your page content is entirely in one language. In this example, we declare English as the default.
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<title>My English-only Page</title>
</head>
<body>
<h1>Welcome!</h1>
<p>This page is entirely in English.</p>
</body>
</html>
Mixed language document
This example shows how to apply lang attributes when the content includes multiple languages. Here, the base language is English (lang=”en”), but we override that for specific paragraphs and spans (inline elements) where Spanish or French is used.
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<title>Multilingual Snippet</title>
</head>
<body>
<p lang=”en”>Here’s a sentence in English,</p>
<p lang=”es”>Aquí tienes una frase en español.</p>
<p>
The French word for “library” is
<span lang=”fr”>bibliothèque</span>,
pronounced differently from English.
</p>
</body>
</html>
Landmarks & ARIA regions
You can also apply lang attributes within semantic HTML regions or ARIA landmark roles to reflect different languages used in specific page sections. In this multilingual layout, each section’s language is clearly marked, which is especially useful for large sites or applications that serve different languages dynamically.
<!– 3. Using lang on landmarks & ARIA regions –>
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<title>ARIA Landmarks Example</title>
</head>
<body>
<header role=”banner” lang=”en”>
<h1>Site Title</h1>
</header>
<nav role=”navigation” lang=”en”>
<ul>
<li><a href=”#”>Home</a></li>
<li><a href=”#”>About</a></li>
</ul>
</nav>
<main role=”main”>
<article lang=”ja”>
<h2>日本語の見出し</h2>
<p>これは日本語で書かれた段落です。</p>
</article>
</main>
<footer role=”contentinfo” lang=”en”>
<p>© 2025 My Website</p>
</footer>
</body>
</html>
Our 40-page Digital Accessibility & Inclusion Toolkit helps businesses break down online barriers and make a real impact. It offers practical advice on all aspects of digital accessibility, from writing an accessibility statement to accessible website tips and inclusive hiring.

The verdict: Make sure your website is Lang Tag compliant
The HTML lang attribute may seem like a small detail in your code, but its role in web accessibility and user experience is significant. By clearly indicating the language of your content, you’re not only improving how screen readers and assistive technologies interpret your site, you’re also supporting better translation and even helping search engines better understand your content. It’s an essential part of building websites that are not just usable, but respectful and welcoming to all users.
If you’re not already using lang attributes in your HTML, now is the time to start. Whether your site is monolingual or supports multiple languages, applying these best practices ensures you’re delivering a more accessible, user-friendly, and international experience.
HTML lang tag attributes FAQs
Looking for a recap or quick summary? Here are a few of our most frequently asked questions to help you get to grips with the essentials:
Can I use multiple lang attributes on a single element?
No. Each HTML element can only have one lang attribute. If content contains multiple languages, split it into nested elements with separate lang tags.
What’s the difference between lang="en" and lang="en-US"?
The former specifies English in general, while the latter is specific to US English. This helps with regional variations in pronunciation and spelling.
Do I need lang if my site is only in one language?
Yes. Always declare a base language at the root <html> tag, even for single-language sites.
Is lang required for WCAG compliance?
Yes. According to WCAG 2.1, success criteria 3.1.1 and 3.1.2 require language declarations at both the page and element level for accessibility.
Does the lang tag replace the need for hreflang in SEO?
No. Lang attributes improve on-page accessibility by telling assistive technologies how to interpret the content. Hreflang, on the other hand, is used in the <head> or headers for search engines to determine the right version to serve in regional search results.