HTML hellbender says:
Don’t forget the
langattribute to define the default language.
And here’s why:
- Screen readers use the
langattribute to pronounce words correctly and adjust voice settings, making content easier to understand. - Search engines like Google use the
langattribute to serve the right content to the right audience. - Browsers and translation tools rely on the
langattribute to identify the language and improve translations. - Some languages have specific hyphenation and formatting rules that work better when the correct language is set.
- Standards like WCAG recommend defining the default language for better accessibility.
Here are some tips on defining the lang attribute.
- Use simple codes like
enfor English,defor German, orfrfor French to define the main language. - Use specific codes like
en-GBfor British English oren-USfor American English to define regional differences. - If part of your content is in another language, wrap it in a tag with a different lang attribute:
<p lang="fr">Ce texte est en français.</p>