Skip to main content
Ganesh Joshi
Back to Cheatsheets

CSS selectors

Updated 2026-02-15

CSS selectors, combinators, and pseudo-classes. Element, class, ID, attribute, and :nth-child.

Basic and combinators

element, .class, #id. [attr], [attr=val], [attr^=val], [attr$=val], [attr*=val]. space descendant, > child, + adjacent sibling, ~ general sibling.

Pseudo-classes

:hover, :focus, :active, :disabled. :first-child, :last-child, :nth-child(n), :nth-of-type(n). :not(.class). :is(), :where(), :has().

Pseudo-elements

::before, ::after (content required). ::first-line, ::first-letter. ::placeholder, ::selection.

CSS selectors | Cheatsheet | Ganesh Joshi