The HTML bdi tag marks text that has an unknown or mixed direction. It makes sure that this part does not break the normal flow of the page.
Table of Content
What is the <bdi> Tag in HTML?
The <bdi> tag means bidirectional isolation. It tells the browser to treat that text part apart from the page around it.
Here is the tag:
<bdi>Text here</bdi>
You place the text inside the tag, and the browser will keep it in the right direction without change to nearby content.
You can use the bdi tag when you need to show names, codes, or words that may come from another language. This helps avoid text order mix-up.
The bdi tag does not use special attributes. It follows normal HTML rules and supports global attributes like class, id, or style.
The bdi tag works in most browsers, such as Chrome, Edge, Firefox, Opera, and Safari. Old versions of Internet Explorer do not support it.
The Difference Between <bdi> and <bdo> Tags
The bdi tag lets the browser decide the text direction in an isolated way. The <bdo> tag forces text into a set direction that you choose.
Here are the key differences:
Tag | Action | Control | Use Case |
---|---|---|---|
<bdi> | Isolate text and keep natural direction | The author sets it | Mixed language text |
<bdo> | Force text to go left or right | Author sets it | Reverse or override direction |
You use bdi when you show user names or content you do not control. You use <bdo> when you must override normal direction and force a strict layout.
Examples of <bdo> Tag in HTML
Isolate Username in Mixed Text:
User: <bdi>مرحبا</bdi> joined the chat.
In this case, The word in Arabic stays safe inside the tag. It does not affect the order of other words. The page may show mixed letters without this.
Keep Code Safe Inside Text:
Code: <bdi>123-XYZ</bdi> saved in record.
This code stays in order without change. The tag makes sure that numbers and letters stay aligned, even when they come with text from right to left.
Compare bdi and <bdo>:
<bdi>שלום</bdi>
<bdo dir="rtl">hello</bdo>
The first tag shows you Hebrew text. This keeps the remaining text in the same place, and the second text is RTL.
User Data in Multi-Language Page:
Post by <bdi>محمود</bdi> at 10:00 AM
Wrapping Up
You learned the role of the HTML bdi tag and the way it differs from the <bdo> tag. Here is a quick recap:
- The <bdi> tag isolates unknown or mixed text.
- The <bdo> tag forces direction control.
- You can use bdi for names or user text.
- You can use <bdo> when you need a strict order.
FAQs
How to use <bdi> tag in HTML?
<p>User: <bdi>مرحبا</bdi> 10 points</p>
The browser will display it correctly without breaking the text flow.
What is the difference between <bdi> and <bdo> in HTML?
<p>With bdi: <bdi>مرحبا</bdi></p>
<p>With bdo: <bdo dir="rtl">مرحبا</bdo></p>
Can I style <bdi> tag with CSS?
<bdi style="color:red; font-weight:bold;">مرحبا</bdi>
Similar Reads
Use the HTML object tag to embed different types of external files into your webpage. It works for videos and…
Forms need instructions so users know what to enter. You use the HTML label tag to give names to input…
The id attribute adds a unique name to an HTML element. It helps with CSS and JavaScript in the page.…
The HTML a tag allows you to create links that move users from one page or resource to another. Understand…
The HTML <cite> tag is a small but important tool for marking up the title of a creative work. You…
The header tag defines the top part of a page or a section in HTML. It usually holds a heading…
The HTML embed tag is used to display media content, such as videos or audio. It can also display PDFs…
In this article, you will learn what HTML meta tags are and how they work. You also see how they…
HTML has three main list tags: <ul>, <ol>, and <dl>. Each one shows a different kind of group. In this…
Semantic article tag in HTML uses clear tags that show the role of each part. These tags tell browsers and…