--- id: css-advanced-attribute-selectors title: "CSS Advanced Attribute Selectors" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["advanced attribute selector", "[attribute^=value]", "[attribute$=value]", "[attribute*=value]", "substring attribute selector"] 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", "selectors", "attributes"] raw_sources: ["https://www.w3schools.com/css/css_attribute_selectors_advanced.asp"] applied_in: [] github_commit: "" --- # [[CSS Advanced Attribute Selectors]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The advanced attribute selectors match by substring position β€” `^=` for values that start with, `$=` for values that end with, and `*=` for values that contain a string β€” and combine with `input[type=...]` to style form controls. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`[attribute^="value"]`** β€” selects elements with the specific attribute whose value **starts with** a specific value. [S1] - **`[attribute$="value"]`** β€” selects elements whose attribute value **ends with** a specific value. [S1] - **`[attribute*="value"]`** β€” selects elements whose attribute value **contains** a specific value (substring, anywhere). [S1] - **Form styling use** β€” attribute selectors are commonly used to style form elements by their `type`, e.g. `input[type="text"]` and `input[type="button"]`. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Prefix match** β€” `^=` targets values beginning with a token (e.g. class names that start with `top`). [S1] - **Suffix match** β€” `$=` targets values ending with a token (e.g. class names ending in `test`, or file extensions). [S1] - **Substring match** β€” `*=` targets any value containing the token, the most permissive of the three. [S1] - **Type-based form styling** β€” drive distinct styles for text vs. button inputs purely from their `type` attribute. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **`[attribute^="value"]` selector** The `[attribute^="value"]` selector is used to select elements with the specific attribute whose value **starts with** a specific value. The following selects elements whose class starts with "top": [S1] ```css [class^="top"] { background: yellow; } ``` **`[attribute$="value"]` selector** The `[attribute$="value"]` selector is used to select elements whose attribute value **ends with** a specific value. The following selects elements whose class ends with "test": [S1] ```css [class$="test"] { background: yellow; } ``` **`[attribute*="value"]` selector** The `[attribute*="value"]` selector is used to select elements whose attribute value **contains** a specific value. The following selects elements whose class contains "te": [S1] ```css [class*="te"] { background: yellow; } ``` **Styling Forms With Attribute Selectors** Attribute selectors can style form controls by their `type`. The following styles text inputs and button inputs differently: [S1] ```css input[type="text"] { width: 150px; padding: 6px; margin-bottom: 10px; background-color: pink; } input[type="button"] { width: 100px; padding: 6px; background-color: lightgreen; } ``` > Note: The full HTML markup for the form example is not shown in the fetched source β€” "Not found in source." ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's examples demonstrate the three substring selectors on `class` values and applying type-based attribute selectors to style form inputs. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) The three substring attribute-selector forms (language: CSS): ```css [class^="top"] { background: yellow; } /* starts with */ [class$="test"] { background: yellow; } /* ends with */ [class*="te"] { background: yellow; } /* contains */ ``` Type-based form styling (language: CSS): ```css input[type="text"] { width: 150px; padding: 6px; margin-bottom: 10px; background-color: pink; } input[type="button"] { width: 100px; padding: 6px; background-color: lightgreen; } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **`^=` (starts with)** β€” use when matching a known prefix, e.g. a naming convention where related classes begin with the same token. [S1] - **`$=` (ends with)** β€” use when matching a known suffix, e.g. classes ending in `test`. [S1] - **`*=` (contains)** β€” use when the token may appear anywhere in the value; broadest match of the three. [S1] - **vs. basic selectors** β€” these substring forms complement the basic `[attribute]`, `=`, `~=`, and `|=` selectors documented in [[CSS Attribute Selectors]], adding positional substring matching that the basic set lacks. [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 Attribute Selectors]], [[CSS Selectors]], [[CSS Styling Forms]] - **μ°Έμ‘° λ§₯락:** Referenced when targeting elements by partial attribute values or styling form controls by their `type`. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Advanced Attribute Selectors β€” https://www.w3schools.com/css/css_attribute_selectors_advanced.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Advanced Attribute Selectors" page (Astra wiki-curation, P-Reinforce v3.1 format).