Email or username:

Password:

Forgot your password?
Top-level
Bramus

Practically this means you need to write your styles as follows:

```css
/* Regular props = target the element’s ::selection */
main::selection {
color: red;
}

/* Custom props = target *::selection */
::selection {
background: var(--bg, transparent);
}
```

1 comment
Bramus

For compat with the old model, duplicate the CSSStyleRule with the regular props, and change the selector so that it matches all children of the element you are targeting.

```css
/* Compat with old model */
main *::selection {
color: red;
}
```

This approach will work in most cases.

Go Up