Skip to content

<bdi> - The Bidirectional Isolate Element

Inline HTML5

The bidirectional isolate element isolates a span of text that might be formatted in a different direction from the surrounding text, preventing bidirectional text algorithm interference.

Result
<bdi>potentially bidirectional text</bdi>

The <bdi> element tells the browser to treat this text as isolated from its surroundings when determining text direction.

When mixing left-to-right (LTR) and right-to-left (RTL) text, the browser’s bidirectional algorithm can produce unexpected results:

<!-- Can produce incorrect rendering -->
<p>Winner: محمد: 100 points</p>

The colon and “100 points” might appear in the wrong position.

When displaying usernames that could be in any language:

Result
Result
Result
Result
Result

Use <bdi> when:

  • Displaying user-generated content (usernames, comments)
  • The text direction is unknown at development time
  • Mixing content from multiple languages
  • Building internationalized applications
<!-- Isolates text, browser determines direction -->
<p>User: <bdi>أحمد</bdi> posted a comment</p>

Use when direction is unknown.

Screen readers respect the text direction indicated by <bdi>, ensuring content is read in the correct order.

Combine with lang attribute for better accessibility:

<p>User: <bdi lang="ar">محمد</bdi> has logged in</p>
<p>User: <bdi lang="zh">李明</bdi> has logged in</p>
BrowserVersionNotes
Chrome16+Full support
Firefox10+Full support
Safari6+Full support
Edge79+Full support
IE11Partial support

All modern browsers support <bdi>. For older browsers, the text will still display but without bidirectional isolation.

dir attribute

Global attribute to specify text direction. Learn more →