Search code examples
csscss-selectorspseudo-elementpseudo-class

Is it possible to use pseudo-elements with the :is() pseudo-class?


Can something like this be written using the :is() pseudo-class?

div p,
div p::before,
div p::after {
    /* selectors */
}

I tried this but it didn't work:

div :is(p, p::before, p::after) {
    /* selectors */
}

Solution

  • No you cannot.

    Pseudo-elements cannot be represented by the matches-any pseudo-class; they are not valid within :is(). ref