HTML reference
lang
The lang attribute declares the human language of an HTML document or a particular element. It helps speech synthesis, translation tools, search, and text rules.
What you will learn
- How to declare a document and a fragment's language
- How language affects speech, translation, and search
- How to choose values such as
jaanden-US
Basic usage
<html lang="en">
<p>This page is in English.</p>
<p lang="ja">この文だけ日本語です。</p>
</html>Set lang on the root element to describe the page's main language. Override it on a smaller element when a passage switches language.
Language tags
Use standardized BCP 47 language tags. ja identifies Japanese, en English, and en-US English as used in the United States. Add a region only when it matters to the content.
Why it matters
- Screen readers can choose an appropriate pronunciation.
- Browsers and services can offer more accurate translation behavior.
- Search and text styling tools receive a useful language signal.
lang describes language; it does not translate text or change the user's locale by itself.