/* =================================== COMMON PSEUDO-CLASSES
=================================== */ :hover /* Mouse over element
*/
:focus /* Element focused (click/tab) */
:active /* Element being clicked */
:visited /* Visited link */
:link /* Unvisited link */
/* =================================== CHILD-BASED PSEUDO-CLASSES
=================================== */ :first-child /* First child of
parent */
:last-child /* Last child of parent */
:nth-child(n) /* Nth child (1,2,3... or even/odd) */
:nth-last-child(n) /* Nth child from end */
:only-child /* Only child of parent */
/* =================================== TYPE-BASED PSEUDO-CLASSES
=================================== */ :first-of-type /* First element
of its type */
:last-of-type /* Last element of its type */
:nth-of-type(n) /* Nth element of its type */
/* =================================== FORM PSEUDO-CLASSES
=================================== */ :checked /* Checked
checkbox/radio */
:disabled /* Disabled form element */
:enabled /* Enabled form element */
:required /* Required form element */
:optional /* Optional form element */
:valid /* Valid form input */
:invalid /* Invalid form input */
:in-range /* Input within range */
:out-of-range /* Input outside range */
/* =================================== FUNCTIONAL PSEUDO-CLASSES
=================================== */ :not(selector) /* Exclude
matching selector */
:is(selector) /* Group selectors (shorter) */
:where(selector) /* Same as :is but lower specificity */
:has(selector) /* Parent containing selector (newer) */
🧠Quick Quiz
/* Question 1: What pseudo-class selects the 3rd child? */ /* Answer:
:nth-child(3) */ /* Question 2: What pseudo-class selects all li
EXCEPT those with class "hidden"? */ /* Answer: li:not(.hidden) */ /*
Question 3: What pseudo-class styles a checked checkbox? */ /* Answer:
:checked */ /* Question 4: What is the difference between :first-child
and :first-of-type? */ /* Answer: :first-child checks position in
parent. :first-of-type checks first element of that type. */ /*
Question 5: What pseudo-class styles an input with invalid email? */
/* Answer: :invalid */