--- 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).