9609c04755
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>
123 lines
4.8 KiB
Markdown
123 lines
4.8 KiB
Markdown
---
|
|
id: css-add-external
|
|
title: "CSS Add External"
|
|
category: "Frontend"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["external CSS", "external style sheet", "link stylesheet", "mystyle.css", "how to add CSS"]
|
|
duplicate_of: ""
|
|
source_trust_level: "B"
|
|
confidence_score: 0.9
|
|
created_at: 2026-06-23
|
|
updated_at: 2026-06-23
|
|
review_reason: ""
|
|
merge_history: []
|
|
tags: ["css", "web", "frontend", "w3schools", "stylesheet"]
|
|
raw_sources: ["https://www.w3schools.com/css/css_howto.asp"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[CSS Add External]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
There are three ways to insert CSS — external, internal, and inline; an external style sheet lets you change the look of an entire website by editing just one `.css` file, referenced from each page via a `<link>` element in the head. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **Three ways to insert CSS** — External CSS (link to an external `.css` file), Internal CSS (use the `<style>` element in the head section), and Inline CSS (use the `style` attribute on HTML elements). [S1]
|
|
- **External CSS power** — with an external style sheet, you can change the look of an entire website by changing just one file. [S1]
|
|
- **Reference mechanism** — each HTML page must include a reference to the external style sheet file inside the `<link>` element, inside the head section. [S1]
|
|
- **No space before units** — do not add a space between the property value and the unit (e.g. `20px`, not `20 px`). [S1]
|
|
|
|
## 🧩 추출된 패턴 (Extracted patterns)
|
|
- **Single source of truth** — one external `.css` file linked from many pages centralizes site-wide styling. [S1]
|
|
- **Head linkage** — `<link rel="stylesheet" href="…css">` inside `<head>` connects a page to its stylesheet. [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
CSS can be added to HTML documents in 3 ways: [S1]
|
|
1. **External CSS** — link to an external `.css` file.
|
|
2. **Internal CSS** — use the `<style>` element in the head section.
|
|
3. **Inline CSS** — use the `style` attribute on HTML elements.
|
|
|
|
**External CSS** — with an external style sheet, you can change the look of an entire website by changing just one file! Each HTML page must include a reference to the external style sheet file inside the `<link>` element, inside the head section. [S1]
|
|
|
|
```html
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="mystyle.css">
|
|
</head>
|
|
<body>
|
|
<h1>This is a heading</h1>
|
|
<p>This is a paragraph.</p>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
An external style sheet can be written in any text editor and must be saved with a `.css` extension. The external `.css` file (`mystyle.css`) should not contain any HTML tags — it holds only style rules: [S1]
|
|
```css
|
|
body {
|
|
background-color: lightblue;
|
|
}
|
|
|
|
h1 {
|
|
color: navy;
|
|
margin-left: 20px;
|
|
}
|
|
```
|
|
|
|
**Note:** Do not add a space between the property value and the unit. [S1]
|
|
- Incorrect (space): `margin-left: 20 px;`
|
|
- Correct (no space): `margin-left: 20px;`
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
The page's own example links an HTML page to `mystyle.css`, which styles `body` and `h1`. No external project/commit applications found in the source.
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Linking an external stylesheet from the head (language: HTML):
|
|
```html
|
|
<head>
|
|
<link rel="stylesheet" href="mystyle.css">
|
|
</head>
|
|
```
|
|
The external stylesheet file (language: CSS):
|
|
```css
|
|
body {
|
|
background-color: lightblue;
|
|
}
|
|
|
|
h1 {
|
|
color: navy;
|
|
margin-left: 20px;
|
|
}
|
|
```
|
|
|
|
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
|
| Method | How it is added | Best use |
|
|
| --- | --- | --- |
|
|
| External CSS | `<link>` to a `.css` file in `<head>` | Change an entire website's look by editing one file [S1] |
|
|
| Internal CSS | `<style>` element in the head section | A single HTML page with a unique style [S1] |
|
|
| Inline CSS | `style` attribute on an HTML element | A unique style for a single element [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.9
|
|
- **중복 검사 결과:** 신규 생성 (New discovery)
|
|
|
|
## 🔗 지식 그래프 (Knowledge Graph)
|
|
- **상위/루트:** [[CSS Tutorial]]
|
|
- **관련 개념:** [[CSS Add Internal]], [[CSS Add Inline]], [[CSS Multiple Style Sheets]]
|
|
- **참조 맥락:** Referenced when connecting an HTML page to a centralized, site-wide stylesheet.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — CSS Add External — https://www.w3schools.com/css/css_howto.asp
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Add External" page (Astra wiki-curation, P-Reinforce v3.1 format).
|