Why should a web page declare its language?

The lang attribute on the html tag tells browsers, screen readers and search engines what language the page is written in. Screen readers use it to choose the right voice and pronunciation. Search engines use it to show the page to people searching in that language. For a British site the value is "en-GB", and most platforms set it from the site's language setting.

Why it matters

A screen reader given no language will use its default, so a British visitor with a French default voice hears English words pronounced as French. Browsers use it to offer translation, to choose quotation marks and hyphenation, and to pick fonts for some scripts. Search engines use it alongside other signals to serve the page to the right audience. It is also a requirement of the accessibility standards that public bodies and many businesses must meet.

en or en-GB?

Both are valid. "en-GB" is more precise and lets screen readers use a British voice and spell-checkers use British spelling. Use it unless you write in American English.

How to check

Our check reads the lang attribute on the html element of your home page. View the page source; the very first tag should read something like <html lang="en-GB">.

How to fix it

On WordPress, set the site language to "English (UK)" under Settings, General, and the theme's header.php outputs it through the language_attributes() function. If the attribute is missing, the theme has hard-coded its html tag and needs a one-line change. On other platforms it is usually a site language setting. If a page contains a passage in another language, mark that passage with its own lang attribute so it is read correctly too.

Not sure how your own site does on this? Run the free check: it takes about twenty seconds and reports on this and thirty other things.

Check my website

More guides