HTML Tags

HTML <bdi> Tag

The <bdi> tag stands for Bi-Directional Isolation and is used to isolate a part of text that might have a different direction from the surrounding text.
Unlike <bdo> (which forces a direction), <bdi> allows the browser to automatically determine the correct direction based on the content.
It is particularly useful for user-generated content in multilingual or dynamic text environments.

Syntax

<bdi>Text with different direction</bdi>

Attributes

AttributeDescription
dirOptional. Lets you manually set direction (ltr or rtl), though it’s often detected automatically.
classAdds one or more class names for CSS styling.
idDefines a unique identifier for the element.
styleAdds inline CSS for custom styling.
titleShows extra information on hover.

Example

<!DOCTYPE html>
<html>
<head>
  <title>BDI Tag Example</title>
  <style>
    bdi {
      background-color: #f0f0f0;
      padding: 4px 6px;
      border-radius: 4px;
      color: #2c3e50;
    }
    table {
      border-collapse: collapse;
      margin-top: 10px;
    }
    td, th {
      border: 1px solid #ccc;
      padding: 8px 12px;
      text-align: left;
    }
  </style>
</head>
<body>
  <h1>HTML &lt;bdi&gt; Tag Example</h1>

  <p>The <code>&lt;bdi&gt;</code> tag helps when you have mixed-direction text, such as English and Arabic usernames.</p>

  <table>
    <tr>
      <th>Username</th>
      <th>Score</th>
    </tr>
    <tr>
      <td><bdi>John</bdi></td>
      <td>95</td>
    </tr>
    <tr>
      <td><bdi>إيمان</bdi></td> <!-- Arabic name (right-to-left) -->
      <td>89</td>
    </tr>
    <tr>
      <td><bdi>Ali_العربي</bdi></td> <!-- Mixed direction -->
      <td>92</td>
    </tr>
  </table>
</body>
</html>

Output

Browser Output

Use our TryIt Editor to see the output.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

The Arabic or mixed-direction usernames will display properly aligned without breaking the layout — the <bdi> tag isolates each name’s direction automatically.

Notes

  • The <bdi> element is useful for dynamic or user-generated content where text direction is unknown.
  • It ensures that the surrounding text layout remains consistent regardless of the inserted text’s language.
  • You can use the optional dir attribute to force a direction if needed.
  • Unlike <bdo>, <bdi> doesn’t override the direction — it isolates it.

Conclusion

The <bdi> tag provides a smart and automatic solution for displaying multilingual text correctly.
It preserves layout and readability by isolating text direction without manual overrides — ideal for user names, comments, and mixed-language content.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend