Skip to content
Astera Technology

Mark a language change inside one paragraph

Use lang on a short phrase so it can differ from the surrounding paragraph language.

The quoted phrase carries a language distinct from its containing sentence.

Download complete case notes and answer keys ↓

Inspect the working example

The English paragraph quotes a Hong Kong Chinese button label. The Chinese fixture independently describes an English button label. Each phrase has its own language metadata, while the surrounding sentence keeps its original language.

Inputs and native observations
CaseInput or inspectionResult and meaning
Paragraph languageInspect the p lang attributeen in this English fixture
Phrase languageInspect phrase langzh-Hant-HK for 儲存草稿
CSS language matchingTest :lang on paragraph and phraseThe explicit phrase language overrides the inherited language
Download editable CSV ↓

Follow the browser mechanism

lang declares content language and inherits when a descendant has no explicit language. An explicit value on span identifies the switch. It does not translate content, set a universal voice, or change Chinese into right-to-left text. Any claim about spoken pronunciation still needs testing with the actual reading technology.

An unmarked phrase inherits the surrounding language

The phrase below contains different-language text but has no lang of its own. Its content is still classified by the surrounding paragraph language.

Counterexample source; inspect separately
<p lang="en">The button reads <span id="phrase">儲存草稿</span>.</p>

The English counterexample phrase matches :lang(en), not :lang(zh-Hant-HK). The Chinese counterexample phrase matches :lang(zh-Hant-HK), not :lang(en).

Try the repair

You add another English sentence after the marked Chinese phrase. Must the whole paragraph become zh-Hant-HK?

Show the worked answer

No. Keep the paragraph en and mark only the Chinese phrase zh-Hant-HK in the English fixture. In the Chinese fixture, keep the paragraph zh-Hant-HK and only the English phrase en.

  • Inspect explicit lang attributes and inherited :lang matches separately.
  • Keep original wording for each language rather than using language metadata as a translation instruction.

Original example files

Related resources