Content · Web Development · HTML

HTML <bdi> Element: Isolating Bidirectional Text

Bdi isolates text whose direction may differ from surrounding text, especially user-provided names. The browser keeps that piece's direction from affecting nearby punctuation.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Bdi isolates text whose direction may differ from surrounding text, especially user-provided names. The browser keeps that piece's direction from affecting nearby punctuation.

What You Need to Know


It does not translate the text. Use dir where you know and want to set a direction; bdi is valuable when you do not control the name's language.

The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.

Example: See It in Action


Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<p>Player: <bdi>أحمد</bdi> — 15 points</p>
<p>The name keeps its own text direction.</p>
<p>This helps when content comes from users.</p>

Let’s Understand the Example


  • Bdi isolates text whose writing direction may differ from its surroundings.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.

Look for the text “Player:” in the page. If the visible result surprises you, inspect the rendered elements to see what the browser actually built.

What Should You See?


The page should include “Player:”. If it looks different from what you expected, open developer tools and compare the source with the elements the browser created.

Try removing one piece of markup in a scratch copy, refresh the page, and compare the behavior. This is often the fastest way to understand what that piece contributes.

Try It Yourself


  1. Put two names from different writing directions into a score list.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Letting an unknown right-to-left user name reorder punctuation in a score display.
  • Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.

Key Takeaways


  • Bdi isolates text whose direction may differ from surrounding text, especially user-provided names.
  • Bdi isolates text whose writing direction may differ from its surroundings.
  • It does not translate the text. Use dir where you know and want to set a direction; bdi is valuable when you do not control the name's language.
Share this resourceSend this page to someone who may find it useful.