CSS :dir() Selector Reference

The CSS :dir() pseudo-class matches elements according to their text direction.

CSS :dir() Selector Reference

The CSS :dir() pseudo-class matches elements according to their text direction.

Updated 2026-08-07

Syntax and example

Use :dir(ltr) or :dir(rtl) when styling must follow the direction calculated by the document language and directionality rules.

CSS :dir(rtl) { text-align: right; }

Description

The CSS :dir() pseudo-class matches elements according to their text direction.

References

  1. Selectors Level 4: The Directionality Pseudo-class
  2. MDN: :dir()

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies