search

Home  >  Q&A  >  body text

What is the purpose of the <bdo> element?

First, I understand the difference between the attribute dir of the bdo element and any other element. If we have the following text:

Hello world!

<bdo dir="rtl">Hello world!</bdo> The mirrored version of the text that will be displayed is:

!dlrow ,olleH

and <p dir="rtl">Hello world!</bdo> will display Arabic text as usual:

!Hello, world

Why does the bdo element exist? I checked MDN's use cases but didn't find any. This example shows that this seems useless to me in any real world application. Are there mirror texts that are treated as normal RTL languages? Or is there another use case for this element?

UPD: I even found a tweet from a W3C member:

Recommended BDO is always wrong.

P粉165823783P粉165823783244 days ago592

reply all(1)I'll reply

  • P粉638343995

    P粉6383439952024-03-23 10:44:33

    This is useful when the text is in a language written from right to left (RTL), such as Arabic, Hebrew, or Farsi, and needs to be displayed correctly on the web page.

    For example, let's say you have a web page that contains some English text followed by Arabic quotes. Without using the bdo element, Arabic quotes will appear in the same orientation as the English text, which is incorrect. By using the bdo element with the "rtl" attribute, you can ensure that Arabic text displays correctly from right to left.

    reply
    0
  • Cancelreply