This document is a draft, and is designed to show changes from a previous version. It is presently showing added text,changed text,deleted text,[start]/[end] markers,and Issue Numbers.
Changes are displayed as follows:
HTML 4, XHTML 1.0 and XHTML 1.1
This technique relates to:
The objective of this technique is to use Unicode right-to-left marks and left-to-right marks to override the HTML bidirectional algorithm when it produces undesirable results. This may be necessary, for instance, when placing neutral characters such as spaces or punctuation between different directional text runs. The concepts used in this technique are described in What you need to know about the bidi algorithm and inline markup.
[begin add]Unicode right-to-left marks and left-to-right marks can be entered directly or by means of entities. [1965] [end add]The character entities for these markers are
left-to-right mark: ‎ or ‎ (U+202A)
right-to-left mark: ‏ or ‏ (U+202B)
Due to the bidi algorithm, a source code editor may not display character entities as expected.
[end add]This example shows an Arabic phrase in the middle of an English sentence. The exclamation point is part of the Arabic phrase and should appear on its left. Because it is between an Arabic and Latin character and the overall paragraph direction is LTR, the bidirectional algorithm would position it to the right of the Arabic phrase. [begin change]Inserting a Unicode right-to-left mark (in this case via the HTML character entity ‏) after the exclamation mark positions it correctly.[end change]
<p>The title is "مفتاح معايير الويب!‏" in Arabic.</p>
The following is a working example of the code above:
The title is "مفتاح معايير الويب!" in Arabic.
Visual ASCII version:
[end add]Resources are for information purposes only, no endorsement implied.
Examine the source for places where text changes direction.
When text changes direction, check whether neutral characters such as spaces or punctuation occur adjacent to text that is rendered in the non-default direction.
When #2 is true and the HTML bidirectional algorithm would produce the wrong placement of the neutral characters, check whether the neutral characters are followed by Unicode right-to-left or left-to-right marks that cause neutral characters to be placed as part of the preceding characters.
Check #3 is true.