Skip to content

CSS Selectors

Direction

About

The :dir() pseudo-class matches elements based on the directionality of their text content.

Right-to-left elements

The selector :dir(rtl) matches elements whose text direction is right-to-left.

  • Change the selector to match left-to-right elements instead

Automatic direction

With dir="auto", the browser determines the direction from the text content. The :dir() pseudo-class reflects this computed direction.

  • Enter some Arabic text to let the selector match

Inherited direction

The direction is inherited from parent elements. The inner div is matched because the parent has dir="rtl".