HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tags

HTML Tags

HTML <!DOCTYPE> TagHTML <html> TagHTML <head> TagHTML <title> TagHTML <body> TagHTML <base> TagHTML <link> TagHTML <meta> TagHTML <style> TagHTML <script> TagHTML <h1 to h6> TagHTML <hgroup> TagHTML <p> TagHTML <br> TagHTML <wbr> TagHTML <hr> TagHTML <pre> TagHTML <b> TagHTML <strong> TagHTML <i> TagHTML <em> TagHTML <mark> TagHTML <small> TagHTML <del> TagHTML <ins> TagHTML <sub> TagHTML <sup> TagHTML <u> TagHTML <blockquote> TagHTML <q> TagHTML <cite> TagHTML <abbr> TagHTML <address> TagHTML <bdo> TagHTML <bdi> TagHTML <a> TagHTML <nav> TagHTML <ul> TagsHTML <menu> TagHTML <ol> TagHTML <dl> TagHTML <img> TagHTML <figure> TagHTML <figcaption> TagHTML <audio> TagHTML <video> TagHTML <source> TagHTML <track> TagHTML <embed> TagHTML <object> TagHTML <param> Tag (Obsolete)HTML <picture> TagHTML <canvas> TagHTML <map> TagHTML <area> TagHTML <table> TagHTML <caption> TagHTML <thead> TagHTML <tbody> TagHTML <tfoot> TagHTML <tr> TagHTML <th> TagHTML <td> TagHTML <col> TagHTML <colgroup> TagHTML <form> TagHTML <input> TagHTML <textarea> TagHTML <button> TagHTML <select> TagHTML <selectedcontent> TagHTML <option> TagHTML <optgroup> TagHTML <label> TagHTML <fieldset> TagHTML <legend> TagHTML <datalist> TagHTML <output> TagHTML <meter> TagHTML <progress> TagHTML <header> TagHTML <footer> TagHTML <article> TagHTML <section> TagHTML <aside> TagHTML <main> TagHTML <search> TagHTML <details> TagHTML <summary> TagHTML <dialog> TagHTML <time> TagHTML <noscript> TagHTML <slot> TagsHTML <template> TagHTML <shadow> Tag (Obsolete)HTML <center> TagHTML <font> TagHTML <big> TagHTML <strike> TagHTML <tt> TagHTML <acronym> TagHTML <applet> TagHTML <frame> TagHTML <frameset> TagHTML <noframes> TagHTML <marquee> TagHTML <blink> TagHTML <s> TagHTML <var> TagHTML <kbd> TagHTML <samp> TagHTML <code> TagHTML <dfn> TagHTML <div> TagHTML <span> TagHTML Comment TagHTML <data> TagHTML Ruby Annotations: <ruby>, <rt> and <rp>HTML <svg> TagHTML <basefont> Tag
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML <bdi> Tag

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

html

<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

html

<!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 <bdi> Tag Example</h1>

  <p>The <code><bdi></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>

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

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.

PreviousHTML <bdo> TagNextHTML <a> Tag