The relational pseudo-class represents elements whose relative scope selector matches when evaluated absolute.
# Syntax
Copy
selector1:has(selector2) {
/* declarations */
}
# Example
Copy
header:has(h1) {
background-color: blue;
}
The mentioned example applies a blue background color to the header element with <h1>
sub elements.
# Browser support
Platform
Chrome
Firefox
Safari
Edge
Internet Explorer
Opera
Desktop
No
No
No
No
No
No
Mobile
No
No
No
No
No
No
For future browser support information, also check out caniuse.com (Relational pseudo-class).
# Usage statistics (Alexa Top 1,250,000 sites)
Please wait a moment, the comments start loading now...