<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui" -->

---
title: Quick Tip: Use the “lang” Attribute for Better Accessibility
description: The lang attribute is a global HTML attribute that specifies the language of an element and its children using standardized language subtags, such as "en" or...
canonical: https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Quick Tip: Use the “lang” Attribute for Better Accessibility | daily.dev
og:description: The lang attribute is a global HTML attribute that specifies the language of an element and its children using standardized language subtags, such as "en" or...
og:url: https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui
og:image: https://api.daily.dev/og/posts/0Z4pBGWui.png
og:image:alt: Quick Tip: Use the “lang” Attribute for Better Accessibility
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Tip: Use the “lang” Attribute for Better Accessibility

**[Eric Bailey](https://daily.dev/sources/ericwbailey)** · 3 min read · 0 upvotes · 0 comments

## Summary

The lang attribute is a global HTML attribute that specifies the language of an element and its children using standardized language subtags, such as "en" or "en-GB". Setting it correctly on the html element, and overriding it for embedded content in a different language, helps translation tools like Chrome's translate feature work accurately and lets screen readers like JAWS pronounce content correctly. It's a small semantic addition that meaningfully improves accessibility and interoperability with automated services.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://webdesign.tutsplus.com/tutorials/use-the-lang-attribute-for-better-accessibility--cms-31961>

## Questions this post answers

### How do I mark up a section of a page that's in a different language than the rest of the content in HTML?

Add a lang attribute with the appropriate language subtag to the wrapping element of that section, overriding the page-level lang set on the html tag. For example, if the page is set to lang="en" but contains a Spanish section, wrap that section in an element like aside lang="es" so screen readers and translation tools handle it correctly.

_Developers polishing accessibility details like this often track HTML best practices on daily.dev._

### Why does the HTML lang attribute matter for screen readers and translation tools?

It tells software what language content is written in, so screen readers like JAWS pronounce words correctly and translation services like Chrome's built-in translator trigger accurately. Without it, a screen reader may read foreign phrases using the wrong language's pronunciation rules, and translation prompts may not appear or may misfire.

_daily.dev helps developers stay sharp on accessibility fundamentals like language declarations._

## Similar posts on daily.dev

- [This blog is written in en-GB](https://daily.dev/posts/this-blog-is-written-in-en-gb-qgoqezok3) · Terence Eden · 0 upvotes · 0 comments
- [Lost, forgotten, and unfamiliar HTML](https://daily.dev/posts/lost-forgotten-and-unfamiliar-html-gzqwgcxgb) · thoughbot · 75 upvotes · 3 comments
- [Metadata for AI Generated Outputs](https://daily.dev/posts/metadata-for-ai-generated-outputs-jxsqay6nn) · Terence Eden · 2 upvotes · 0 comments
- [The Enforced Accessibility of the Geolocation Element – Frontend Masters Blog](https://daily.dev/posts/the-enforced-accessibility-of-the-geolocation-element-frontend-masters-blog-vsdfbupnk) · Frontend Masters · 2 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#html](https://daily.dev/tags/html), [#accessibility](https://daily.dev/tags/accessibility)

[View this post on daily.dev](https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Quick Tip: Use the “lang” Attribute for Better Accessibility","url":"https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui"},"datePublished":"2026-09-20T07:43:42.132Z","dateModified":"2026-09-20T07:49:47.560Z","description":"The lang attribute is a global HTML attribute that specifies the language of an element and its children using standardized language subtags, such as \"en\" or...","image":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","thumbnailUrl":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","isAccessibleForFree":true,"articleSection":"Eric Bailey","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Eric Bailey","logo":"https://media.daily.dev/image/upload/s--r1vwe6z1--/f_auto,q_auto/v1789890198/logos/ericwbailey?_a=BAMAMicg0","url":"https://daily.dev/sources/ericwbailey"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,html,accessibility","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Eric Bailey","item":"https://daily.dev/sources/ericwbailey"},{"@type":"ListItem","position":3,"name":"Quick Tip: Use the “lang” Attribute for Better Accessibility"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/quick-tip-use-the-lang-attribute-for-better-accessibility-0z4pbgwui#faq","mainEntity":[{"@type":"Question","name":"How do I mark up a section of a page that's in a different language than the rest of the content in HTML?","acceptedAnswer":{"@type":"Answer","text":"Add a lang attribute with the appropriate language subtag to the wrapping element of that section, overriding the page-level lang set on the html tag. For example, if the page is set to lang=\"en\" but contains a Spanish section, wrap that section in an element like aside lang=\"es\" so screen readers and translation tools handle it correctly. Developers polishing accessibility details like this often track HTML best practices on daily.dev."}},{"@type":"Question","name":"Why does the HTML lang attribute matter for screen readers and translation tools?","acceptedAnswer":{"@type":"Answer","text":"It tells software what language content is written in, so screen readers like JAWS pronounce words correctly and translation services like Chrome's built-in translator trigger accurately. Without it, a screen reader may read foreign phrases using the wrong language's pronunciation rules, and translation prompts may not appear or may misfire. daily.dev helps developers stay sharp on accessibility fundamentals like language declarations."}}]}
```

