Format Code Now
/

HTML BDO Generator

WM-26

Type your text, pick left-to-right or right-to-left, and copy a bdo element with its required dir attribute. A bdi action is there too, for text whose direction you do not know.

Runs in your browser. Nothing is uploaded.

Text to wrap (optional lines: lang:, id:, class:, title:)

HTML

How to use it

  1. Type or paste the text to wrap. Add lang:, id:, class: or title: lines if you need those attributes.
  2. Choose rtl or ltr in the Direction select.
  3. Pick the bdo element action to force the direction, or bdi to isolate the text.
  4. Copy the result into your page.

What bdo does that dir on a span cannot

The bdo element overrides the Unicode bidirectional algorithm. Without it, a browser orders each run of characters by the direction the characters themselves carry, so Latin letters stay left to right even inside a right-to-left paragraph. With bdo dir="rtl", the characters are laid out right to left no matter what they are, which reverses the visible order of the letters. The dir attribute is required on bdo, and its only valid values are ltr and rtl.

bdi is for text you did not write

The bdi element isolates its content from the text around it, so a user name or comment in unknown script cannot scramble the surrounding sentence. Its dir attribute defaults to auto, which means the browser looks at the first strong character inside it and picks the direction from that. bdi does not force anything; it protects its neighbours. The bdi action here writes the element without a dir attribute for exactly that reason.

Questions people ask

When should I use bdo?

Use it when you want to force a direction on text that the browser would otherwise order by its own rules, such as showing a string reversed for a teaching example. For ordinary Arabic or Hebrew content, set dir on the paragraph instead; the browser already orders the letters correctly.

What is the difference between bdo and bdi?

bdo overrides the direction of its content and requires dir set to ltr or rtl. bdi isolates its content and works out the direction itself, using auto by default. Use bdo to force an order and bdi to protect a sentence from user-supplied text.

Does bdo reverse my text in the HTML source?

No. The characters stay in the same order in the markup and in the copied text. Only the way the browser paints them on screen changes. That is why the output here keeps your text exactly as typed, with only less-than and ampersand characters escaped.

Can bdo use dir auto?

No. For bdo the dir attribute is required and takes ltr or rtl only. If you want the browser to decide the direction from the content, use the bdi element, or put dir="auto" on a span or other element.

Do I need a lang attribute as well?

It is a good idea. Direction and language are separate: dir controls the order the characters are drawn in, while lang tells screen readers and search engines which language the text is in. Add a lang: line to the input and it is written onto the element.

About this tool

The bdo action writes <bdo dir="..."> around your text and the direction comes from the select above. The dir attribute is required on bdo, so it is always present. The bdi action writes <bdi> instead, which isolates the text but does not force a direction: the browser works the direction out from the characters. Text is escaped, so < and & in the input show as text. Nothing is previewed here; paste the result into a page to see it. This tool does not reverse your text or fix the order of a mixed-direction sentence for you. Optional lines: id:, class:, title:, lang:, data-* and aria-*.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.