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>
6.5 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| css-selectors | CSS Selectors | Frontend | draft | conceptual |
|
B | 0.89 | 2026-06-23 | 2026-06-23 |
|
|
CSS Selectors
🎯 한 줄 통찰 (One-line insight)
CSS selectors are used to "find" (select) the HTML elements you want to style, ranging from simple selectors that match by name, id, or class to combinator, pseudo-class, pseudo-element, and attribute selectors. [S1]
🧠 핵심 개념 (Core concepts)
- Purpose — a CSS selector selects the HTML element(s) you want to style. [S1]
- Five categories — Simple selectors (by name, id, class), Combinator selectors, Pseudo-class selectors, Pseudo-elements selectors, and Attribute selectors. [S1]
- Element selector — selects elements based on the element name (e.g.
p). [S1] - id selector — uses the
#character plus the id of a specific element; an id is unique within a page. [S1] - class selector — uses a
.followed by a class name; multiple elements can share a class. [S1] - Naming rule — an id name cannot start with a number, and a class name cannot start with a number. [S1]
🧩 추출된 패턴 (Extracted patterns)
- By type —
element { ... }styles all elements of that tag. [S1] - By id —
#id { ... }styles the one element with that id. [S1] - By class —
.class { ... }styles every element carrying that class. [S1] - Type + class scoping —
element.class { ... }styles only those elements of a type that also carry the class. [S1] - Multiple classes — an element can reference more than one class at once via a space-separated
classattribute. [S1]
📖 세부 내용 (Details)
A CSS selector is used to find (select) the HTML elements you want to style. CSS selectors divide into five categories: Simple selectors (select elements based on name, id, class), Combinator selectors, Pseudo-class selectors, Pseudo-elements selectors, and Attribute selectors. [S1]
The CSS element selector selects HTML elements based on the element name. [S1]
p {
text-align: center;
color: red;
}
The CSS id selector uses the id attribute of an HTML element to select a specific element. The id of an element is unique within a page, so it selects one unique element. To select an element with a specific id, write a hash (#) character followed by the id of the element. [S1]
#para1 {
text-align: center;
color: red;
}
Note: an id name cannot start with a number! [S1]
The CSS class selector selects HTML elements with a specific class attribute. To select elements with a specific class, write a period (.) character followed by the class name. [S1]
.center {
text-align: center;
color: red;
}
You can also specify that only specific HTML elements should be affected by a class. In this example only <p> elements with class="center" will be center-aligned and red: [S1]
p.center {
text-align: center;
color: red;
}
HTML elements can also refer to more than one class: [S1]
<p class="center large">This paragraph refers to two classes.</p>
Note: a class name cannot start with a number! [S1]
The CSS universal selector (*) selects all HTML elements on the page. [S1]
* {
text-align: center;
color: blue;
}
The CSS grouping selector selects all the HTML elements with the same style definitions. To group selectors, separate each selector with a comma. [S1]
h1, h2, p {
text-align: center;
color: red;
}
All CSS Simple Selectors [S1]
| Selector | Example | Example description |
|---|---|---|
#id |
#firstname |
Selects the element with id="firstname" |
.class |
.intro |
Selects all elements with class="intro" |
element.class |
p.intro |
Selects only <p> elements with class="intro" |
* |
* |
Selects all elements |
element |
p |
Selects all <p> elements |
element,element,.. |
div, p |
Selects all <div> elements and all <p> elements |
🛠️ 적용 사례 (Applied in summary)
The page's own examples apply each selector type to style headings and paragraphs (element, id, class, type+class, universal, and grouping). No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Selecting by id and by class (language: CSS):
#para1 {
text-align: center;
color: red;
}
.center {
text-align: center;
color: red;
}
Scoping a class to a specific element type:
p.center {
text-align: center;
color: red;
}
⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
| Selector | When to use | Scope |
|---|---|---|
element (e.g. p) |
Style every element of a tag uniformly | All elements of that type [S1] |
#id (e.g. #para1) |
Style one unique element | A single element (id is unique per page) [S1] |
.class (e.g. .center) |
Reuse a style across many elements | All elements carrying that class [S1] |
element.class (e.g. p.center) |
Reuse a class but limit it to one tag | Only that element type with the class [S1] |
* |
Apply a baseline to everything | All elements on the page [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.89
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: CSS Tutorial
- 관련 개념: CSS Syntax, CSS Grouping Selectors, CSS Introduction
- 참조 맥락: Referenced whenever deciding how to target HTML elements for styling.
📚 출처 (Sources)
- [S1] W3Schools — CSS Selectors — https://www.w3schools.com/css/css_selectors.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Selectors" page (Astra wiki-curation, P-Reinforce v3.1 format).