bdo
The <bdo>
(Bi-Directional Override) tag is an HTML tag that allows you to force the writing direction of the text it contains, regardless of the predefined direction of the document or the parent element.
It is often used to manage specific situations in multilingual content.
Structure and syntax of the <bdo>
tag
Basic structure and syntax
The <bdo>
tag is a container tag that has:
- An opening tag:
<bdo>
; - A closing tag:
</bdo>
.
It is often combined with the dir
attribute to define the writing direction, which can be:
ltr
: Left to right ;rtl
: Right to left.
Usage example
Here is a practical example:
<p>Text displayed normally: Hello</p>
<p>Text forced right-to-left: <bdo dir="rtl">Hello</bdo></p>
In this example, the word "Hello" will be displayed from right to left in the second paragraph, independently of the overall directionality of the page.
Attributes
The <bdo>
tag accepts classic HTML attributes, such as title
, class
, or even id
.
It also uses the dir
attribute, which is mandatory to specify the writing direction. This attribute can take the following values:
ltr
(default): Left to right direction.rtl
: Right to left direction.
Difference with other similar tags
<span>
: Allows styling text without forcing its directionality.<bdi>
: Isolates a portion of text to manage directionality automatically, without forcing it.
Browser compatibility
The <bdo>
tag is supported by all modern browsers.
Browser | Compatibility |
---|---|
Chrome | Yes |
Firefox | Yes |
Safari | Yes |
Edge | Yes |
Internet Explorer | Yes |