Screen readers can use a page's declared language to choose pronunciation rules. In HTML, the lang attribute on the root <html> element sets the default language for the document.

The language on the root element applies to the page title and to body text that inherits it. A passage written in another language can carry its own lang attribute on the element that contains it.

A language tag can be as broad as en for English or as specific as en-GB for British English. A regional tag is useful when the wording or spelling follows that variety.

Steps to set the HTML language attribute:

  1. Create index.html in an empty test folder using your text editor.
  2. Enter the HTML below with lang="en" on the opening <html> tag for the page's English text.
    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Library</title>
    </head>
    <body>
      <h1>Library hours</h1>
      <p>Open at nine.</p>
    </body>
    </html>

    On an existing HTML page, the change belongs on the opening <html> tag. If it already has lang, replace its value in place. The W3C guidance on language tags explains which BCP 47 tag to use for your text.

  3. Save index.html.
  4. Open the saved index.html from your test folder in desktop Chrome.

    Chrome's file picker opens with Ctrl+O on Windows or Linux and Command+O on macOS.

  5. Open the Elements panel in Chrome DevTools with Ctrl+Shift+C on Windows or Linux.

    On macOS the shortcut is Command+Option+C.

  6. Confirm that the top-level <html> element in Elements shows the language tag you saved.

    The Library hours page shows <html lang="en">. If the attribute is missing or has the wrong value, correct the opening tag in the file and reopen the saved page.

Share this guide