Pseudo-Classes

๐ŸŽจ CSS3+ ๐ŸŸข Chapter 5 of 49 ๐Ÿ“‚ Phase 02: Selectors ๐Ÿ“… 2026 Edition
๐Ÿ“Œ Covered in this chapter: :hover ยท :active ยท :focus ยท :focus-visible ยท :visited ยท :checked ยท :disabled ยท :nth-child() ยท :not() ยท :is() ยท :where() ยท :has()
Welcome to Chapter 5: Pseudo-Classes โ€” part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1What Are Pseudo-Classes?

Pseudo-classes element state or position based ga style apply chestayi โ€” hover, focus, nth child, etc. Syntax: single colon : prefix.

CSS โ€” Common Pseudo-Classesโ–ถ Try in Editor
button:hover {
  background-color: #2563eb;
}

input:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

li:nth-child(even) {
  background: #f3f4f6;
}
2Interactive States โ€” :hover, :active, :focus
  • :hover โ€” mouse pointer element meedha unnapudu
  • :active โ€” click/press chesinapudu (momentary)
  • :focus โ€” keyboard or click tho element focused
  • :focus-visible โ€” keyboard navigation focus matrame (accessibility best practice)
CSS
a:visited { color: #7c3aed; }
input:disabled { opacity: 0.5; cursor: not-allowed; }
input:enabled { border-color: #cbd5e1; }
input:checked + label { font-weight: 700; }
3Structural Pseudo-Classes โ€” :first-child, :nth-child()
CSS
li:first-child { font-weight: 700; }
li:last-child { border-bottom: none; }
li:nth-child(odd) { background: #f8fafc; }
li:nth-child(3n) { color: #3b82f6; }
4Modern Functional Pseudo-Classes โ€” :not(), :is(), :where(), :has()
CSS โ€” Modern Selectors
/* Exclude disabled buttons */
button:not(:disabled) { cursor: pointer; }

/* Group selectors with zero specificity boost (where) */
:where(h1, h2, h3) { line-height: 1.2; }

/* Parent selector โ€” card with image inside */
.card:has(img) { padding-top: 0; }

/* Form invalid state on parent */
.form-group:has(input:invalid) { border-color: red; }

:has() โ€” "parent selector" revolution! Previously impossible parent styling ippudu possible.

OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy ยท CSS Complete Roadmap ยท Last updated August 2026