Question

In HTML, the <bdo> tag is used to override the current text direction.

When i have a <div> tag, should i use <bdo> tag inside it?

<div><bdo dir="rtl">TEXT</bdo></div>

Or instead i should use a CSS class for the <div> tag:

<div class="rtl-lang">TEXT</div>

My question is: When should i use <bdo> tag? Will it be deprecated?

Was it helpful?

Solution

You should normally not use the bdo element, or its CSS counterpart, since they are meant to be used in exceptional situations, where you need to override the normal bidirectionality rules. They mean forced writing direction, which means that the inherent directionality of letters will be overridden.

For any normal text in a right-to-left language, <div dir=rtl>...</div> is adequate. In fact, in most cases, you don’t need even that, since by default, Latin, Greek, and Cyrillic letters will run left to right, Arabic and Hebrew letters will run right to left, and neutral characters will follow suit. But the dir attribute is still a useful precaution against special cases and against browser bugs.

Using dir rather than corresponding CSS is preferable since writing direction is not just a casual presentational suggestion, like fonts and colors and backgrounds, but an integral part of a writing system.

So you should use bdo only if you have a good reason to override the birectionality algorithm. If you are wondering whether you have a good reason, you don’t have. But here’s an example. If you write

The letters &#x5d0;, &#x5d1;, and &#x5d2;...

then the visual order will be wrong, since the Hebrew letters א and ב will appear in a wrong visual order (given the English-language context). The comma between them is neutral, so they run right to left. To prevent this, you would write

The letters <bdo dir=ltr>&#x5d0;, &#x5d1;,</bdo> and &#x5d2;...

There is no reason to expect bdo to become deprecated. It has its uses, though rare, and within the relevant scope, it serves its purpose. It is more logical to use HTML rather than CSS in those rare occasions, and more practical to use HTML rather than control characters that override normal directionality.

OTHER TIPS

It shows that it is included in the HTML5 spec http://www.w3.org/wiki/HTML/Elements/bdo and on the https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdo it shows that is a Candidate Recommendation for HTML5. Will it be deprecated? Most likely not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top