concept

bidirectional-text — CSS reference

Mixed-direction text requires the Unicode Bidirectional Algorithm, not manual reversal of strings. HTML dir sets base direction; bdi isolates an unknown-direction run. Preserve source order and isolate embedded identifiers such as usernames, phone numbers and product codes.

Formal Syntax & Structure

css syntaxcss
<p lang="fa" dir="rtl">…<bdi>ABC-42</bdi></p>

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS logical layout lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}#a{padding-inline-start:12px} #b{unicode-bidi:isolate}</style><body><p id="a" lang="fa" dir="rtl">شماره سفارش: <bdi id="b">ABC-42</bdi></p></body></html>
CSS Reference