Universal *, Type p, Class .class, ID #id, Attribute [attr=value], Pseudo-classes, Pseudo-elements, Combinators.
input[type="text"] { color: blue; }
➡ nth-child: based on position among siblings.
➡ nth-of-type: based on position among same type.
▶ div > p: only direct children.
▶ div p: all nested.
➡ h1 + p: first <p> after <h1>.
➡ h1 ~ p: all <p> after <h1>.
▶ :first-child: first child of parent regardless of type.
▶ :first-of-type: first element of its type.
➡ nth-child(odd): odd children regardless of tag.
➡ nth-of-type(odd): odd elements of same tag.
p:not(.highlight) { color: gray; }
▶ :hover: triggered on mouse hover.
▶ ::before: adds content before element.
-- Inline (1000) > ID (100) > Class (10) > Element (1).
* {
margin: 0;
padding: 0;
}
➡ :checked: for checked inputs.
➡ :disabled: for disabled inputs.
➡ :enabled: for enabled inputs.
Applied when an element or its descendants have focus.
▶ :root: highest-level element, useful for CSS variables.
▶ html: same as root, but :root has higher specificity.
➡ :link → unvisited links.
➡ :visited → visited links.
➡ :hover → mouse hover.
➡ :active → when clicked.