Files
2nd/10_Wiki/Topic_Programming/Topic_CSS/CSS_Selectors.md
T
Antigravity Agent e9cbf23ab5 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.
2026-07-05 00:39:13 +09:00

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
CSS selector
element selector
id selector
class selector
universal selector
simple selectors
B 0.89 2026-06-23 2026-06-23
css
web
frontend
w3schools
selectors
https://www.w3schools.com/css/css_selectors.asp

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 typeelement { ... } 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 scopingelement.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 class attribute. [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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "CSS Selectors" page (Astra wiki-curation, P-Reinforce v3.1 format).