Languages and Scripts
How the lang attribute selects typography for each script, quotation marks for each language and the display of ruby annotations.
The lang attribute
Set lang on <html> for the page and on any element whose content is in another language. The rules below are written with :lang(), which matches the element and everything inside it, so one attribute on a section is enough.
Typography by script
Scripts differ in more than their letters. Chinese, Japanese and Korean text has no spaces to break lines at. Arabic and Thai have marks above and below the line that collide at a Latin line height. For each script the library sets a typeface stack, a line height and line-breaking rules.
<html lang="ja"> </html> <section lang="ar" dir="rtl"> </section>
Supported scripts
| Script | Languages | Token | Line height |
| CJK | zh, ja, ko | --font-cjk | 1.8 |
| Arabic | ar, fa, ur, ps | --font-arabic | 1.9 |
| Hebrew | he, yi | --font-hebrew | 1.75 |
| Thai | th | --font-thai | 2.0 |
| Devanagari | hi, mr, sa, ne | --font-devanagari | 1.75 |
Typeface tokens
Each script has a token that holds its typeface stack. The defaults name fonts that ship with the common operating systems. Override a token to use a font you serve.
:root { --font-cjk: "Noto Sans CJK SC", "PingFang SC", system-ui, sans-serif; --font-arabic: "Noto Sans Arabic", "Segoe UI", system-ui, sans-serif; --font-hebrew: "Noto Sans Hebrew", "Segoe UI", system-ui, sans-serif; --font-thai: "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif; --font-devanagari: "Noto Sans Devanagari", system-ui, sans-serif;}
The Typography guide covers the type system for Latin text. Typefaces lists the fonts served with the library.
Quotation marks
The <q> element draws the quotation marks of the language it is in. Write <q> and leave the marks out of your text. The same sentence is then correct in every translation.
<p lang="en">She said <q>hello</q>.</p><p lang="de">Sie sagte <q>hallo</q>.</p><p lang="fr">Elle a dit <q>bonjour</q>.</p><p lang="ja">彼女は<q>こんにちは</q>と言いました。</p>
| Language | Outer | Inner |
| English (US) | “...” | ‘...’ |
| English (GB, AU, NZ) | ‘...’ | “...” |
| German | „...“ | ‚...‘ |
| Swiss German (de-CH) | «...» | ‹...› |
| French | « ... » | ‹ ... › |
| Italian / Spanish / Portuguese (pt-PT) | «...» | “...” |
| Portuguese (pt, pt-BR) | “...” | ‘...’ |
| Polish | „...” | «...» |
| Japanese / Chinese Traditional (zh-Hant, TW, HK, MO) | 「...」 | 『...』 |
| Chinese Simplified (zh, zh-Hans) | “...” | ‘...’ |
| Korean | “...” | ‘...’ |
| Russian | «...» | „...“ |
| Arabic | «...» | ‘...’ |
| Any other language | Browser default (quotes: auto) |
Ruby annotations
<ruby> places a small reading aid above or beside a character, as furigana does in Japanese and pinyin in Chinese.
Annotations are visible by default. Put data-ruby on <html>, any ancestor, or the <ruby> itself to change that for its subtree; the nearest data-ruby wins:
| Value | Behavior |
| (absent) | Visible (browser default) |
show | Visible; undoes an outer hide or auto |
hide | Visually hidden, still in the accessibility tree |
auto | Visible when the annotation's own language is CJK (ja, zh, ko, yue, wuu), visually hidden otherwise |
<html lang="ja" data-ruby="auto"><body> <ruby>漢<rt>かん</rt></ruby><ruby>字<rt>じ</rt></ruby> <section lang="en"> <ruby>ruby<rt>annotation</rt></ruby> </section></body></html>