Language References
Allows authors to disable the bidirectional algorithm for selected fragments of text. | HTML 4, 4.01, 5 |
HTML Syntax
<bdo
dir = ltr | rtl
id = value
title = text
event=script
>
The BDO element can be used when control is required over the reading order of a block of text.
The Unicode bidirectional algorithm automatically reverses embedded character sequences according to their inherent direction.
For example, the base direction of an English document is left-to-right ( ltr ). If portions of a paragraph within this document contain a language with an opposing reading order, implementations of that language would be reversed correctly by the user agently applying the bidirectional algorithm.
The bidirectional algorithm and the dir attribute generally suffice for embedded direction changes. However, incorrect presentations can result when formatted text is exposed to the birectional algorithm.
For example, a paragraph containing English and Hebrew that has been formatted for email may be incorrectly inverted by the bidirection algorithm. Because the reading order of the Hebrew text was inverted once for the email, exposing it to the bidirectional algorithm would invert the words a second time.
The <bdo
> element can be used to turn off the algorithm and control the reading order.
The dir attribute is mandatory when using the <bdo
> element.
NOTE: Both start and end tags are required.
The <bdo
> element supports the following attributes, in addition to global attributes common to all HTML elements.
Attribute | Value | Description |
dir | ltr, rtl | Required. Specifies the text direction of the text inside the element |
Consider a block of text containing the following string: This fragment is in english, WERBEH NI SI TNEMGARF SIHT.
Assuming this block of text was already put in the correct reading order by inverting the Hebrew passage, interaction with the Unicode bidirectional algorithm would invert WERBEH NI SI TNEMGARF SIHT a second time.
The Hebrew words would be displayed left-to-right instead of right-to-left.
The solution is to override the bidirectional algorithm and put the block of text in the correct reading order inside a <bdo
> element, whose dir attribute is set to ltr.
<bdo dir="ltr">This fragment is in english, WERBEH NI SI TNEMGARF SIHT.</bdo>
BDI direction