HTML <bdi> Tag

Tag Bdi is the topic of today’s post. For educational purposes, I believe this will be sufficient.

Tag Bdi allows users to isolate usernames from adjacent text-direction options:

Usernames and points are shown in the example below. As a result, if the browser does not support the bdi element, the Arabic user’s username would cause confusion (the bidirectional algorithm would put the colon and number “60” next to the word “User” instead of next to the word “Points”).

Example: 

<!DOCTYPE html> <html> <body> <p> Hey User ! Welcome to our Site. <br> <bdi>يا مستخدم! مرحبا بكم في موقعنا</bdi> is some text in Arabic. </p> </body> </html>

Here is a detailed example of the tag <bdi>:

Example: 

<!DOCTYPE html> <html> <head> <title>BDI Example</title> </head> <body> <p>Here is some code:</p> <pre> <code> <bdi> <span dir="ltr"> <p>This is some English text</p> <p>وهذا هو بعض النص العربي</p> </span> </bdi> </code> </pre> </body> </html>


Uses and Definition

BDI stands for Bi-Directional Isolation.

The Tag Bdi <bdi>separates a part of text that could render separately from the rest.

This element is helpful if an unknown text direction is embedded in user-generated content.


Global Attributes

There is additional functionality for HTML’s Global Attributes in the <bdi> tag.


Event Attributes

Similarly, the HTML5 <bdi> tag is compatible with the Event Attributes.


Browser Compatibility

Element
<bdi>16.079.010.0Not supported15.0

HTML <bdi> Tag Importance

The importance of the <bdi> tag lies in its ability to ensure that the text it contains is displayed correctly and without disruption, regardless of the surrounding text. This is especially important when dealing with bi-directional languages such as Arabic or Hebrew, where the writing direction changes based on the direction of the text.

By isolating a part of text with the <bdi> tag, the browser can properly handle the text’s display and formatting, even if the text is in a different language or direction than the surrounding text. This allows web developers to create more accessible and user-friendly web pages for a wider audience.


If this article somehow fulfilled your educational desires, then do share this meaningful information with your friends by clicking on the links below.
We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *