Computer Study

Bdi Tag in HTML

The <bdi> tag is a relatively new HTML5 tag that is used to isolate a span of text that might be formatted differently from the text around it, due to a difference in language or directionality. The name “bdi” stands for “Bi-Directional Isolation”.

The <bdi> tag is useful for websites that support multiple languages or have content that includes text in different languages with different directionality (such as Arabic, Hebrew or Persian).

Syntax: The basic syntax for the <bdi> tag is as follows:

<bdi>text</bdi>

Here, “text” represents the content to be isolated by the <bdi> tag.

Example: Here’s an example of how the <bdi> tag can be used to isolate text that’s formatted differently due to language differences:

<p>
Welcome to our site!
<bdi lang=”ar”>أهلاً وسهلاً</bdi>
to all our Arabic-speaking visitors!
</p>

In this example, the Arabic text is surrounded by the <bdi> tag, with the “lang” attribute indicating that the text is in Arabic. The <bdi> tag isolates the text from the surrounding English text and allows it to be formatted correctly according to Arabic directionality.

Conclusion: The <bdi> tag is a useful tool for creating websites that support multiple languages or have content with different directionality. It allows for the isolation of text that might otherwise be formatted incorrectly due to these differences.

Related Articles

Leave a Reply

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

Check Also
Close
Back to top button