CSS Selector Cheat Sheet
A complete reference for every CSS selector type — from basic element selectors to complex pseudo-classes and attribute matchers.
Last updated: May 21, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is CSS Selector Cheat Sheet?
CSS selectors determine which HTML elements a rule applies to. This cheat sheet covers all selector categories defined in the CSS specification: basic selectors, attribute selectors, structural pseudo-classes, UI pseudo-classes, pseudo-elements, and combinators.
Each entry shows the selector syntax, a brief description, and an example. Use it as a quick lookup when you need the exact syntax for an attribute selector or a specific `nth-child` expression.
How to Use CSS Selector Cheat Sheet
Common Use Cases
- Front-end developers looking up the exact syntax for :nth-child or attribute selectors.
- Students learning CSS who want a structured reference for all selector types.
- Code reviewers checking whether a selector is valid and what it targets.
- Developers migrating from a CSS framework to custom CSS who need selector basics.
Example Input and Output
Quick selector reference examples from the cheat sheet.
a[href^="https"]
p:nth-child(2n+1)
.card > .title
h2 ~ pLinks where href starts with "https"
Odd paragraph children
Direct .title children of .card
All <p> siblings after <h2>Browser support
Most selectors in this cheat sheet have universal browser support. Very new selectors (:has(), :is(), :where()) may have limited support in older browsers — check MDN or caniuse.com for specific version support.

