Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

HTML element: bdi

The bidirectional-isolation element separates an unknown fragment’s direction from surrounding text so characters on either side do not reorder one another.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

User <bdi>unknown-direction name</bdi>

bdi is especially appropriate for user names and other user-supplied data of unknown direction; an explicit dir can be supplied when direction is known.

A missing dir on bdi behaves as auto: the browser determines direction from the first strong character instead of inheriting it from the parent.

bdi creates an isolation boundary, whereas bdo forces character ordering; isolation does not translate, sanitize, or reverse source text.

The example uses getComputedStyle() on an Arabic name and observes direction and unicodeBidi together with the adjacent suffix.

Examples

<!doctype html>
<meta charset="utf-8">
<p id="message" dir="ltr">User <bdi id="name">إياد</bdi>: 3 files</p>
<output id="result"></output>
<script>
const name = document.querySelector("#name");
const style = getComputedStyle(name);
document.querySelector("#result").textContent = `attr=${name.hasAttribute("dir") ? name.dir : "absent"}; direction=${style.direction}; bidi=${style.unicodeBidi}; tail=${name.nextSibling.textContent.trim()}`;
</script>

Result

attr=absent; direction=rtl; bidi=isolate; tail=: 3 files

The result verifies automatic RTL direction and isolation in Chromium; it does not simulate a complete paragraph layout or assistive technology.

Sources