🔤Bidirectional Text (Bidi)
Also known as Bidi Text, Mixed-Direction Text, Unicode Bidirectional Algorithm
One line of text that runs two ways, right to left and left to right.
Think of it like
It is like two cars on one street going opposite ways. Clear lanes keep them from crashing.
Example
In a chat app, someone types an English brand name inside an Arabic sentence. The rules keep the brand name reading left to right. The rest of the line still reads right to left.
Why it matters
Mixed lines are everywhere in these languages. When the rules fail, words and brackets jump to the wrong place.
Definition
Example code
html
<p dir="auto"><bdi>user_name</bdi> left a review</p>Common mistake
Key takeaways
- 1Two directions. In one line.
- 2Unicode decides. A shared set of rules.
- 3Isolate inserts. Names and user text.