CSS Selectors Cheat Sheet
# CSS Selectors Cheat Sheet
## Basic Selectors
- * โ Universal
- #id โ ID selector
- .class โ Class selector
- element โ Type selector
- element, element โ Grouping
## Combinators
- A B โ Descendant
- A > B โ Child
- A + B โ Adjacent sibling
- A ~ B โ General sibling
## Attribute Selectors
- [attr] โ Has attribute
- [attr=value] โ Exact match
- [attr^=value] โ Starts with
- [attr$=value] โ Ends with
- [attr*=value] โ Contains
- [attr~=value] โ Word match
- [attr|=value] โ Dash match
## Pseudo-Classes
- :hover, :focus, :active
- :first-child, :last-child
- :nth-child(n), :nth-of-type(n)
- :not(selector)
- :checked, :disabled, :enabled
- :empty, :root, :target
- ::before, ::after
## Specificity (highest wins)
1. inline styles (1000)
2. #id (100)
3. .class / [attr] / :pseudo (10)
4. element / ::pseudo (1)