Home > OS >  CSS: Select multiple classes' child
CSS: Select multiple classes' child

Time:07-02

I want to select multiple parents' child in CSS in this manner:

(.parent1, .parent2, ...) > child {
    ...
}

Is there any way I can do this without duplicating code:

.parent1 > child,
.parent2 > child,
... {
    ...
}

CodePudding user response:

Use the :is() pseudo-class selector

:is(.parent1, .parent2, ...) > child {
    ...
}
  • Related