2.1.3.9.2 The dir attribute

The dir attribute provides direction about how processors should render bidirectional text. Languages such as Arabic, Hebrew, Farsi, Urdu, and Yiddish have text written from right to left. Numerics and embedded sections of Western language text, however, are written from left to right. Some multilingual documents also contain a mixture of text segments in two directions. This attribute specifies how such text should be rendered to a reader.

Bidirectional text processing is controlled by several factors:

The Unicode bidirectional algorithm positions the punctuation correctly for a given language. The rendering is responsible for displaying the text properly.

The use of the dir attribute and the Unicode algorithm is explained in the article Specifying the direction of text and tables: the dir attribute (http://www.w3.org/TR/html4/struct/dirlang.html#adef-dir) . This article contains several examples of how to use the dir attribute set to either left-to-right or right-to-left. There is no example of setting the dir attribute to either "lro" or "rlo", although it can be inferred from the example that uses the <bdo> element, a now-deprecated W3C mechanism for overriding the entire Unicode bidirectional algorithm.

Note that properly written mixed text does not need any special markers. The Unicode bidirectional algorithm is sufficient. However, some rendering systems may need directions for displaying bidirectional text, such as Arabic, properly. For example, the Apache FOP tool may not render Arabic properly unless the left-to-right and right-to-left indicators are used.

Recommended usage

The dir attribute, together with the xml:lang attribute, is essential for rendering table columns and definition lists <dl> to ensure proper order.

In general text, the Unicode Bidirectional algorithm, as specified by the xml:lang attribute together with the dir attribute, provides for various levels of bidirectionality, as follows:

For most authoring needs, the "ltr" and "rtl" values are sufficient. Only when the desired effect cannot be achieved using these values, should the override values be used.

Implementation precautions

Applications that process DITA documents, whether at the authoring, translation, publishing, or any other stage, should fully support the Unicode bidirectional algorithm to correctly implement the script and directionality for each language used in the document.

Applications should ensure every highest level topic element and the root map element explicitly assign the dir attribute, as well as the xml:lang attribute.

Previous Topic:  2.1.3.9.1 The @xml:lang attribute

Next Topic:  2.1.4 Configuration, specialization, and constraints

Parent Topic:  2.1.3.9 Translation and localization

Sibling Topics:

2.1.3.9.1 The @xml:lang attribute

Related Topics:

What you need to know about the BIDI algorithm and inline markup (http://www.w3.org/International/articles/inline-bidi-markup/)

XHTML Bi-directional Text Attribute Module (http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-bidi.html)

Specifying the direction of text and tables: the dir attribute (http://www.w3.org/TR/html4/struct/dirlang.html#adef-dir)

HTML 4.0 Common Attributes (http://www.htmlhelp.com/reference/html40/attrs.html)