--- id: css-tooltips title: "CSS Tooltips" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["tooltip", "CSS tooltip", "hover tooltip", "tooltiptext", "hover hint", "info tooltip"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "tooltip", "hover"] raw_sources: ["https://www.w3schools.com/css/css_tooltip.asp"] applied_in: [] github_commit: "" --- # [[CSS Tooltips]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) A CSS tooltip shows extra information about an element when the user moves the mouse pointer over it, built from a hidden, absolutely-positioned text box that is revealed on `:hover`. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Purpose** β€” a tooltip specifies extra information about something when the user hovers the mouse pointer over an element. [S1] - **Two-element structure** β€” a container element (class `tooltip`) wraps the trigger text and a nested element (class `tooltiptext`) that holds the tooltip text. [S1] - **Hidden by default** β€” the tooltip text starts with `visibility: hidden` and becomes `visible` only on hover of the container. [S1] - **Positioning context** β€” the container is `position: relative` so the absolutely-positioned tooltip text is placed relative to it. [S1] - **Stacking** β€” `z-index: 1` keeps the tooltip above other content. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Hover-reveal pattern** β€” hide an element, then flip it to visible via a descendant selector triggered by the parent's `:hover` state (`.tooltip:hover .tooltiptext`). [S1] - **Directional placement** β€” the same tooltip text box can be moved right, left, above, or below the trigger by switching which offset properties (`left`/`right`/`top`/`bottom`) and centering margins are set. [S1] - **Fade-in via opacity transition** β€” instead of toggling visibility instantly, animate `opacity` from 0 to 1 with a `transition` for a smooth appearance. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **What is a CSS tooltip?** A CSS tooltip is used to specify extra information about something when the user moves the mouse pointer over an element. [S1] **Basic tooltip** The container uses `position: relative` and `display: inline-block`; the tooltip text is hidden and absolutely positioned, and a hover rule on the container makes it visible. [S1] ```css .tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; cursor: pointer; } .tooltiptext { visibility: hidden; width: 130px; background-color: black; color: #ffffff; text-align: center; padding: 5px 0; border-radius: 6px; position: absolute; z-index: 1; } .tooltip:hover .tooltiptext { visibility: visible; } ``` **Positioning the tooltip** By adding offset properties to the `.tooltiptext` rule, the tooltip is moved to the right, left, top, or bottom of the trigger. The grounded offset values from the source are: [S1] | Direction | Offset properties | |-----------|-------------------| | Right | `left: 105%; top: -5px;` | | Left | `right: 105%; top: -5px;` | | Top | `bottom: 100%; left: 50%; margin-left: -65px;` | | Bottom | `top: 100%; left: 50%; margin-left: -65px;` | For the top and bottom variants, `left: 50%` plus a negative `margin-left` of half the tooltip width (`-65px` for a `130px`-wide box) horizontally centers the tooltip over the trigger. [S1] **Fade-in animation** To fade the tooltip in instead of showing it instantly, start the text at `opacity: 0`, add a `transition` on opacity, and raise it to `1` on hover. This creates a 2-second fade from invisible to fully visible. [S1] ```css .tooltiptext { opacity: 0; transition: opacity 2s; } .tooltip:hover .tooltiptext { opacity: 1; } ``` ## πŸ› οΈ 적용 사둀 (Applied in summary) The tutorial's own example β€” a `.tooltip` container with a nested `.tooltiptext` element revealed on hover β€” is the canonical applied case. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Hover-reveal tooltip skeleton (language: CSS): ```css .tooltip { position: relative; display: inline-block; } .tooltip .tooltiptext { visibility: hidden; position: absolute; z-index: 1; } .tooltip:hover .tooltiptext { visibility: visible; } ``` Directional placement (right of the trigger): ```css .tooltip .tooltiptext { top: -5px; left: 105%; } ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Tooltip Arrows]], [[CSS Position]], [[CSS Visibility]], [[CSS Transitions]] - **μ°Έμ‘° λ§₯락:** Referenced whenever a hover hint or extra-information popup is needed on a UI element. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Tooltips β€” https://www.w3schools.com/css/css_tooltip.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Tooltips" page (Astra wiki-curation, P-Reinforce v3.1 format).