Performance: Class selectors
Class selectors affect how quickly the browser matches CSS rules to HTML elements during style calculation.
Jump into concepts and practice - no test required
.title { color: blue; }
.container .header .title { color: blue; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| .title | Minimal DOM checks | 0 | Low | [OK] Good |
| .container .header .title | Multiple DOM ancestor checks | 0 | Low | [!] Caution |
highlight?.highlight is correct.<p class="note">Hello!</p>.note { color: blue; }.alert { color: red; }.note { color: blue; } applies.menu? menu { font-size: 1.2rem; }menu targets elements named <menu>, not class "menu". Class selectors need a dot before the name.primary to have a blue background and white text, but only when hovered. Which CSS code correctly uses class selectors and pseudo-classes?.primary:hover.