Starlit Daily

📚 › CSS: style and layout

9. Pseudo-classes: hover and focus

A pseudo-class styles an element in a particular state. :hover applies while the mouse is over an element. :focus applies when the element is selected with the keyboard. :first-child picks the first child.

Always style :focus too, so keyboard users can see where they are.

Show example

a:hover {
  text-decoration: underline;
}
button:focus {
  outline: 3px solid orange;
}

✍️ Your turn

Make .btn change its background to orange when hovered.

← Back to course