--- id: css-z-index title: "CSS Z-index" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["z-index", "stack order", "stacking order", "CSS z index", "layer order", "stacking context"] 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", "position", "z-index"] raw_sources: ["https://www.w3schools.com/css/css_z-index.asp"] applied_in: [] github_commit: "" --- # [[CSS Z-index]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The `z-index` property sets the stack order of positioned elements β€” higher values render in front of lower ones β€” and it only works on positioned elements and flex items. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **stack order** β€” `z-index` specifies the stack order of positioned elements, determining which elements appear in front of or behind others. [S1] - **positive or negative** β€” elements can have positive or negative z-index values. [S1] - **higher wins** β€” higher z-index values always appear above lower ones. [S1] - **only on positioned elements** β€” z-index only works on positioned elements (`position: absolute`, `position: relative`, `position: fixed`, or `position: sticky`) and flex items. [S1] - **default order** β€” without a z-index, elements render in HTML source order. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Send behind with negative z-index** β€” give an absolutely positioned element `z-index: -1` to render it behind text/content. [S1] - **Explicit layering** β€” assign ascending z-index values to sibling boxes to control which overlaps which, independent of source order. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **CSS The z-index Property** [S1] `z-index` specifies the stack order of positioned elements, determining which elements appear in front or behind others. Elements can have positive or negative z-index values. **Note:** z-index only works on positioned elements (`position: absolute`, `position: relative`, `position: fixed`, or `position: sticky`) and flex items. [S1] **First example β€” negative z-index puts an image behind text** [S1] The CSS rule uses `position: absolute`, `left: 0px`, `top: 0px`, and `z-index: -1`. The HTML includes a heading "This is a heading". The image with z-index of -1 renders behind the text. The page did not provide the full verbatim CSS rule block β€” Not found in source. **Second example β€” higher z-index appears above lower** [S1] CSS classes defined: - `.container` with `position: relative` - `.black-box` with `z-index: 1`, plus border and margins - `.gray-box` with `z-index: 3`, light gray background - `.green-box` with `z-index: 2`, light green background HTML structure: a container div holding three nested divs representing the three boxes. The gray box (z-index 3) sits on top, then green (2), then black (1). The full verbatim CSS/HTML block was not provided in the fetched source β€” Not found in source. **Third example β€” rendering order without z-index** [S1] Code identical to the second example but omitting all z-index declarations, showing that elements render in HTML source order. **Property reference** [S1] | Property | Description | |----------|-------------| | z-index | Sets the stack order of an element | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's applied examples are: an image sent behind a heading via `z-index: -1`; three overlapping boxes layered by ascending z-index (gray 3 on top, green 2, black 1); and the same three boxes without z-index to show default source-order stacking. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Send a positioned element behind content (language: CSS): ```css img { position: absolute; left: 0px; top: 0px; z-index: -1; } ``` Layer sibling boxes by explicit stack order (language: CSS): ```css .container { position: relative; } .black-box { z-index: 1; } .green-box { z-index: 2; } .gray-box { z-index: 3; } ``` Note: the page described these declarations but did not present the complete rule blocks verbatim; the snippets above reflect the described properties β€” additional rule details Not found in source. [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 Position Fixed and Absolute]], [[CSS Position Sticky]], [[CSS Position Offsets]] - **μ°Έμ‘° λ§₯락:** Referenced whenever positioned elements overlap and their front-to-back order must be controlled. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Z-index β€” https://www.w3schools.com/css/css_z-index.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Z-index" page (Astra wiki-curation, P-Reinforce v3.1 format).