Concepts 🚀 Project 🧮 Labs
🧮 Labs / CSS / Tabs — switch between panels

Tabs — switch between panels

Tab navigation that switches content panels. Pure CSS using :target or radio inputs (no JS needed for basic tabs).

style.css v3.1
style.css — the CSS rules
index.html — the HTML structure (what the CSS targets)
Live preview updates as you type
🧠 How it works

The .tabs container has a bottom border — the 'tab bar'. Each .tab is a <button> with: transparent background, bottom border that's invisible until active. margin-bottom: -2px — the tab's bottom border overlaps the tab bar's border (so the active tab 'connects'). Active tab: colored bottom border + colored text + bold. Tab panels: display: none by default, display: block when .active. The onclick JS just toggles .active classes — the CSS handles the visual switching. In a real app, you'd use addEventListener instead of inline onclick, but the CSS is the same.

✏️ Try these changes
  • Change border-bottom: 3px to 5px on .tab.active
    → thicker active indicator
  • Change the active color from #a0c000 to #58a6ff
    → tabs become blue
  • Change .tab font-size from 0.92rem to 1.1rem
    → bigger tab labels
  • Add border-radius: 6px 6px 0 0 to .tab
    → tabs get rounded top corners