Tag unicode-bidi

🔤 CSS unicode-bidi — Control Text Direction and Embedding

The unicode-bidi property works alongside the direction property to manage how bidirectional text is handled in HTML. It’s essential for properly displaying languages that use right-to-left (RTL) scripts like Arabic or Hebrew mixed with left-to-right (LTR) text.


🔹 What Does unicode-bidi Do?

It controls the embedding and override behavior of the bidirectional algorithm, determining how text with mixed directions (LTR & RTL) is displayed and ordered.


📘 Syntax

selector {
unicode-bidi: normal | embed | isolate | bidi-override | isolate-override | plaintext;
}

✅ Values Explained

ValueDescription
normalDefault. No special handling; text direction follows direction property.
embedEmbeds the element’s text in a new directional context.
isolateIsolates the element’s text direction, preventing influence from surrounding text.
bidi-overrideOverrides the bidirectional algorithm; text direction forced as per direction property.
isolate-overrideCombines isolate and bidi-override.
plaintextMakes the element behave like plain text for bidi purposes (used less often).

🔧 Usage with direction

The unicode-bidi property must be used with direction to have effect:

.rtl-text {
direction: rtl;
unicode-bidi: embed;
}

✍️ Examples

1. Basic RTL Embedding

<p class="rtl-text">Hello مرحبا world!</p>
.rtl-text {
direction: rtl;
unicode-bidi: embed;
}

✅ The Arabic text is embedded properly within the LTR sentence.


2. Override Text Direction

.override-text {
direction: rtl;
unicode-bidi: bidi-override;
}

✅ Forces the entire text block to display RTL, ignoring logical text order.


🖼️ Image Idea: Mixed Direction Text

Show side-by-side examples of:

  • Normal bidirectional text (default)
  • Text with unicode-bidi: embed + direction: rtl
  • Text with unicode-bidi: bidi-override

Illustrate the flow of text and how the rendering differs.


💡 When to Use unicode-bidi

  • Displaying mixed LTR and RTL languages in the same paragraph
  • Handling quotes or embedded text with a different direction
  • Controlling layout of complex scripts in multilingual websites
  • Overriding browser’s default bidi algorithm when needed

✅ Summary

Propertyunicode-bidi
PurposeControls embedding and overriding of text direction
Must be used withdirection property
Common Valuesnormalembedbidi-overrideisolate
Use casesBidirectional text handling, multilingual layouts

🔚 Final Thought

unicode-bidi is a subtle but powerful CSS property that ensures your multilingual text displays correctly and elegantly — making your site accessible and readable worldwide.