/* Selects any element with right-to-left text */
:dir(rtl) {
background-color: red;
}`:dir()` CSS pseudo-class / notebook
`:dir()` CSS pseudo-class
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
<div dir="rtl">
<span>test1</span>
<div dir="ltr">
test2
<div dir="auto">עִבְרִית</div>
</div>
</div>:dir(ltr) {
background-color: yellow;
}
:dir(rtl) {
background-color: powderblue;
}