bdi elementdir global attribute has special semantics on this element.HTMLElement.The bdi element represents a span of
text that is to be isolated from its surroundings for the purposes
of bidirectional text formatting. [BIDI]
The dir global
attribute defaults to auto on
this element (it never inherits from the parent element like with
other elements).
For the purposes of applying the bidirectional algorithm to the
contents of a bdi element, user agents must treat the
element as a paragraph-level container.
For the purposes of applying the bidirectional algorithm to the
paragraph-level container that a bdi element finds
itself within, the bdi element must be treated like a
U+FFFC OBJECT REPLACEMENT CHARACTER (in the same manner that an
image or other inline object is handled).
The requirements on handling the bdi element for the
bidirectional algorithm may be implemented indirectly through the
style layer. For example, an HTML+CSS user agent could implement
these requirements by implementing the CSS 'unicode-bidi' property.
[CSS]
This element is especially useful when embedding user-generated content with an unknown directionality.
In this example, usernames are shown along with the number of
posts that the user has submitted. If the bdi element
were not used, the username of the Arabic user would end up
confusing the text (the bidirectional algorithm would put the colon
and the number "3" next to the word "User" rather than next to the
word "posts").
<ul> <li>User <bdi>jcranmer</bdi>: 12 posts. <li>User <bdi>hober</bdi>: 5 posts. <li>User <bdi>إيان</bdi>: 3 posts. </ul>