
HTML specifications explicitly warn that the declaration of the language used in a
document, via lang or xml:lang attribute, shall not set directionality. The overall default
in HTML is left-to-right directionality. Thus, a document in Arabic should normally
have <html dir="rtl"> as its first tag. Using the attribute lang="ar" there as well can
be useful for other purposes, but it does not set directionality.
Web browsers, especially Internet Explorer, have flaws in directionality features. For
example, text that contains only right-to-left characters and neutral characters should
be displayed correctly without any extra markup, but this does not always happen.
Using logically redundant markup with dir attributes may help.
HTML authors who create right-to-left or mixed-direction content
should use dir attributes even in contexts where they are not required
by the specifications.
For additional explanations, examples, and advice, please consult Andreas Prilop’s
“Bidirectional text” at http://www.unics.uni-hannover.de/nhtcapri/bidirectional-
text.html.
Directionality of Formatting
The dir attribute in HTML and the direction property in CSS should be used with
caution, since they do not affect the directionality of characters only. They also affect
the direction of document formatting. This is natural in many ways. If you have, say,
a bulleted list, then the bullet should apparently be placed ...