Skip to main content
WCAGrules
Quick navigation

Fix nested right-to-left text with the dir attribute

H56 is the heavier counterpart to H34, for the case W3C calls a nested directional run. An English paragraph quoting a Hebrew sentence that itself contains an English phrase is three levels deep, and a Unicode mark is no longer enough. Wrap the inner run in an element and declare its direction with dir=rtl or dir=ltr. W3C lists this as sufficient for 1.3.2 Meaningful Sequence in combination with the general technique of ordering content meaningfully. Two things are worth doing while you are in there. Pair dir with lang on the same element, because the inner run is usually in another language too and that is a separate rule. And keep the page's overall direction on the html element, because H56 is a phrase-level tool.

How we find it in an audit

A tool can list dir attributes and cannot judge whether the result reads correctly, so this needs a reviewer who reads the language. The check runs both ways. Every right-to-left run needs its direction declared, and every left-to-right run nested inside one needs either no dir ancestor at all or one set to ltr.

How affected users experience it

Get this wrong and the visible sentence comes apart. Parenthetical phrases render backwards, punctuation jumps to the far end of a line, and a reader of the language sees something subtly different from what was written. The correction is invisible in the source and obvious on the page, which is why it gets checked by looking rather than by searching the code.

Passes vs. fails

Passes: the right voice reads the page. Fails: no lang, so the wrong voice reads it.

Passes

<span lang="en" dir="ltr">(see figure 2)</span> inside the Hebrew sentence keeps the phrase and its brackets together.

Fails

A Hebrew sentence quoting the English phrase (see figure 2), with no direction declared on the quoted run. The brackets split to opposite ends of the line.

Other ways to satisfy this rule

12 guides on this site are filed under 1.3.2 Meaningful Sequence. W3C lists this one as sufficient for that rule only alongside G57, so the pair is what passes and neither half does on its own.

This guide is our interpretation of W3C technique H56: Using the dir attribute on an inline element to resolve problems with nested directional runs. W3C publishes its techniques as guidance rather than as the standard, and says so on every one of them. The success criterion is what conformance is measured against, and a technique is one documented way to meet it.

Go somewhere useful

Find tools, resources and your workspace.

29 destinations