HTML Tutorial

HTML Tag: <bdo>

The <bdo> tag (Bidirectional Override) allows you to override the directionality of text, ensuring it is displayed correctly regardless of the surrounding text direction.

Usage of <bdo>

Use <bdo> when you have text that has a different directionality than the rest of the page, such as:

  • Right-to-left (RTL) text in a left-to-right (LTR) context
  • LTR text in an RTL context

Attributes of <bdo>

Attribute Description
dir Specifies the directionality of the text
lang Specifies the language of the text

Examples with <bdo>

RTL text in an LTR context:

<p>This is an LTR paragraph.</p>
<bdo dir="rtl">This is an RTL text.</bdo>

LTR text in an RTL context:

<p dir="rtl">هذا نص من اليمين إلى اليسار.</p>
<bdo dir="ltr">This is an LTR text.</bdo>

Exploring the <bdo> Tag

<!DOCTYPE html>
<html>
<head>
  <title>Exploring the &lt;bdo&gt; Tag</title>
</head>
<body>
  <p>This is an LTR paragraph.</p>
  <bdo dir="rtl">This is an RTL text.</bdo>
</body>
</html>

In this example, the <bdo> tag overrides the directionality of the RTL text, ensuring it is displayed correctly in the LTR paragraph.