CSS selectors
Quick Hands-on
See the Pen CSS Basics - CSS Selectors by (@) on CodePen.
Important points to remember
-
A CSS selector is used to select the HTML element(s) that we can style.
-
Common CSS categories:
- Simple selectors (name, id, class)
- Combinator selectors (relation between two selectors): Descendant selector (space), Child selector(
>
), Normal sibling selector(~
), Adjacent sibling selector(+
) - Pseudo-class selectors (based on specific states)
- Pseudo-elements selectors (select and style a part of an element)
- Attribute selectors (based on an attribute or attribute value)