HTML bdo Tag – Control Text Direction

html bdo tag

Text on a page often moves from left to right. Some languages move from right to left. HTML gives control for this with the bdo tag.

Understand the <bdo> Tag in HTML

The <bdo> tag means bidirectional override. It forces text to show in a set direction that you decide.

Here is the syntax:

<bdo dir="ltr">Some text here</bdo>
<bdo dir="rtl">Some text here</bdo>

Writers often face mixed scripts on one page. Numbers may appear with Arabic text, or Hebrew text may sit with English text. <bdo> lets you set the flow so each part shows correctly.

The only main attribute of <bdo> is dir. It can take ltr for left-to-right text or rtl for right-to-left text.

All main browsers support <bdo>. It works in Chrome, Edge, Safari, Firefox, and Opera with no extra setup.

The Differences Between <bdo> Tag and CSS Direction

The <bdo> tag forces the flow by HTML itself. CSS direction sets flow by style rules. HTML override has more weight.

Here is a table that shows you the key differences:

FeaturebdoCSS direction
Control typeHTML tagCSS property
Force levelStrong overrideStyle suggestion
Common useSmall partsLarge sections

You use <bdo> for short words or lines with mixed scripts. You use CSS direction when you want the whole block to follow one flow.

Examples of <bdo> Tag in HTML

Force Left to Right Flow:

<bdo dir="ltr">مرحبا Hello</bdo>

This code sets mixed Arabic and English text into a left-to-right flow. The Arabic word moves out of its normal flow and matches the English word beside it.

Force Right to Left Flow:

<bdo dir="rtl">Hello مرحبا</bdo>

This code forces the same words into a right-to-left flow. The English part appears after the Arabic part in reverse order to match the Arabic flow.

Nested bdo for Mixed Text Control:

<bdo dir="rtl">مرحبا <bdo dir="ltr">12345</bdo></bdo>

This code shows Arabic text with numbers inside. Arabic part flows right to left, but numbers flow left to right.

Wrapping Up

You learned what the <bdo> tag means and how to use it to control text flow. You also saw its attribute and how it differs from CSS direction.

Here is a quick recap:

  • <bdo> shows you the text flowed by HTML
  • dir attribute sets left to right or right to left
  • The CSS direction handles style but <bdo> gives you a direct override

FAQs

What is the use of <bdo> tag in HTML?

The <bdo> tag forces the browser to override the default text direction.
<bdo dir="rtl">This text reads right to left</bdo>

How to reverse text direction with <bdo> in HTML?

You can set dir="rtl" inside <bdo> to reverse text flow.
<bdo dir="rtl">Hello World</bdo>

What is the difference between <bdo> and CSS direction?

The <bdo> tag is semantic and forces direction at the HTML level, while CSS uses direction property for styling.
/* CSS Example */
p {
  direction: rtl;
}

Can <bdo> be nested inside other HTML elements?

Yes, you can nest <bdo> inside most inline and block elements.
<p>Normal text <bdo dir="rtl">Reversed text</bdo></p>

Similar Reads

HTML Global Attributes Overview

HTML global attributes work on most elements. They do not depend on the tag name. You can use them with…

HTML id Attribute: How to Assign Unique Identifiers to Elements

The id attribute adds a unique name to an HTML element. It helps with CSS and JavaScript in the page.…

HTML br Tag: Line Breaks

The br tag adds a single line break in HTML. It is an empty tag that does not need a…

HTML meta http-equiv Attribute for Web SEO with Examples

This guide explains how to use the HTML meta http-equiv attribute, why it matters for SEO, and how browsers treat…

HTML output Tag: How to Display Calculation Results

The <output> tag in HTML shows results inside a form. It helps display values from user actions or scripts. You…

HTML Select Tag: How Combo Box & Option Work with Examples

HTML select tag and option tags let users pick values in a form. You use them to create dropdowns. The…

HTML samp Tag: How to Show Sample Program Output

The HTML samp tag shows the result of a computer program or command. It helps readers know which text came…

What is HTML for Beginners and How it Works for Beginners

HTML builds the base for every web page. It sets structure and meaning so the browser knows what to show.…

How to Use HTML div Tag – Examples & Group Content

In this article, you will cover how to use div tag in HTML layout. It offers beginner to advanced code…

HTML head Tag: How to Include Metadata and Links in head

The HTML head tag contains information and loads tools for the web page. What Is the <head> Tag in HTML?…

Previous Article

PHP array_diff_key Function: How it Works with Examples

Next Article

PHP array_find: How to Locate Array Values with Examples

Write a Comment

Leave a Comment

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


Subscribe to Get Updates

Get the latest updates on Coding, Database, and Algorithms straight to your inbox.
No spam. Unsubscribe anytime.