Is there a CSS selector combinator for selecting two classes in the same element or in any descendant. For example:
<div class="theme-classic btn"></div>
or:
<div class="theme-classic">
<div>
<div class="btn"></div>
</div>
</div>
If in my CSS file I write: .theme-classic.btn
I do not select the descendants.
If in my CSS file I write: .theme-classic .btn
I do not select the first case where the classes are on the same element.
Of course, I can do something like:
.theme-classic.btn,
.theme-classic .btn { ... }
But I can’t find a combinator that does both.
2
Answers
This does not exist in CSS.
You need to select them both separately like you mentioned:
CSS nesting can help you simplify the selector and avoid repeating
.theme-classic