Matches when a user moves the mouse pointer over an element
A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). (see more on MDN)
For example, :hover can be used to change a button's color when the user's pointer hovers over it.
In this section, you'll understand the difference between hover, active, focus and focus-within.
Every time a pseudo class in an Exercice block is triggered you'll see the name of the triggered state at the top of the html element like on the picture below:
Matches when a user moves the mouse pointer over an element
Matches when an item is being activated by the user. When you start click on a element with a mouse for example
Matches when an item is being focused by the user. When you click on an element with the mouse.
Buttons and link can be focused by default. To allow other HTML elements to be focused, you should add the key tabindex="0" to it.
Matches when an item is focused or any of its descendants are focused
Sometimes you do not want an element to be affected by pseudo-class. In that case, you can disable all pointer-events on this element.
In this page, we only covered 4 pseudo classes but there is much more pseudo classes to use.
Go to MDN - Pseudo classes to find out all the pseudo-classes available 🥳