concept

Rule matching — CSS reference

Rule matching determines which selectors apply to an element in its tree context. Matching a selector makes its declarations candidates; the cascade may still choose another declaration. This is not a measure of selector execution cost.

Formal Syntax & Structure

css syntaxcss
.panel > .label { color: blue; }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>rule-matching</title><style>body{margin:8px;font:16px/24px sans-serif;color:black;background:white}#a{box-sizing:border-box}.panel > .label{color:blue}</style><body><div class="panel"><span id="a" class="label">Direct</span><div><span id="b" class="label">Nested</span></div></div></body></html>
CSS Reference