CSS Pseudo Classes
What are Pseudo Classes?
Pseudo-classes select elements based on their state or position. They start
with a colon : and add dynamic styling without extra HTML.
Interactive States
:hover, :active, and :focus style
elements based on user interaction.
First & Last Child
:first-child and :last-child select the first
or last element among siblings.
Nth Child
:nth-child(n) selects elements by position. Use
numbers, odd, even, or formulas like
3n.
Not Selector
:not() excludes elements from selection. Great for
styling everything except specific items!
Link States
Style links with :link, :visited,
:hover, and :active. Order
matters: LVHA!
Form States
Style form elements with :checked,
:disabled, :enabled,
:valid, :invalid.
Summary
:hover,:focus,:active- Interactive states:first-child,:last-child- Position-based:nth-child(n)- Select by formula or keyword:not(selector)- Exclude elements:checked,:disabled,:valid- Form states- Pseudo-classes add no specificity weight
Quick Quiz
Which pseudo-class selects every other element?
Enjoying these tutorials?