<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6" -->

---
title: Using the language attribute to make your website accessible
description: Explains how to use the HTML lang attribute to satisfy WCAG criteria 3.1.1 (Language of page) and 3.1.2 (Language of parts), which help screen readers...
canonical: https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using the language attribute to make your website accessible | daily.dev
og:description: Explains how to use the HTML lang attribute to satisfy WCAG criteria 3.1.1 (Language of page) and 3.1.2 (Language of parts), which help screen readers...
og:url: https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6
og:image: https://api.daily.dev/og/posts/cBfxuCQU6.png
og:image:alt: Using the language attribute to make your website accessible
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.

# Using the language attribute to make your website accessible

**[Craig Abbott](https://daily.dev/sources/craigabbott)** · 5 min read · 0 upvotes · 0 comments

## Summary

Explains how to use the HTML lang attribute to satisfy WCAG criteria 3.1.1 (Language of page) and 3.1.2 (Language of parts), which help screen readers pronounce content correctly. Covers setting lang on the html element, marking foreign-language blocks and inline phrases with lang, why the idiomatic <i> element is preferred over spans for language tagging, and a real-world example of a UK government site switching between English and Welsh versions. Points to ISO 639-1 codes and an npm package for looking up language codes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.craigabbott.co.uk/blog/2022/using-the-language-attribute-to-make-your-website-accessible>

## Questions this post answers

### How do I mark up a paragraph that mixes English and French text so screen readers pronounce both correctly?

Wrap the foreign-language portion in an idiomatic text element with a lang attribute, such as an <i lang="fr"> tag around the French phrase, rather than applying lang to the whole paragraph. Applying lang to the entire paragraph would cause a screen reader to read all of it in French. Spans should be avoided since some screen readers ignore lang on span elements.

_daily.dev surfaces accessibility techniques like this for developers polishing multilingual pages._

### Do I need to add a lang attribute to every paragraph on my webpage?

No, you only need to set lang once on the html element and child elements inherit it automatically. You only add a lang attribute to specific elements when their content is in a different language than the page default, such as adding lang="fr" to a single paragraph on an otherwise English page.

_Developers auditing WCAG compliance can find practical lang-attribute patterns like this via daily.dev._

### What happens if I don't set the lang attribute on my HTML page?

Without a lang attribute, the browser treats the language as unknown, which can cause screen readers to mispronounce content unpredictably. Setting lang="en" (or the appropriate ISO 639-1 code) on the html element ensures the browser and assistive technology know how to read the text correctly, satisfying WCAG criterion 3.1.1.

_daily.dev helps developers catch overlooked accessibility basics like missing lang attributes._

## 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
- [Barriers from Links with ARIA](https://daily.dev/posts/barriers-from-links-with-aria-1gi6b0uo0) · Adrian Roselli · 1 upvotes · 0 comments
- [Lost, forgotten, and unfamiliar HTML](https://daily.dev/posts/lost-forgotten-and-unfamiliar-html-gzqwgcxgb) · thoughbot · 75 upvotes · 3 comments
- [How to Build More Accessible Websites with WCAG 2.2](https://daily.dev/posts/how-to-build-more-accessible-websites-with-wcag-2-2-ionjqlod0) · freeCodeCamp · 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/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6)

```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":"Using the language attribute to make your website accessible","url":"https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6"},"datePublished":"2026-09-20T07:44:10.841Z","dateModified":"2026-09-20T07:46:49.384Z","description":"Explains how to use the HTML lang attribute to satisfy WCAG criteria 3.1.1 (Language of page) and 3.1.2 (Language of parts), which help screen readers...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a0ffc407e6f6c1b75eadc5a3e5dc0325?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a0ffc407e6f6c1b75eadc5a3e5dc0325?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Craig Abbott","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":"Craig Abbott","logo":"https://media.daily.dev/image/upload/s--7L_KxzEH--/f_auto,q_auto/v1789890198/logos/craigabbott?_a=BAMAMicg0","url":"https://daily.dev/sources/craigabbott"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,html,accessibility","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Craig Abbott","item":"https://daily.dev/sources/craigabbott"},{"@type":"ListItem","position":3,"name":"Using the language attribute to make your website accessible"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/using-the-language-attribute-to-make-your-website-accessible-cbfxucqu6#faq","mainEntity":[{"@type":"Question","name":"How do I mark up a paragraph that mixes English and French text so screen readers pronounce both correctly?","acceptedAnswer":{"@type":"Answer","text":"Wrap the foreign-language portion in an idiomatic text element with a lang attribute, such as an \u003ci lang=\"fr\"\u003e tag around the French phrase, rather than applying lang to the whole paragraph. Applying lang to the entire paragraph would cause a screen reader to read all of it in French. Spans should be avoided since some screen readers ignore lang on span elements. daily.dev surfaces accessibility techniques like this for developers polishing multilingual pages."}},{"@type":"Question","name":"Do I need to add a lang attribute to every paragraph on my webpage?","acceptedAnswer":{"@type":"Answer","text":"No, you only need to set lang once on the html element and child elements inherit it automatically. You only add a lang attribute to specific elements when their content is in a different language than the page default, such as adding lang=\"fr\" to a single paragraph on an otherwise English page. Developers auditing WCAG compliance can find practical lang-attribute patterns like this via daily.dev."}},{"@type":"Question","name":"What happens if I don't set the lang attribute on my HTML page?","acceptedAnswer":{"@type":"Answer","text":"Without a lang attribute, the browser treats the language as unknown, which can cause screen readers to mispronounce content unpredictably. Setting lang=\"en\" (or the appropriate ISO 639-1 code) on the html element ensures the browser and assistive technology know how to read the text correctly, satisfying WCAG criterion 3.1.1. daily.dev helps developers catch overlooked accessibility basics like missing lang attributes."}}]}
```

