Skip to content

Radio Button Tabs Without JavaScript

Accessible CSS-only tabs built from radio inputs and the :checked selector, with a sliding pill indicator and fading panels. No JavaScript.

Also known as: tabs without javascript, radio button tabs, radio input tabs, no script tab panels, tab panels with sliding indicator

Pure CSS Tabs Responsive Dark #css-only #dark #no-javascript #radio #tabs

Radio Button Tabs Without JavaScript live demo

Open in new tab

Pure CSS code (HTML, CSS)

Tabs built entirely with HTML and CSS: hidden radio inputs, their labels and the :checked selector switch the panels, and a pill indicator slides to the active tab. No JavaScript is involved, which makes it a good fit for product details, settings pages, static sites and email-safe prototypes.

How it works

The root div.rtb-tabs starts with four input.rtb-input radios that share one name. They come before the .rtb-bar and .rtb-panels, so the general sibling selector ~ can reach both. Each label.rtb-tab is tied to its radio with for, so clicking a label checks the radio. The radios are visually hidden with opacity: 0 but stay in the tab order.

The numbered modifier classes do the matching: .rtb-input--2:checked ~ .rtb-panels .rtb-panel--2 shows the second panel, and every other .rtb-panel stays at display: none. The same pattern sets --rtb-index on .rtb-bar, and .rtb-indicator moves with translateX(calc(var(--rtb-index) * 100%)), so the accent pill glides under the checked label. Because the selectors use classes rather than IDs, you can repeat the component on one page; only the name, id and for values must be unique per instance. Panels fade in with a short keyframe animation.

The demo panels show the kinds of content tabs usually hold: stat tiles (.rtb-stats), a check list (.rtb-checks), a definition list (.rtb-specs) and numbered steps (.rtb-steps).

Customization

  • --rtb-accent and --rtb-on-accent on .rtb-tabs: the indicator color and the text color on top of it; the accent is reused for stats, checks and step numbers.
  • --rtb-bg and --rtb-surface: card background and tab bar background.
  • --rtb-count: the number of tabs. To add a fifth tab, set it to 5, add rtb-input--5, rtb-tab--5 and rtb-panel--5, and copy the --5 lines in the :checked, --rtb-index and :focus-visible rules.
  • Add checked to a different radio to open another tab on load.
  • --rtb-speed: duration of the indicator slide and the panel fade.
  • min-height on .rtb-panels: keeps the card height steady when panels have different lengths; lower it or remove it for content-sized panels.

Use cases

  • Documentation pages: readers switch between sections with tabs that need no scripts
  • Pricing and feature comparisons: a sliding pill indicator highlights the active tab
  • Static sites: panels fade in using only radio inputs and the :checked selector
  • Lightweight pages: accessible tabs work where JavaScript is disabled or restricted

Accessibility

Because the controls are real radio buttons, screen readers announce them as a group of options ("Overview, radio button, 1 of 4") inside the labelled role="group", and the native keyboard model applies: Tab moves into the group and the arrow keys switch tabs. A white ring is drawn around the label of a focused radio with :focus-visible. Each panel is a section with aria-labelledby pointing to its label, and hidden panels use display: none, so they are skipped by assistive technology. Icons are aria-hidden. With prefers-reduced-motion: reduce the slide and fade are turned off.

Usage notes

This is not the ARIA tabs pattern (role="tablist"), which needs JavaScript for focus management; radio semantics are the honest choice for a CSS-only version.

Radio Button Tabs Without JavaScript at a glance

Framework
Pure CSS
Code
HTML, CSS
JavaScript
Not needed, CSS only
Dependencies
None
Layout
Responsive, works on mobile, dark design
Category
Tabs
License
Free for personal and commercial use

Questions about this template

Can I use the Radio Button Tabs Without JavaScript code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear and add the CSS to your stylesheet. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. It is built with HTML and CSS only, so there is no JavaScript to load.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Radio Button Tabs Without JavaScript – free Pure CSS tabs template
Radio Button Tabs Without JavaScript · free Pure CSS tabs template

More Tabs

Scrollable Tabs for Mobile – free Bootstrap 5 tabs template

Scrollable Tabs for Mobile

Bootstrap 5 tabs that scroll horizontally on small screens, with fade edges, arrow buttons, scroll snapping and the active tab centered automatically.

Tabs with Photo Preview Panels – free Tailwind CSS tabs template

Tabs with Photo Preview Panels

Tailwind CSS feature tabs that swap a large photo preview with a caption for each selected tab, with full keyboard support.

Animated Pill Tabs – free Pure CSS tabs template

Animated Pill Tabs

Segmented pill tabs with a sliding, springy background, ARIA tabs keyboard support and fading panels, shown on an analytics card. Pure CSS and vanilla JS.

Vertical Tabs – free Bootstrap 5 tabs template

Vertical Tabs

Bootstrap 5 vertical nav-pills tabs styled as a settings panel with a dark sidebar, icons, fading content panes and a scrollable mobile tab strip.

Underline Tabs – free Tailwind CSS tabs template

Underline Tabs

Accessible Tailwind CSS tabs with a sliding underline indicator, arrow-key and Home/End navigation, count badge and scrollable tab bar on mobile.