CSS :dir() Selector
Example
p:dir(rtl) {
color: blue;
}
p:dir(ltr) {
color: green;
}
Meaning
The :dir() selector matches elements based on the directionality of the text contained in them.
The :dir() pseudo-class uses only the semantic value of the directionality, i.e., the one defined in the document itself. It doesn't account for styling directionality, i.e., the directionality set by CSS properties such as direction.
Note: In HTML, the direction is determined by the dir attribute. Other document types may have different methods.
Version: CSS3
Standard Syntax
:dir(ltr | rtl) {
css declarations;
}
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Status
Parameters
The following table describes the values of this parameters.
ltr | Apply left-to-right elements. |
rtl | Apply right-to-left elements. |