docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)

W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더).
- Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외)
- Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체)
- Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속)
각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-23 19:21:18 +09:00
parent 8957890d13
commit 9609c04755
379 changed files with 54618 additions and 6 deletions
@@ -0,0 +1,97 @@
---
id: css-specificity-hierarchy
title: "CSS Specificity Hierarchy"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["specificity hierarchy", "specificity weight", "specificity X-Y-Z", "selector ranking", "specificity calculation"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.86
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["css", "web", "frontend", "w3schools", "specificity", "selectors", "cascade"]
raw_sources: ["https://www.w3schools.com/css/css_specificity_hierarchy.asp"]
applied_in: []
github_commit: ""
---
# [[CSS Specificity Hierarchy]]
## 🎯 한 줄 통찰 (One-line insight)
Every selector earns a three-number weight (X-Y-Z) counting ID, class/attribute/pseudo-class, and element/pseudo-element selectors — the higher leftmost number wins, deciding which rule applies. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Four ranked categories** — from highest to lowest the hierarchy is: inline styles, ID selectors, classes/attributes/pseudo-classes, and elements/pseudo-elements. [S1]
- **Three-digit weight notation (X-Y-Z)** — X counts ID selectors, Y counts class, attribute, and pseudo-class selectors, and Z counts element and pseudo-element selectors. [S1]
- **Leftmost-number-wins comparison** — the selector with the higher leftmost number wins; if those are equal, compare the next number, and so on. [S1]
- **Universal selector contributes nothing** — the universal selector (`*`) and `:where()` add no specificity weight. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **Count-then-compare pattern** — to resolve a conflict, count each selector's ID/class/element selectors into X-Y-Z, then compare position by position from the left. [S1]
- **Compound selectors stack weight** — combining selector types (e.g. `p#demo`) adds their individual weights together (1-0-0 + 0-0-1 = 1-0-1). [S1]
## 📖 세부 내용 (Details)
**Hierarchy of selector categories.** Specificity ranks selector types as follows (highest priority first) [S1]:
| Rank (high → low) | Selector category |
| --- | --- |
| 1 (highest) | Inline styles |
| 2 | ID selectors |
| 3 | Classes, attributes, and pseudo-classes |
| 4 | Elements and pseudo-elements |
| 5 (lowest) | Universal selector and `:where()` |
**Weight notation (X-Y-Z).** Specificity is written as a three-number value where [S1]:
- **X** = the count of ID selectors,
- **Y** = the count of class selectors, attribute selectors, and pseudo-classes,
- **Z** = the count of element selectors and pseudo-elements.
The selector with the higher leftmost number wins; if equal, the next number is compared, and so on. [S1]
**Example — competing selectors with computed weights.** The page demonstrates the weights of several selectors targeting the same element. The compound selector `p#demo` (weight 1-0-1) beats the bare `#demo` (weight 1-0-0) because, with the ID counts tied at 1, its element count breaks the tie. [S1]
```css
#demo {color: blue;} /* weight: 1-0-0 */
p#demo {color: orange;} /* weight: 1-0-1 WINS! */
.test {color: green;} /* weight: 0-1-0 */
p.test {color: green;} /* weight: 0-1-1 */
p {color: red;} /* weight: 0-0-1 */
```
**Tie-breaking rules noted on the page.** When specificity is equal, later rules win; ID selectors beat attribute selectors; and class selectors beat element selectors. [S1]
## 🛠️ 적용 사례 (Applied in summary)
The weight-annotated example above is the page's applied demonstration: each selector is labeled with its X-Y-Z weight so the reader can see exactly why `p#demo` (1-0-1) wins over the others. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Annotating selectors with their specificity weight (language: CSS):
```css
#demo {color: blue;} /* 1-0-0 */
p#demo {color: orange;} /* 1-0-1 — wins: ID tied, element breaks the tie */
.test {color: green;} /* 0-1-0 */
p {color: red;} /* 0-0-1 */
```
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source.
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.86
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[CSS Tutorial]]
- **관련 개념:** [[CSS Specificity]], [[CSS !important]], [[CSS Selectors]]
- **참조 맥락:** Used to compute and compare selector weights when diagnosing why a particular CSS rule does or does not apply.
## 📚 출처 (Sources)
- [S1] W3Schools — CSS Specificity Hierarchy — https://www.w3schools.com/css/css_specificity_hierarchy.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Specificity Hierarchy" page (Astra wiki-curation, P-Reinforce v3.1 format).