Skip to content
BENIBIX Learn

Bidirectional Text (Bidi)

Design🔤 TypographyWriting Systems

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

Bidirectional text is a line that mixes right-to-left words with left-to-right ones. A Persian sentence with an English name or a number in it is a common case. The screen must show each part in its own direction. It must also keep the parts in the right order. A shared set of Unicode rules decides that order. On web pages, the bdi tag and dir="auto" help when the direction is not known.

Example code

html
<p dir="auto"><bdi>user_name</bdi> left a review</p>
The bdi tag keeps a name in its own direction. Then it cannot mix up the words around it.
One right-to-left line holds an English word that still reads left to right.

Common mistake

Testing only with Arabic or only with English. Bugs show up in lines that mix both.

Key takeaways

  1. 1
    Two directions. In one line.
  2. 2
    Unicode decides. A shared set of rules.
  3. 3
    Isolate inserts. Names and user text.

Learn it properly