Week 2 — 7 / 24

Advanced Selectors: Pseudo-Classes

You can also have styling that is conditional on the state of the page with Pseudo-Classes.

:hover matches when the user's cursor is hovering over the element. Lets you add interactivity without any javascruipt code.


:target matches if the element's id is in the URL after the # symbol


:checked, :optional, :valid, etc. for form elements


:first-child, :last-child, :nth-child for fence post problems or alternating colors on rows of a table


And many more! Normalize looking them up if you are trying to do something specific: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-classes