---
id: w3css-slideshow
title: "W3CSS Slideshow"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["carousel", "mySlides", "w3-display-container", "W3.CSS 슬라이드쇼"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.87
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["w3css", "css-framework", "w3schools", "slideshow", "carousel"]
raw_sources: ["https://www.w3schools.com/w3css/w3css_slideshow.asp"]
applied_in: []
github_commit: ""
---

# [[W3CSS Slideshow]]

## 🎯 한 줄 통찰 (One-line insight)
The manual and automatic slideshow share IDENTICAL slide-hiding logic — the only real difference is WHAT triggers the index change: `plusDivs()` called by a button click (manual) versus `setTimeout(carousel, 2000)` recursively calling itself (automatic) — meaning a "carousel" is simply a slideshow whose advance function schedules its own next call instead of waiting for user input. [S1]

## 🧠 핵심 개념 (Core concepts)
- **Shared-class slides** — every slide element uses the same class (`mySlides`), just like the Tabulators pattern; JS hides all, then shows one by index. [S1]
- **`slideIndex` wraparound** — manual version resets to 1 if the index exceeds slide count, or to the last slide if it goes below 1, allowing infinite forward/backward cycling. [S1]
- **Automatic carousel** — `carousel()` calls itself via `setTimeout(carousel, 2000)` at the end of its own execution, creating a self-perpetuating timer loop (distinct from `setInterval`, which the Progress Bar chapter used instead). [S1]
- **HTML slides, not just images** — slides can be any HTML content (styled divs with text), not restricted to `<img>`. [S1]
- **Caption + indicator overlays** — reuse `w3-display-container`/`w3-display-bottomleft` (from the Display chapter) for captions, and clickable `w3-badge` or numbered buttons as slide indicators via a `currentDiv(n)` function. [S1]
- **Multiple independent slideshows per page** — achieved simply by giving each slideshow group a UNIQUE class name (`mySlides1`, `mySlides2`) so their JS loops don't interfere. [S1]

## 📖 세부 내용 (Details)
- Manual slideshow core logic: `function showDivs(n) { var i; var x = document.getElementsByClassName("mySlides"); if (n > x.length) {slideIndex = 1} if (n < 1) {slideIndex = x.length}; for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } x[slideIndex-1].style.display = "block"; }`. [S1]
- Automatic carousel (self-scheduling timer): `function carousel() { ...hide all...; slideIndex++; if (slideIndex > x.length) {slideIndex = 1} x[slideIndex-1].style.display = "block"; setTimeout(carousel, 2000); }`. [S1]
- Caption overlay: `<div class="w3-display-container mySlides"><img src="img_snowtops.jpg" style="width:100%"><div class="w3-display-bottomleft w3-container w3-padding-16 w3-black">French Alps</div></div>`. [S1]
- Independent multi-slideshow class separation: `mySlides1` for one group, `mySlides2` for another, entirely separate `getElementsByClassName` calls. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **setTimeout 재귀 호출 vs setInterval**: 자동 슬라이드쇼는 setInterval이 아니라 carousel() 함수가 자기 자신을 setTimeout으로 다시 예약하는 재귀적 방식이라는 점이 프로그레스 바 챕터의 setInterval 방식과 대비됨. [S1]

## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 모달 챕터에서 언급된 "라이트박스(Lightbox)" 패턴이 슬라이드쇼를 모달 안에 내장하는 실전 조합 사례로 예고됨. [S1]

## 💻 코드 패턴 (Code patterns)
Self-scheduling automatic carousel using setTimeout recursion (JavaScript):
```javascript
var slideIndex = 0;
carousel();
function carousel() {
  var i;
  var x = document.getElementsByClassName("mySlides");
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
  }
  slideIndex++;
  if (slideIndex > x.length) {slideIndex = 1}
  x[slideIndex-1].style.display = "block";
  setTimeout(carousel, 2000); // Change image every 2 seconds
}
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.87
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[W3.CSS Tutorial]]
- **관련 개념:** [[W3CSS Progress Bar]], [[W3CSS Tabulators]], [[W3CSS Modal]]
- **참조 맥락:** 타이머 기반 동적 UI의 두 번째 사례 — 모달(Modal) 챕터에서 라이트박스 조합으로 재등장.

## 📚 출처 (Sources)
- [S1] W3Schools — W3.CSS Slideshow — https://www.w3schools.com/w3css/w3css_slideshow.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "W3.CSS Slideshow" page (Astra wiki-curation, P-Reinforce v3.1 format).
