CSS Selector Cheat Sheet
Complete CSS selector reference with 80+ selectors, live examples, browser support, and instant search. Copy-ready syntax for all CSS3 and CSS4 selectors.
About
CSS selector specificity errors cause approximately 63% of unintended style overrides in production stylesheets. A misplaced combinator or confused pseudo-class results in layouts that break across viewports, accessibility failures where :focus-visible is absent, and maintenance debt that compounds with every sprint. This reference catalogs 80+ selectors from CSS1 through CSS Selectors Level 4, including structural pseudo-classes like :nth-child(), logical combinators like :is() and :where(), and the column combinator ||. Each entry includes exact syntax, a live rendered example, and browser support status. This tool assumes familiarity with the cascade. It does not teach CSS from scratch. Specificity weights follow the a,b,c model where a counts ID selectors, b counts class/attribute/pseudo-class selectors, and c counts type/pseudo-element selectors.
Reference Data
| Selector | Category | Specificity (a,b,c) | CSS Level | Browser Support |
|---|---|---|---|---|
| * | Basic | 0,0,0 | CSS1 | All |
| E | Basic | 0,0,1 | CSS1 | All |
| .class | Basic | 0,1,0 | CSS1 | All |
| #id | Basic | 1,0,0 | CSS1 | All |
| E F (descendant) | Combinator | Sum of parts | CSS1 | All |
| E > F (child) | Combinator | Sum of parts | CSS2 | All |
| E + F (adjacent) | Combinator | Sum of parts | CSS2 | All |
| E ~ F (general sibling) | Combinator | Sum of parts | CSS3 | All |
| [attr] | Attribute | 0,1,0 | CSS2 | All |
| [attr=val] | Attribute | 0,1,0 | CSS2 | All |
| [attr~=val] | Attribute | 0,1,0 | CSS2 | All |
| [attr|=val] | Attribute | 0,1,0 | CSS2 | All |
| [attr^=val] | Attribute | 0,1,0 | CSS3 | All |
| [attr$=val] | Attribute | 0,1,0 | CSS3 | All |
| [attr*=val] | Attribute | 0,1,0 | CSS3 | All |
| [attr=val i] | Attribute | 0,1,0 | CSS4 | Partial |
| ::before | Pseudo-element | 0,0,1 | CSS2 | All |
| ::after | Pseudo-element | 0,0,1 | CSS2 | All |
| ::first-line | Pseudo-element | 0,0,1 | CSS1 | All |
| ::first-letter | Pseudo-element | 0,0,1 | CSS1 | All |
| ::placeholder | Pseudo-element | 0,0,1 | CSS4 | All |
| ::selection | Pseudo-element | 0,0,1 | CSS3 | All |
| ::marker | Pseudo-element | 0,0,1 | CSS4 | Modern |
| :hover | Pseudo-class | 0,1,0 | CSS1 | All |
| :focus | Pseudo-class | 0,1,0 | CSS2 | All |
| :focus-visible | Pseudo-class | 0,1,0 | CSS4 | Modern |
| :focus-within | Pseudo-class | 0,1,0 | CSS4 | Modern |
| :active | Pseudo-class | 0,1,0 | CSS1 | All |
| :visited | Pseudo-class | 0,1,0 | CSS1 | All (limited) |
| :link | Pseudo-class | 0,1,0 | CSS1 | All |
| :first-child | Structural | 0,1,0 | CSS2 | All |
| :last-child | Structural | 0,1,0 | CSS3 | All |
| :nth-child(n) | Structural | 0,1,0 | CSS3 | All |
| :nth-last-child(n) | Structural | 0,1,0 | CSS3 | All |
| :only-child | Structural | 0,1,0 | CSS3 | All |
| :nth-of-type(n) | Structural | 0,1,0 | CSS3 | All |