--- url: "https://www.w3.org/WAI/WCAG22/Techniques/html/H56" titulek: "H56: Using the dir attribute on an inline element to resolve problems with nested directional runs | WAI | W3C" h1: "Technique H56:Using the dir attribute on an inline element to resolve problems with nested directional runs" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 04:43:32" znaku: 3309 slov: 474 kodovani: "utf-8" sha256: "cc12b4b80320e0f68ce145cb36601fe1c74d358da5d433ec94742a09773136ad" --- # Technique H56:Using the `dir` attribute on an inline element to resolve problems with nested directional runs ## About this Technique This technique relates to [1.3.2 Meaningful Sequence](https://www.w3.org/WAI/WCAG22/Understanding/meaningful-sequence) (**Sufficient** when used with [G57: Ordering the content in a meaningful sequence](../general/G57)). This technique applies to HTML. Techniques are examples of ways to meet Web Content Accessibility Guidelines (WCAG). They are **not required** to meet WCAG. Content can satisfy the normative requirements of WCAG even if it does not use any of the documented techniques. See [About WCAG Techniques](https://www.w3.org/WAI/WCAG22/Techniques/about). ## Description The objective of this technique is to identify changes in the text direction of text that includes nested directional runs by providing the `dir` attribute on inline elements. A nested directional run is a run of text that includes mixed directional text, for example, a paragraph in English containing a quoted Hebrew sentence which in turn includes an English phrase. Use of the `dir` attribute on an enclosing `span` or other inline element may be necessary because the [Unicode bidirectional algorithm](https://www.w3.org/International/articles/inline-bidi-markup/) can produce undesirable results when mixed directional text contains spaces or punctuation. The concepts used in this technique are described in [What you need to know about the bidi algorithm and inline markup](https://www.w3.org/International/articles/inline-bidi-markup/). ## Examples ### Example 1: Defining the text direction of a nested, mixed-direction phrase, in Hebrew and English, to be right-to-left Because the whole quote is in Hebrew, and therefore runs right to left, the text "W3C" and the comma should appear to the left of (i.e., after) the Hebrew text, like this: The title is "פעילות הבינאום, W3C" in Hebrew. Visually-ordered ASCII version (RTL text in uppercase, LTR in lower): the title is "w3c ,YTIVITCA NOITAZILANOITANRETNI" in Hebrew. The Unicode bidirectional algorithm alone is insufficient to achieve the right result, and leaves the text "W3C" on the right side of the quote: The title is "פעילות הבינאום, W3C" in Hebrew. Visually-ordered ASCII version: the title is "YTIVITCA NOITAZILANOITANRETNI, w3c" in hebrew. The following markup will produce the expected result: ```
The title says "פעילות הבינאום, W3C" in Hebrew.
``` ## Related Resources *No endorsement implied.* - [HTML - the `dir` attribute](https://html.spec.whatwg.org/multipage/dom.html#attr-dir) . - [HTML - bidirectional text](https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering) . - [Creating HTML Pages in Arabic, Hebrew and Other Right-to-left Scripts (tutorial)](https://www.w3.org/International/tutorials/bidi-xhtml/) . ## Tests ### Procedure 1. Examine the text direction of text in the document 2. If the text direction is right-to-left, check that for the ancestor element that has a `dir` attribute, the attribute has the value `"rtl"` 3. If the text direction is left-to-right, check that there is no ancestor element with a `dir` attribute, or that for the ancestor element that has a `dir` attribute, the attribute has the value `"ltr"` ### Expected Results - Checks #2 and #3 are true for all text. Back to Top