Course contentsShow
← Web Development
Lesson 2518 of 2,98245. InternationalizationFree lesson

CSS direction and unicode-bidi Properties

Control text direction with CSS properties and understand when to use unicode-bidi values.

CSS direction and unicode-bidi Properties

You'll learn how to use CSS to explicitly control text direction and fine-tune bidirectional text rendering behavior.

The Core Idea

While the HTML dir attribute handles most text directionality needs, CSS provides two properties that give you programmatic control over text flow direction: direction and unicode-bidi. These work together to manage how text renders in mixed-directionality scenarios.

The direction Property

The direction property sets the base text direction for an element:

.rtl-content {
  direction: rtl; /* right-to-left */
}

.ltr-content {
  direction: ltr; /* left-to-right (default) */
}

This affects text alignment, scrollbar position, table column order, and more. However, direction alone won't override the Unicode bidirectional algorithm for inline content.

The unicode-bidi Property

This is where things get powerful. unicode-bidi controls how the browser applies directionality:

  • normal: Default behavior—respects Unicode rules
  • embed: Opens a new level of embedding (like HTML dir attribute)
  • bidi-override: Completely overrides Unicode algorithm—forces direction value on all characters
  • isolate: Treats element as isolated from surrounding text (modern approach)
  • isolate-override: Combines isolation with override behavior
.force-rtl {
  direction: rtl;
  unicode-bidi: bidi-override; /* Forces ALL text RTL */
}

When to Use Each

Use isolate for embedding content with different directionality without affecting neighbors. Use bidi-override sparingly—only when you need to force directionality regardless of character properties (like displaying codes or filenames).

Key Takeaway: direction sets the base text flow, while unicode-bidi controls how strictly that direction is applied—prefer HTML's dir attribute for content, and reserve CSS properties for dynamic styling scenarios.