🌐CSS Pseudo-Class
Also known as Pseudo-Class, :hover, :focus, Pseudo Class Selector
A bit of a CSS rule that picks a thing by its state. :hover means the mouse is on it.
Think of it like
It is like a light that comes on when someone stands at the door.
Example
Lucy wants her buttons to turn dark when the mouse is on them. She adds one rule with button:hover, and no JavaScript.
Why it matters
It lets a page answer the reader with no script at all. Clear focus styles also help people who use a keyboard.
Definition
Example code
css
button:hover { background: navy; }
input:focus { outline: 2px solid teal; }Common mistake
Key takeaways
- 1One colon. :hover, :focus, :first-child.
- 2State or place. It picks by what is happening.
- 3Scores as a class. It adds 0-1-0 to the score.