Lesson 29 of 55
HTMLInternationalization – `lang` Attribute and Text Direction
9 min
Course progress53%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 29 of 55
HTML9 min
Keep these ideas in mind as you work through the lesson.
Declare the page language to improve accessibility and SEO.
<html lang='en' dir='ltr'>
…
</html>
lang – ISO language code (en, fr, ar). Helps screen readers pronounce text correctly and informs search engines.dir – ltr (left‑to‑right) or rtl (right‑to‑left) for scripts like Arabic or Hebrew.<p>Welcome! <span lang='es'>¡Bienvenido!</span></p>
The <span> tells assistive tech that the inner text is Spanish.
margin-inline-start, padding-inline-end) instead of physical ones (margin-left).text-align: start to respect the document’s direction.dir='rtl' on the <table> if the primary language is right‑to‑left.lang and dir set on <html>? ✅lang='…') used where needed? ✅text-align: start used instead of left/right? ✅Tip: For multilingual sites, implement a language switcher that updates the
langattribute and optionally the URL (/en/,/es/).