Lab 13: Internationalization

Time: 30 minutes | Level: Advanced | Docker: docker run -it --rm node:20-alpine sh

Overview

Build globally-ready HTML/CSS: dir attribute for RTL/LTR, vertical writing modes, CSS logical properties, :lang() pseudo-class, international font stacks, Intl.DateTimeFormat, and unicode-bidi.


Step 1: Direction — dir Attribute

<!-- HTML-level direction -->
<html lang="en" dir="ltr">  <!-- Latin languages: left to right -->
<html lang="ar" dir="rtl">  <!-- Arabic: right to left -->
<html lang="he" dir="rtl">  <!-- Hebrew: right to left -->

<!-- Per-element direction -->
<p dir="auto">
  <!-- auto: browser detects based on first strong directional character -->
  This could be any language
</p>

<!-- Bidirectional content: RTL within LTR page -->
<p>
  User wrote:
  <bdi>مرحبا بالعالم</bdi>  <!-- isolated bidirectional content -->
</p>

<!-- Override direction -->
<span dir="ltr">[email protected]</span>  <!-- keep email LTR in RTL context -->
<span dir="rtl">⬅ Back</span>

<!-- Form inputs in RTL document -->
<input type="text" dir="auto" lang="ar">
<input type="email" dir="ltr">  <!-- emails always LTR -->

Step 2: CSS Logical Properties — Full Reference


Step 3: RTL Layout Example


Step 4: Vertical Writing Modes


Step 5: :lang() Pseudo-Class


Step 6: International Font Stacks


Step 7: Intl.DateTimeFormat & unicode-bidi


Step 8: Capstone — RTL/LTR Logical Property Converter

(Create the file:)

📸 Verified Output:


Summary

Feature
Implementation
Languages

dir="rtl"

HTML attribute

Arabic, Hebrew, Farsi

dir="auto"

Auto-detect

Mixed content

margin-inline-start

Logical property

All

padding-block

Block-axis padding

All

writing-mode: vertical-rl

Vertical text

CJK

text-orientation: upright

Character orientation

CJK

:lang(ar)

Language-specific CSS

Any

Intl.DateTimeFormat

Locale-aware dates

All

unicode-bidi: isolate

Bidi isolation (<bdi>)

Mixed RTL/LTR

quotes property

Language-appropriate

FR, DE, JA...

Last updated