CSS :dir() Pseudo-class
Example
Use of the :dir() pseudo-class:
:dir(rtl) {
background-color: lightgreen;
}
Try it Yourself »
Definition and Usage
The CSS :dir() pseudo-class matches any
element with the specified text direction.
-
:dir(rtl)matches elements with right-to-left text -
:dir(ltr)matches elements with left-to-right text
Tip: In HTML, the text direction is specified with the
dir attribute.
| Version: | CSS Selectors Level 4 |
|---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the pseudo-class.
| Pseudo-class | |||||
|---|---|---|---|---|---|
| :dir() | 120 | 120 | 49 | 16.4 | 106 |
CSS Syntax
:dir(ltr|rtl) {
css declarations;
}