Agent Wranglers

WEB-2Required

Say the page's language

Set the page's language on the <html> element of every page, such as lang="en", using a standard language code (BCP 47).

How to do it

Set lang in the shared template from one site setting. Use the content's language. Add a region only if it matters (en, en-GB). Mark sent email the same way, as Declare the language and text direction says.

Examples

HTML example

<html lang="en">
<!-- or, when the region matters -->
<html lang="en-GB">

How to check

A build gate finds <html lang="…"> with a valid BCP 47 code on every page. Lighthouse and axe html-has-lang and html-lang-valid pass.

Measured

On a reference site, removing it dropped Lighthouse Accessibility from 100 to 96.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/html-basics/html-lang">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.