dir="auto" uses first strongIt is a valuable browser-native baseline. An English product name at the start of an otherwise RTL sentence can still select LTR.

Choose policy by available authority.

Direction is knownUse authored metadata

User locale, field schema, or explicit message direction should outrank inference.

Arbitrary model textUse a versioned heuristic

Publish first-strong, word/character dominance, neutral fallback, and tie rules.

One document can contain both directions.

rootinherited base
→
blockoverride if needed
→
inlinebdi / isolate
→
codestable layout

Do not apply one global flip.

Markdown

Paragraphs, headings, lists, quotes, and tables need structural ownership.

Technical literals

Code, terminal, diff, JSON, hashes, paths, and URLs require stable isolation.

Composer

Textarea, backdrop, mirror, wrap, height, selection, and IME share one direction state.

Presentation must not rewrite content.

Keep bidi controls out of durable Session strings.

Use semantic HTML markup. Invisible controls alter copy/paste, search, diffs, model replay, and security review.

Sixteen release gates.

Primary evidence.

Make every direction decision observable.

The complete guide covers message and block policy, inline isolation, code safety, composer geometry, security, cross-browser fixtures, and all sixteen gates.

Read the complete RTL contract