Author

Modern CSS introduced functional pseudo-classes that help you target elements more efficiently. These selectors make complex styling rules simpler and more readable. Let’s explore each one in detail:

:is() Selector:is() pseudo-class allows you to group multiple selectors into one rule.:is().Example :
Style all headings and paragraphs inside a section with one rule.
section :is(h1, h2, h3, p) {
color: #333;
font-family: Arial, sans-serif;
}
:where() Selector:where() selector works like :is(), but the big difference is specificity.:where() has zero specificity, meaning it won’t override other rules.Example :
Apply margin reset to multiple elements without increasing specificity.
:where(h1, h2, h3, p) {
margin: 0;
padding: 0;
}
:has() Selector:has() pseudo-class is sometimes called the “parent selector” in CSS.:has(), CSS couldn’t look “upward” (from child to parent). Now, we can style a parent only if it contains something specific.Example :
Style a card only if it has an image inside.
.card:has(img) {
border: 2px solid green;
background: #f9fff9;
}
:not() Selector:not() pseudo-class excludes elements from being styled.Example :
Style all list items except the first one.
li:not(:first-child) {
color: gray;
}
Advanced CSS Selectors
│
├── :is() → Groups multiple selectors into one
│
├── :where() → Groups selectors with zero specificity
│
├── :has() → Selects a parent if it contains specific children
│
└── :not() → Excludes elements from selection