Content · Web Development · HTML

HTML Language Changes with the lang Attribute

Language Changes with the lang Attribute: Try moving through the elements with a keyboard. The labels and relationships matter even when no extra styling has been added. Includes a practical HTML example and an explanation.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Good accessibility usually starts with clear words and the right HTML elements, not a large amount of extra code.

What You Need to Know


The lang attribute tells tools how to pronounce text and which language rules may apply. Set the page language on html, and mark shorter passages separately when they switch to another language.

In this example: mark a foreign quotation within an English paragraph.

Try the Example


Take a look at the example. We’ll explain the important lines right below it.

<p lang="en">Welcome to the class.</p>
<p lang="fr">Bonjour à tous.</p>
<p>The lang attribute helps reading tools choose the right language rules.</p>

Let’s Read the Code


  • lang: Lang identifies the language used in a document or passage.
  • Read from the outside inward: the outer element describes the job, while the nested elements supply the information.

Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.

What Happens in the Browser?


Try this with Tab and Shift+Tab. If you can, inspect the accessibility tree too; appearance alone does not tell the whole story.

Try a different way of reading. Read only the headings and labels, or navigate through links without looking at the rest of the page. If the page still makes sense, the underlying HTML is probably doing an important part of its job.

Your Turn


Use Tab and Shift+Tab to visit the controls, then read their labels aloud. Is the purpose of each one clear?

Common Beginner Mistakes


  • Judging the page only by how it looks, without checking its meaning and keyboard behavior.
  • Check the same result using both the browser and a keyboard, not only by looking at the screen.

Key Takeaways


  • The lang attribute tells tools how to pronounce text and which language rules may apply.
  • lang: Lang identifies the language used in a document or passage.
  • Test the behavior you expect rather than trusting how the snippet looks in your editor.
Share this resourceSend this page to someone who may find it useful.