---
id: css-interactive-pseudo-classes
title: "CSS Interactive Pseudo-classes"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["interactive pseudo-classes", "link pseudo-classes", "hover focus active", "anchor states", "hover tooltip"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.88
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["css", "web", "frontend", "w3schools", "pseudo-classes", "links"]
raw_sources: ["https://www.w3schools.com/css/css_pseudo_classes_interactive.asp"]
applied_in: []
github_commit: ""
---
# [[CSS Interactive Pseudo-classes]]
## π― ν μ€ ν΅μ°° (One-line insight)
Interactive pseudo-classes style elements in response to user actions β the four link states (`:link`, `:visited`, `:hover`, `:active`) must be declared in a specific order, and `:hover`/`:focus` also power effects like tooltips and highlighted inputs. [S1]
## π§ ν΅μ¬ κ°λ
(Core concepts)
- **Four link states** β `:link` (unvisited), `:visited` (visited), `:hover` (mouseover), `:active` (when clicked/activated). [S1]
- **Order matters** β `a:hover` MUST come after `a:link` and `a:visited` to be effective; `a:active` MUST come after `a:hover` to be effective. [S1]
- **`:hover` is not just for links** β it can apply to any element, e.g. a `
`. [S1]
- **`:focus`** β styles a form input while it has focus. [S1]
- **Hover-driven reveal** β `div:hover p` can show a hidden paragraph, producing a simple tooltip effect. [S1]
- **Combine with classes** β pseudo-classes can be combined with HTML classes, e.g. `a.highlight:hover`. [S1]
## π§© μΆμΆλ ν¨ν΄ (Extracted patterns)
- **LVHA ordering** β declare link, visited, hover, active in that cascade order so each rule takes effect. [S1]
- **Hover-to-reveal** β hide a child (`display: none`) and show it (`display: block`) on parent hover for a tooltip. [S1]
- **Scoped hover** β pair a class with `:hover` (`a.highlight:hover`) to limit the effect to selected elements. [S1]
## π μΈλΆ λ΄μ© (Details)
**Link pseudo-classes (the four states)**
Style links through different states using `:link`, `:visited`, `:hover`, and `:active`: [S1]
```css
/* unvisited link */
a:link {
color: #FF0000;
}
/* visited link */
a:visited {
color: #00FF00;
}
/* mouse over link */
a:hover {
color: #FF00FF;
}
/* selected link */
a:active {
color: #0000FF;
}
```
**Ordering note**
`a:hover` MUST come after `a:link` and `a:visited` in the CSS definition in order to be effective! `a:active` MUST come after `a:hover` in the CSS definition in order to be effective! [S1]
**`:hover` on a `div` element** [S1]
```css
div:hover {
background-color: blue;
}
```
**Simple tooltip hover effect**
Hovering over a `
` reveals a hidden paragraph: [S1]
```css
p {
display: none;
background-color: yellow;
padding: 20px;
}
div:hover p {
display: block;
}
```
**`:focus` on an `input` element** [S1]
```css
input:focus {
background-color: yellow;
}
```
**Combining pseudo-classes with HTML classes** [S1]
```css
a.highlight:hover {
color: #ff0000;
}
```
## π οΈ μ μ© μ¬λ‘ (Applied in summary)
The page's own applied examples are: coloring the four anchor link states, changing a `div` background on hover, a hover-reveal tooltip (`div:hover p`), highlighting a focused input, and a class-scoped hover (`a.highlight:hover`). No external project/commit applications found in the source.
## π» μ½λ ν¨ν΄ (Code patterns)
Hover-to-reveal tooltip (language: CSS):
```css
p {
display: none;
}
div:hover p {
display: block;
}
```
Class-scoped hover:
```css
a.highlight:hover {
color: #ff0000;
}
```
## βοΈ λΉκ΅ λ° μ ν κΈ°μ€ (Comparison & decision criteria)
- **`:hover` vs `:active` vs `:focus`** β `:hover` reacts to the mouse being over an element, `:active` to the element being activated (e.g. clicked), and `:focus` to an element (typically a form field) holding focus. For links, all four states must follow the LVHA order to apply correctly. [S1]
## βοΈ λͺ¨μ λ° μ
λ°μ΄νΈ (Contradictions & updates)
No contradictions found in the source.
## β
κ²μ¦ μν λ° μ λ’°λ
- **μν:** draft
- **κ²μ¦ λ¨κ³:** conceptual (μ€μ μ μ© μ¬λ‘ λ°κ²¬ μ applied/validatedλ‘ μΉκ²© κ°λ₯)
- **μΆμ² μ λ’°λ:** B (W3Schools β widely used educational reference, not a primary standards body)
- **μ λ’° μ μ:** 0.88
- **μ€λ³΅ κ²μ¬ κ²°κ³Ό:** μ κ· μμ± (New discovery)
## π μ§μ κ·Έλν (Knowledge Graph)
- **μμ/루νΈ:** [[CSS Tutorial]]
- **κ΄λ ¨ κ°λ
:** [[CSS Pseudo-classes]], [[CSS Combinators]], [[CSS Links]], [[CSS Selectors]]
- **μ°Έμ‘° λ§₯λ½:** Referenced when styling link states, hover/focus interactions, and hover-driven UI such as tooltips.
## π μΆμ² (Sources)
- [S1] W3Schools β CSS Interactive Pseudo-classes β https://www.w3schools.com/css/css_pseudo_classes_interactive.asp
## π λ³κ²½ μ΄λ ₯ (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Interactive Pseudo-classes" page (Astra wiki-curation, P-Reinforce v3.1 format).