docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
@@ -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).
|
||||
Reference in New Issue
Block a user