SyntaxStudy
Sign Up
CSS Introduction to CSS Pseudo-Classes
CSS Beginner 4 min read

Introduction to CSS Pseudo-Classes

CSS Pseudo-Classes

Pseudo-classes select elements based on state or position rather than their attributes or type. They use a colon prefix: :hover, :focus, :nth-child().

They add interactivity and structural styling without JavaScript or extra classes.

Example
/* State-based pseudo-classes */
a:hover   { color: #007bff; }
input:focus { border-color: #007bff; }
button:active { transform: scale(0.97); }

/* Structural pseudo-classes */
li:first-child { font-weight: bold; }
tr:nth-child(even) { background: #f8f9fa; }
Pro Tip

Pseudo-classes add no specificity weight — :hover has the same specificity as the base selector.