Mechanical ComparisonCSS Specificity & Inheritance: Baseline · WidelyCSS :has() Relational Selector: Baseline · Newly

CSS Specificity & Inheritance vs CSS :has() Relational Selector

Mechanical Verdict

:has() adopts the highest specificity of its relative selector list instead of summing combinators.

Try CSS Specificity & Inheritance LabTry CSS :has() Relational Selector LabRead CSS Specificity & Inheritance DissectionRead CSS :has() Relational Selector Dissection

Structured Comparison Matrix

DimensionCSS Specificity & InheritanceCSS :has() Relational Selector
Mental ModelCascade resolves Origin, @layer, (A,B,C) specificity, and source order; inherited properties propagate down only when no rule matches.:has() matches an element based on its descendants or following siblings, eliminating JS parent-class toggling.
Maturity & DomainBaseline · Widely · CSS & Layout
Chrome 88+ · Firefox 78+ · Safari 14+
Baseline · Newly · CSS & Layout
Chrome 105+ · Firefox 121+ · Safari 15.4+
PrerequisitesFoundational primitive
When Not to UseWhen not to use #id selectors in CSS: Never style with #id selectors in reusable components; reserve #id for DOM anchors and ARIA labelledby targets.When not to use :has(): Avoid :has() on :root for high-frequency hover/scroll states; scope it to small local components like .field or .card.

Engine Mechanics & Trade-Offs

CSS Specificity & InheritanceBaseline · Widely

Style engine sorts matched declarations by Origin/Importance -> @layer -> (A,B,C) -> Order, then copies inherited properties from parent ComputedStyle.

Key Pitfalls: :is() specificity surprise: :is(#header, .nav) a gives all matches (even .nav a) the #header specificity of (1, 0, 1). Form control inheritance: <button> and <input> have user-agent font and color rules, blocking <body> inheritance unless inherit is set.

CSS :has() Relational SelectorBaseline · Newly

Engines attach :has() invalidation flags to ancestors/siblings so DOM mutations only re-evaluate affected subjects instead of scanning the whole tree.

Key Pitfalls: :root:has(...) over-invalidation: Attaching :has() to :root or body with broad selectors like :has(*:hover) triggers wide style recalculations on pointer moves. Nesting :has(:has(...)): Nested :has() is disallowed by the spec and silently ignored.