--- url: "https://web.dev/learn/css/pseudo-classes" titulek: "Pseudo-classes | web.dev" h1: "Pseudo-classes Stay organized with collections Save and categorize content based on your preferences." popis: "Pseudo-classes let you apply CSS based on state changes. This means that your design can react to user input such as an invalid email address." jazyk: "en" kanonicka: "https://web.dev/learn/css/pseudo-classes" drobecky: ["web.dev", "Resources", "CSS"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 00:55:46" znaku: 18305 slov: 2666 kodovani: "iso-8859-2" sha256: "0b9b0b305c74397f41afe8e6a49a1e3700bf604fa1de5522f931e99541532fe3" --- Pseudo-classes Stay organized with collections Save and categorize content based on your preferences. [The CSS Podcast - 015: Pseudo-classes](https://thecsspodcast.libsyn.com/015-pseudo-selectors) Say you've got an email sign up form, and you want the email form field to have a red border if it contains an invalid email address. How do you do that? You can use an `:invalid` CSS pseudo-class, which is one of many browser-provided pseudo-classes. A pseudo-class lets you apply styles based on state changes and external factors. This means that your design can react to user input such as an invalid email address. These are covered in the [selectors](/learn/css/selectors) module, and this module will take you through them in more detail. Unlike pseudo-elements, which you can learn more about in the [previous module](/learn/css/pseudo-elements), pseudo-*classes* hook onto specific *states* that an element might be in, rather than generally style parts of that element. Interactive states The following pseudo-classes apply due to an interaction a user has with your page. `:hover` Browser Support 1 12 1 2 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/:hover) If a user has a pointing device like a mouse or trackpad, and they place it over an element, you can hook on to that state with [`:hover`](https://developer.mozilla.org/docs/Web/CSS/:hover) to apply styles. This is a useful way to hint that an element can be interacted with. `:active` Browser Support 1 12 1 1 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/:active) This state is triggered when an element is actively being interacted with— such as a click—before click is released. If a pointing device like a mouse is used, this state is when the click starts and hasn't yet been released. `:focus`, `:focus-within`, and `:focus-visible` Browser Support 1 12 1 1 [Source](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/:focus) If an element can receive focus—like a `