---
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 ``. [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: `
