Vivi Guide

Lesson: CSS Pseudo-Selectors

Style elements based on their state, position, or structure!

๐ŸŽฏ What are Pseudo-Selectors?

Pseudo-selectors let you apply styles to elements based on interactions (like :hover), position in the DOM (like :first-child), or states (like :checked).

๐Ÿ”ง Common Pseudo-Classes

๐Ÿงช Example: Button Hover

button:hover {
  background-color: #4CAF50;
  color: white;
}

๐Ÿงช Example: Zebra Table

tr:nth-child(odd) {
  background: #f2f2f2;
}
tr:nth-child(even) {
  background: #ffffff;
}

๐Ÿงช Example: First Letter Styling

p::first-letter {
  font-size: 2em;
  color: red;
}

๐Ÿงช Example: Link Icon

a::before {
  content: "\2192 ";
  color: green;
}

๐Ÿ“Œ Tips

๐Ÿš€ Try It Yourself!

Open Pseudo Playground
PREVIOUS LESSON :

Hover Effects and Transitions

BACK TO CSS BASICS :

CSS Basics