Fix guides · Accessibility
How to set your page's language (the lang attribute)
Without a language on the page, screen readers may read your text with the wrong accent and pronunciation. How to set it on Shopify, WordPress, Webflow, Wix, Squarespace and Next.js.
- Time to fix
- 5 minutes
- Skill needed
- No code
- Who notices
- Screen reader users, translation tools and search engines
Why it matters
The lang attribute on the <html> element tells browsers and assistive technology which language the page is in. Screen readers use it to pick the right voice and pronunciation; browsers use it for translation and hyphenation.
Missing, misspelled (en_US instead of en-US) or made-up codes all fail. So do parts of the page in another language that are marked with an invalid code.
“It’s promising to note that in 2022, 83% of mobile websites included a lang attribute, and two years later it is at 86%.”
Before you start
- Use a valid language code: en, en-US, fr, fr-CA, hi, de and so on, with a hyphen, not an underscore.
- If a passage is in another language, mark just that element: <p lang="fr">…</p>.
Fix it on your platform
Shopify
- Your store's language comes from Settings → Languages. Themes output it on the <html> element, as Shopify's theme accessibility guidance requires.
- If it's missing, open layout/theme.liquid in Edit code and set the attribute on the <html> tag as below.
<html lang="{{ request.locale.iso_code }}">WordPress
- Go to Settings → General and choose your Site Language. WordPress turns it into the lang attribute.
- If the attribute is still missing, your theme's header doesn't call language_attributes(). Ask the theme developer, or use a child theme.
<html <?php language_attributes(); ?>>Webflow
- Webflow sets the page language from your primary locale: open the Localize panel → Locales, choose the language (and optionally a country) and save.
- The legacy language code field in Site settings → General → Localization is overridden by the locale settings.
Wix
- In your dashboard, go to Settings → Language & Region and set the Site language. You can also set it from the Accessibility Wizard.
Squarespace
- Set your site's language in the language and region settings (the Site Languages panel on version 7.1, or Language & region on 7.0).
Next.js
- Set lang on the <html> element in your root layout. For multilingual sites, set it from the locale segment.
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}Any other site
- Add lang to the opening <html> tag of every page.
<html lang="en">Check that it's fixed
- View your page source: the <html> tag should have lang with your language code.
- Re-run your StudioLNC audit: the issue should be gone.
Find every issue like this on your site
Free audit of performance, accessibility, SEO and security, with fixes for your platform.