What are the BDO and BDI HTML5 Tags For?

3 min read

The <bdo> (Bidirectional Override) and <bdi> (Bidirectional Isolation) tags in HTML5 are crucial for managing the text direction on web pages. These tags are especially important in multilingual websites where text direction can vary. This beginner-friendly guide will delve into the functionalities of these tags and their significance in web development.

1. The <bdo> Tag

What is the <bdo> Tag?

The <bdo> tag is used to override the current text direction. It’s particularly useful when you need to change the directionality of text for stylistic or other reasons, regardless of the default direction set by other HTML elements or the document itself.

Attributes of the <bdo> Tag

  • dir: The only attribute for <bdo>, which specifies the text direction. It can be set to ltr (left-to-right) or rtl (right-to-left).

Example Code with the <bdo> Tag

<!DOCTYPE html>
    <title>BDO Tag Example</title>

    <p>The following word uses right-to-left directionality: 
    <bdo dir="rtl">example</bdo>.</p>


In this example, the word “example” is displayed in a right-to-left direction, overriding the default text direction.

2. The <bdi> Tag

What is the <bdi> Tag?

The <bdi> tag isolates a part of the text so that its directionality is calculated independently of its surroundings. This is essential in user-generated content where you cannot predict the direction of the text, such as names or comments.

Example Code with the <bdi> Tag

<!DOCTYPE html>
    <title>BDI Tag Example</title>

        <li>User: <bdi>Carlos</bdi></li>
        <li>User: <bdi>سعيد</bdi></li>


In this example, user names are isolated using the <bdi> tag, ensuring that their directionality doesn’t affect the layout of the list, regardless of whether the text is left-to-right or right-to-left.

Significance in Web Development

  • Multilingual Support: Both tags are particularly useful in multilingual websites where text direction can vary dramatically.
  • Enhanced User Experience: They help display user-generated content correctly, enhancing the readability and user experience.
  • Preventing Layout Issues: These tags can prevent layout issues in a single document caused by mixed directionality.


The <bdo> and <bdi> tags are invaluable in modern web development, especially as the internet becomes increasingly multilingual. Understanding and using these tags can significantly improve web pages’ functionality and user experience that handles multiple text directions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Carlos Baez

Subscribe now to keep reading and get access to the full archive.

Continue Reading