# Isolate mixed-direction names in HTML report sentences

Canonical: https://githtml.com/guides/bdi-isolate-user-names-report
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

Wrap inserted text of uncertain direction in bdi when it should not disturb the bidirectional ordering of surrounding punctuation or numbers. Keep the document's language and direction accurate separately. Isolation helps contain directionality effects; it does not validate a name, translate text, or make visually deceptive strings trustworthy.

## Understand the access barrier

A right-to-left name followed by a score can cause punctuation to appear in an unexpected position inside a left-to-right sentence. The letters themselves may be correct while their relationship with the surrounding number becomes confusing.

## Use a deliberate document pattern

Isolate the inserted name as a unit and leave the sentence's own punctuation outside it. Use actual multilingual examples when reviewing the result. Do not replace the text with an image merely to freeze one visual arrangement.

1. Identify inserted strings whose direction is not known in advance.
2. Use bdi around the string rather than forcing the entire sentence into another direction.
3. Test punctuation and adjacent numeric values with real multilingual content.

````html
<p>Reviewer <bdi>ليلى</bdi>: 3 comments.</p>
````

## Check the actual reading experience

Check names in both directions with parentheses and trailing numbers. Verify the intended relationship with a reader familiar with the language.

## Keep names separate from surrounding numbers

Consider a left-to-right report sentence that inserts a reviewer’s name followed by a colon and a comment count. A right-to-left name can affect the apparent placement of nearby neutral punctuation and digits. Isolating the inserted name lets the surrounding sentence retain its own ordering context. Keep the report’s colon and count outside the isolated name unless they are genuinely part of the inserted content.

Test more than one short Arabic or Hebrew name. Include a mixed Latin-and-Arabic name, parentheses, a hyphenated identifier, and a trailing number. These cases reveal ordering assumptions that a single all-Latin example misses. When the direction is known for a complete passage, use an appropriate direction declaration for that passage; bdi is especially useful for an inserted string whose direction is not known in advance. It does not replace the document’s language declaration or proper translation.

Direction isolation is also not input sanitization. Insert untrusted names through a text-safe mechanism rather than interpreting them as HTML, and treat visually deceptive identifiers as a separate security concern. Copy and paste the rendered sentence to inspect its logical text, then have a reader familiar with the language verify the displayed relationship. Avoid manually reordering characters or adding spaces until one screenshot looks correct; that can damage selection, searching, and other names. The success condition is that the name remains intact and the report’s punctuation and count remain attached to the intended statement across realistic multilingual inputs.

## Sources and further reading

- [MDN: bdi](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/bdi)

## Related guides

- [Keep caption tracks attached to HTML video examples](https://githtml.com/guides/caption-track-missing-html-video)
- [Check contrast of meaningful chart lines and boundaries](https://githtml.com/guides/chart-lines-nontext-contrast)
- [Make HTML checklist state and persistence explicit](https://githtml.com/guides/checkbox-checklist-state-not-saved)
- [Keep warning labels out of CSS-generated content](https://githtml.com/guides/css-generated-warning-label-accessibility)

Editorial approach: https://githtml.com/guides/about
