docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)

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>
This commit is contained in:
2026-06-23 19:21:18 +09:00
parent 8957890d13
commit 9609c04755
379 changed files with 54618 additions and 6 deletions
+177
View File
@@ -0,0 +1,177 @@
---
id: css-image-sprites
title: "CSS Image Sprites"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["image sprite", "sprite image", "CSS sprites", "background-position sprite", "navigation sprite"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.89
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["css", "web", "frontend", "w3schools", "sprites", "background-position", "performance"]
raw_sources: ["https://www.w3schools.com/css/css_image_sprites.asp"]
applied_in: []
github_commit: ""
---
# [[CSS Image Sprites]]
## 🎯 한 줄 통찰 (One-line insight)
An image sprite packs many small images into one file, then uses `background-image` plus `background-position` offsets to display just the needed slice — cutting server requests and eliminating hover-load delay. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Image sprite** — a collection of various small images put into one larger image file, called a "sprite image." [S1]
- **Why sprites** — using a single sprite reduces the number of server requests and saves bandwidth versus loading many separate images. [S1]
- **Two key properties** — sprites are implemented with `background-image` (the sprite file) and `background-position` (which slice to show). [S1]
- **Transparent placeholder** — a tiny transparent image (`img_trans.gif`, `1×1`) can act as the element while CSS controls which part of the sprite is visible. [S1]
- **Hover without extra loads** — hover effects shift `background-position` (e.g. `45px` down) to a different region of the sprite, so no additional image needs to load. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **Slice selection** — fix an element's `width`/`height` to one icon's size and use a negative `background-position` to scroll the sprite so only that icon shows. [S1]
- **Shorthand background** — combine file and position in one `background: url('sprite.gif') -47px 0;` declaration. [S1]
- **Hover row swap** — keep horizontal offset, change the vertical offset on `:hover` to reveal a second row of the sprite for interactive feedback. [S1]
## 📖 세부 내용 (Details)
**What is an image sprite?**
An image sprite is a collection of various small images put into one larger image file, called a "sprite image." This approach reduces the number of server requests and saves bandwidth. Sprites are implemented with the `background-image` and `background-position` properties. [S1]
**Example 1 — Basic Image Sprites**
Three elements (`#home`, `#prev`, `#next`) each set their own `width`/`height` and reference the same `img_navsprites.gif`, differing only by `background-position` so each shows a different icon. Transparent `1×1` images serve as the element bodies: [S1]
```html
<html>
<head>
<style>
#home {
width: 46px;
height: 44px;
background-image: url(img_navsprites.gif);
background-position: 0 0;
}
#prev {
width: 43px;
height: 44px;
background-image: url('img_navsprites.gif');
background-position: -47px 0;
}
#next {
width: 43px;
height: 44px;
background-image: url('img_navsprites.gif');
background-position: -91px 0;
}
</style>
</head>
<body>
<img id="home" src="img_trans.gif" width="1" height="1">
<img id="prev" src="img_trans.gif" width="1" height="1">
<img id="next" src="img_trans.gif" width="1" height="1">
</body>
</html>
```
**Example 2 — Navigation List**
The sprite is applied to a navigation list (`<ul>`/`<li>`). The list uses relative/absolute positioning to lay items out horizontally, with each item's `left` offset and `background` shorthand isolating its icon from the sprite: [S1]
```css
#navlist {
position: relative;
}
#navlist li {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
top: 0;
}
#navlist li, #navlist a {
height: 44px;
display: block;
}
#home {
left: 0px;
width: 46px;
background: url('img_navsprites.gif') 0 0;
}
#prev {
left: 60px;
width: 43px;
background: url('img_navsprites.gif') -47px 0;
}
#next {
left: 120px;
width: 43px;
background: url('img_navsprites.gif') -91px 0;
}
```
**Example 3 — Hover Effect**
Adds interactivity by shifting `background-position` 45px down (to a hover row of `img_navsprites_hover.gif`) on `:hover`. Because all images preload in one file, there is no loading delay on hover: [S1]
```css
#home a:hover {
background: url('img_navsprites_hover.gif') 0 -45px;
}
#prev a:hover {
background: url('img_navsprites_hover.gif') -47px -45px;
}
#next a:hover {
background: url('img_navsprites_hover.gif') -91px -45px;
}
```
**Advantages highlighted:** a single server request instead of multiple image downloads; reduced bandwidth consumption; and no loading delay on hover effects since all images preload in one file. [S1]
## 🛠️ 적용 사례 (Applied in summary)
The page's three examples — basic sprite slices, a positioned navigation list, and a hover row swap — are the applied demonstrations. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Display one slice of a sprite (language: CSS):
```css
#prev {
width: 43px;
height: 44px;
background-image: url('img_navsprites.gif');
background-position: -47px 0;
}
```
Hover row swap with the background shorthand (language: CSS):
```css
#prev a:hover {
background: url('img_navsprites_hover.gif') -47px -45px;
}
```
## ⚖️ 모순 및 업데이트 (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 Backgrounds]], [[CSS Position]], [[CSS Image Gallery]]
- **참조 맥락:** Referenced when optimizing icon/asset delivery by consolidating many images into one file with positioned background slices.
## 📚 출처 (Sources)
- [S1] W3Schools — CSS Image Sprites — https://www.w3schools.com/css/css_image_sprites.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Image Sprites" page (Astra wiki-curation, P-Reinforce v3.1 format).