Teyro
CoursesFor creatorsBlog
Log inGet started
Tey Mascot
LOADING.

Every expert you admire was once a beginner who refused to quit.

Teyro

The fun way to finish learning coding and AI: short daily lessons with streaks, leagues and friends.

Get the app

Learn

  • All courses
  • Learn coding
  • Learn AI
  • Learn online
  • How it works
  • Leagues
  • Get the app

Creators

  • Teach on Teyro
  • How teaching works
  • Teach coding online
  • Teach AI online
  • Join as a Founding Creator
  • Creator log in

Resources

  • Blog
  • Features
  • Use cases
  • Compare
  • FAQ

Legal

  • Terms of Use
  • Privacy Policy

© 2026 Teyro · support@teyro.app

HomeBlogSkill Building & Careers
Skill Building & Careers

CSS Pseudo-Classes: hover, focus, first-child and nth-child

Learn CSS pseudo-classes like :hover, :focus, :first-child, :nth-child and :not with practical examples, plus the difference from pseudo-elements.

The Teyro TeamOct 26, 20261 min read
On this page6 sections
  1. Direct answer
  2. Examples
  3. Accessibility tip
  4. Where Teyro fits
  5. The bottom line
  6. More guides

Pseudo-classes let CSS react to what is happening.

Direct answer

A pseudo-class starts with a single colon and selects an element in a certain state or position. Common ones are :hover, :focus, :active, :first-child, :last-child, :nth-child() and :not(). Pseudo-elements like ::before use two colons.

Examples

a:hover { color: tomato; }
input:focus { outline: 2px solid #3d5afe; }
li:first-child { font-weight: bold; }
tr:nth-child(even) { background: #f5f5f5; }
button:not(:disabled):hover { background: #eee; }

p::first-line { font-weight: bold; }
.note::before { content: "Note: "; }

Accessibility tip

Never remove focus outlines without replacing them with a visible alternative. Keyboard users depend on them.

Where Teyro fits

Teyro's HTML & CSS for Beginners course turns this into short lessons you can play in a few minutes a day. It has 100 lessons, and you can start free.

The bottom line

Pseudo-classes add interactivity and structure to your styles without extra HTML.

More guides

  • CSS Transitions
  • CSS Reset vs Normalize
  • HTML Attributes Explained
  • Css selectors guide
  • HTML & CSS for Beginners course

Frequently asked questions

What is a pseudo-class?

A keyword added to a selector to style an element in a particular state, such as when hovered.

What is the difference between a pseudo-class and pseudo-element?

A pseudo-class selects an element in a state. A pseudo-element selects part of an element, such as its first line or content before it.

How do I style every second item?

Use :nth-child(2n) or :nth-child(even).

Learn it by playing

HTML & CSS for Beginners turns this into short, playable lessons. Free to start.

See the HTML & CSS for Beginners course

Free to start · No credit card needed

Share

Written by

The Teyro Team

Learning Team at Teyro

We build Teyro — an AI-powered learning platform that turns skill-building into a daily habit through bite-sized, gamified lessons. We write about the learning science and study strategies that shape our product.

More from The Teyro Team

On this page

  • Direct answer
  • Examples
  • Accessibility tip
  • Where Teyro fits
  • The bottom line
  • More guides

Keep reading

Skill Building & Careers

Best Careers for 2027: High-Demand Jobs and the Skills to Get Them

The best careers for 2027 and the jobs most in demand, based on BLS and World Economic Forum data, plus the skills each path needs.

Oct 30, 20263 min read
Skill Building & Careers

Best Certifications for 2027: Tech, Data, Cloud and Business

The best certifications for 2027 in cloud, security, data, project management and AI, who each one suits, and when a portfolio matters more.

Oct 30, 20263 min read
Skill Building & Careers

Best Programming Language to Learn in 2027 (for Your Goal)

The best programming language to learn in 2027 depends on what you want to build. Compare Python, JavaScript, TypeScript, SQL and C.

Oct 30, 20263 min read