dir attribute
Description
The dir attribute
tells the browser the direction in which the displayed text is intended
to be read. The browser will render text from left to right by default,
but as with the lang attribute,
you’ll need to override the intended reading direction if you’re
including text that runs in the opposite direction (for example, Arabic
or Hebrew).
If the bulk of your document is written in
English, but it features excerpts in Hebrew, the default rendering will
be left to right. However, the Hebrew phrases will need to be marked up
as reading right to left, or "rtl" . If the page were
written primarily in Hebrew, then the reverse is true—the direction
should be set on the body or html element
as "rtl" , with discrete phrases
in English marked up using "ltr" .
Using the dir attribute
doesn’t actually reverse the order of the text contained within the
element to which the attribute is applied (for that, you’d need to use
the bidirectional override element, or bdo ); it does, however, swap the alignment of
text contained in block-level elements so that each new line of text
starts at the right of the screen, leaving a ragged left-hand edge.
Note
that the dir attribute
is also used to define the reading order of text or data contained in
tables.
|