Skip to content
DesignSeer

UI & Code Snippets41 min read

CSS Pricing Table: Free Copy-Paste Code, No JS (2026)

Copy a free CSS pricing table with subgrid-aligned rows, a featured plan and a no-JS monthly/yearly toggle built on :has(). Includes a Tailwind v4 version.

CSS Pricing Table Hero
On this page19 sections
  1. CSS pricing table template: copy-paste code (no JavaScript)
  2. More pricing table styles
  3. Anatomy of a pricing card that converts
  4. Aligning cards with CSS Grid and subgrid
  5. Responsive without breakpoint guesswork: container queries
  6. Monthly/yearly toggle: CSS-only and JS versions
  7. Highlighting the recommended plan
  8. Feature comparison tables
  9. Accessibility checklist for pricing tables
  10. Tailwind CSS pricing table version
  11. How the other resources were chosen
  12. CodyHouse Pricing Tables
  13. W3Schools: How To Create a Responsive Pricing Table
  14. Flowbite pricing blocks
  15. CodePen pricing-table pens
  16. Free pricing table resources compared
  17. Pricing UX: annual discounts, number of plans and badges
  18. Troubleshooting common pricing table bugs
  19. FAQ

CSS subgrid became Baseline Widely available on March 15, 2026, so a common pricing table bug (prices and buttons that won’t line up across cards) now has a native fix in every major browser. This page gives you a free, copy-paste CSS pricing table template with no JavaScript. It has aligned rows, a featured plan, a monthly/yearly toggle built on :has(), a layout driven by container queries, and four more styles built on the same base. You also get a Tailwind CSS v4 version and a comparison of the free resources that rank for this search, including what each one charges for.

Best forSaaS and product pricing
FormatHTML, CSS, Tailwind
PriceFree (November 2026)
LicenceCommercial use, no credit

Key takeaways

  • Use grid-template-rows: subgrid with grid-row: span 5 on each card so names, prices, features and buttons line up across plans.
  • A fieldset with two radios plus :has(#bill-yearly:checked) gives you a billing toggle that works from the keyboard, with no JS and no duplicate cards.
  • Put container-type: inline-size on the pricing section so the cards stack based on their own width. This also works in sidebars and page builders.
  • Use a real <table> with <caption> and <th scope> for feature comparisons, and add a sticky first column so feature names stay visible on phones.
  • “2 months free” is a 16.7% discount, which Recurly reports as the most common annual discount.

On this page

  • Get the code: copy-paste template, how to use it, more pricing table styles (dark, two-plan, single-plan, comparison-first)
  • Build details: card anatomy, subgrid alignment, container queries, the billing toggle, the featured plan, comparison tables
  • Accessibility: radio group vs switch, accessibility checklist
  • Tailwind: Tailwind CSS v4 version
  • Compare resources: CodyHouse, W3Schools, Flowbite, CodePen, comparison table
  • Pricing UX: annual discounts, number of plans, badges, troubleshooting, FAQ

CSS pricing table template: copy-paste code (no JavaScript)

The template is semantic HTML plus one stylesheet. You get three plans, rows that line up however long the copy is, a highlighted “Most popular” plan, a CSS-only monthly/yearly switch and a stacked layout on narrow screens. Each plan is an <article>, plan names are <h3> elements under one <h2>, feature lists are <ul> elements and every call to action is a real link.

The HTML

Each card holds its price as two short spans, one monthly and one yearly. You never have to keep two copies of a card in sync.

<section class="pricing" aria-labelledby="pricing-title">
  <h2 id="pricing-title">Pricing</h2>

  <fieldset class="billing">
    <legend class="visually-hidden">Billing period</legend>
    <input type="radio" id="bill-monthly" name="billing" value="monthly" checked>
    <label for="bill-monthly">Monthly</label>
    <input type="radio" id="bill-yearly" name="billing" value="yearly">
    <label for="bill-yearly">Yearly <span class="save">2 months free</span></label>
  </fieldset>

  <div class="plans">
    <article class="plan" aria-labelledby="plan-starter">
      <h3 id="plan-starter">Starter</h3>
      <p class="plan-desc">For freelancers running one or two client sites.</p>
      <p class="price">
        <span class="price-monthly">$12 <small>/ month</small></span>
        <span class="price-yearly">$120 <small>/ year, billed annually</small></span>
      </p>
      <ul class="features">
        <li>3 projects</li>
        <li>10 GB storage</li>
        <li>Email support</li>
      </ul>
      <a class="cta" href="/signup?plan=starter">Start with Starter</a>
    </article>

    <article class="plan" aria-labelledby="plan-pro">
      <p class="badge">Most popular</p>
      <h3 id="plan-pro">Pro</h3>
      <p class="plan-desc">For small studios shipping client work every month.</p>
      <p class="price">
        <span class="price-monthly">$29 <small>/ month</small></span>
        <span class="price-yearly">$290 <small>/ year, billed annually</small></span>
      </p>
      <ul class="features">
        <li>Unlimited projects</li>
        <li>Client review links</li>
        <li>100 GB storage</li>
        <li>Priority support</li>
      </ul>
      <a class="cta" href="/signup?plan=pro">Start Pro trial</a>
    </article>

    <article class="plan" aria-labelledby="plan-team">
      <h3 id="plan-team">Team</h3>
      <p class="plan-desc">For agencies that need roles and shared libraries.</p>
      <p class="price">
        <span class="price-monthly">$59 <small>/ month</small></span>
        <span class="price-yearly">$590 <small>/ year, billed annually</small></span>
      </p>
      <ul class="features">
        <li>Everything in Pro</li>
        <li>Up to 10 seats with roles</li>
        <li>Shared asset library</li>
        <li>1 TB storage</li>
        <li>SSO and audit log</li>
      </ul>
      <a class="cta" href="/signup?plan=team">Choose Team</a>
    </article>
  </div>
</section>

The CSS

The brand colours sit in custom properties at the top. Changing about five values restyles the whole component, and every variant further down works by overriding those same values.

.pricing {
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #4b5563;
  --line: #e5e7eb;
  container-type: inline-size;
  max-width: 72rem;
  margin-inline: auto;
  padding: 2rem 1rem;
  color: var(--ink);
  font-family: system-ui, sans-serif;
}

.pricing h2 { text-align: center; margin: 0 0 1rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Billing toggle: two real radios, both labels clickable */
.billing {
  display: flex; justify-content: center; gap: .25rem;
  margin: 0 auto 2.5rem; padding: .25rem; border: 1px solid var(--line);
  border-radius: 999px; width: fit-content;
}
.billing input { position: absolute; opacity: 0; }
.billing label {
  padding: .5rem 1.25rem; border-radius: 999px; cursor: pointer; font-weight: 600;
}
.billing input:checked + label { background: var(--brand); color: var(--brand-ink); }
.billing input:focus-visible + label { outline: 3px solid var(--brand); outline-offset: 2px; }
.save { font-size: .8125rem; font-weight: 500; }

/* Layout: stacked by default, three columns when the section is wide */
.plans { display: grid; gap: 2rem; }
@container (min-width: 52rem) {
  .plans { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
}

/* Each card borrows the parent's rows, so every row aligns across cards */
.plan {
  position: relative;
  display: grid;
  grid-row: span 5;
  grid-template-rows: subgrid;
  row-gap: .75rem;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.plan > * { margin: 0; }
.plan-desc { color: var(--muted); }

/* Price: both spans share one cell, so toggling never shifts layout */
.price { display: grid; font-size: 2.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price > span { grid-area: 1 / 1; }
.price small { font-size: .9rem; font-weight: 400; color: var(--muted); }
.price-yearly { visibility: hidden; }
.pricing:has(#bill-yearly:checked) .price-monthly { visibility: hidden; }
.pricing:has(#bill-yearly:checked) .price-yearly { visibility: visible; }

.features { list-style: none; padding: 0; display: grid; gap: .5rem; align-content: start; }
.features li { display: flex; gap: .6rem; align-items: baseline; }
.features li::before {
  content: ""; flex: none; width: .4rem; height: .8rem;
  border: solid var(--brand); border-width: 0 2px 2px 0; rotate: 45deg;
}

.cta {
  align-self: end; display: block; text-align: center; padding: .75rem 1rem;
  border: 2px solid var(--brand); border-radius: .5rem; color: var(--brand);
  font-weight: 600; text-decoration: none;
}
.cta:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Featured plan, detected by its badge */
.plan:has(.badge) { border: 2px solid var(--brand); box-shadow: 0 12px 32px rgb(79 70 229 / .18); }
.plan:has(.badge) .cta { background: var(--brand); color: var(--brand-ink); }
.badge {
  position: absolute; inset-block-start: 0; inset-inline-start: 50%; translate: -50% -50%;
  padding: .25rem .75rem; border-radius: 999px; background: var(--brand);
  color: var(--brand-ink); font-size: .8125rem; font-weight: 600; white-space: nowrap;
}

/* Fallback for browsers without subgrid */
@supports not (grid-template-rows: subgrid) {
  .plan { display: flex; flex-direction: column; gap: .75rem; }
  .features { flex: 1; }
  .cta { margin-top: auto; }
}

Try it in CodePen or as two files

How to use it

  1. Paste the HTML into CodePen’s HTML panel and the CSS into the CSS panel. No external resources are needed.
  2. Or save them as index.html and pricing.css, then link the stylesheet in the <head>.
  3. Change the five custom properties at the top of .pricing to your brand colours.
  4. Edit plan names, prices and features in the HTML. Keep five direct children per card, or update grid-row: span 5.
  5. Point each CTA href at your real signup or checkout URL.

The template is free for personal and client projects, including commercial ones, and you don’t need to credit anyone. It only uses CSS features that are part of Baseline, so you don’t need a framework, a build step or jQuery.

More pricing table styles

Each of the four styles below reuses the HTML and CSS above. You add one modifier class to <section class="pricing"> and paste a short override after the base stylesheet. Only the rules that change are shown, so you keep a single component with one set of fixes rather than five copies.

Style Modifier class Use it for What changes
Dark theme pricing--dark Dark landing pages, developer tools Six custom properties and the featured shadow
Two-plan layout pricing--two Free vs Pro, monthly vs lifetime Narrower section, two columns from 36rem
Horizontal single plan pricing--single One product, one price Card splits into a summary column and a feature column
Comparison-first pricing--compare B2B and feature-heavy products Slim plan headers, the feature table carries the detail

Dark theme

This style switches the palette for dark pages and keeps every text pair above 4.5:1. Indigo #4f46e5 is too dark to work as text on a dark surface, so the brand colour moves to the lighter #818cf8 and the button text becomes near-black.

Show the dark theme CSS
.pricing--dark {
  --brand: #818cf8;
  --brand-ink: #111827;
  --surface: #1e293b;
  --ink: #f1f5f9;
  --muted: #9ca3af;
  --line: #334155;
  background: #0f172a;
  border-radius: 1.5rem;
  color-scheme: dark;
}
.pricing--dark .plan:has(.badge) { box-shadow: 0 12px 32px rgb(129 140 248 / .25); }

By the WCAG relative-luminance formula, #818cf8 on the #1e293b card surface works out to roughly 4.9:1. Muted grey #9ca3af on the same surface comes to about 5.8:1. Both pass AA for body text.

Designer tip

To follow the visitor’s system setting rather than adding a class, paste the same custom properties into @media (prefers-color-scheme: dark) { .pricing { ... } }. The rest of the component picks them up on its own.

Two-plan layout

Two plans present a straight choice, usually free vs paid or monthly vs lifetime. Delete one <article>, add the modifier, and the cards go side by side from a 36rem container width. Because the section is capped at 52rem, the base three-column rule never fires.

Show the two-plan CSS
.pricing--two { max-width: 52rem; }
@container (min-width: 36rem) {
  .pricing--two .plans { grid-template-columns: repeat(2, 1fr); }
}

Put the badge on the plan you want most people to choose, which is nearly always the paid one. A free plan with a “Most popular” badge undercuts your own upgrade path.

Horizontal single-plan card

A single horizontal card suits products with one price, such as a course, a template bundle or a plugin licence. On wide containers, the name, description, price and button stack on the left and the feature list fills the right column. On phones it falls back to the normal stacked card.

Show the single-plan CSS
.pricing--single .plans { grid-template-columns: 1fr; max-width: 56rem; margin-inline: auto; }
@container (min-width: 48rem) {
  .pricing--single .plan {
    grid-row: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: repeat(4, auto);
    column-gap: 3rem;
    align-content: center;
  }
  .pricing--single .features { grid-column: 2; grid-row: 1 / -1; align-self: center; }
  .pricing--single .cta { justify-self: start; }
}

The card no longer needs subgrid because there’s nothing to align it with, so grid-row: auto replaces the five-row span. If a single plan has no annual option, remove the fieldset too. A toggle with one meaningful state is just noise.

Minimal comparison-first layout

The comparison-first style suits buyers who decide on features, not on headlines. Each card shrinks to a plan header (name, price, button) with a rule underneath, and the semantic feature table from the comparison section sits directly below it. Each card now has three children, so the span drops to 3. Remove the .plan-desc and .features elements from the HTML.

Show the comparison-first CSS
.pricing--compare .plan {
  grid-row: span 3;
  padding: 1rem 0;
  border: 0;
  border-block-end: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.pricing--compare .plan:has(.badge) {
  border: 0;
  border-block-end: 2px solid var(--brand);
  box-shadow: none;
}
.pricing--compare .badge { inset-inline-start: 0; translate: 0 -100%; }
.pricing--compare .price { font-size: 1.75rem; }

The badge stays absolutely positioned, so it doesn’t add an extra row. It moves to the top-left edge so it reads as a label rather than floating over a missing border.

Anatomy of a pricing card that converts

Pricing Table with Monthly/Yearly Toggle

A pricing card should help a visitor pick a plan in a few seconds. Every card above has the same parts in the same order, so readers can scan straight across the row.

Part Element Why it exists
Plan name <h3> Gives each plan a heading, so screen reader users can jump between plans
Audience line <p> Says who the plan is for, which helps more than a list of limits
Price <p> with currency, amount, period The number people compare first, so it gets the largest type
Savings note Next to the toggle Shows the annual offer once, where the choice is made
Feature list <ul> Differences between plans, most important first
CTA <a> or <button> One clear next step per plan
Badge <p class="badge"> Points to the recommended plan without shouting on every card

Price formatting (currency, /mo, billed annually)

Show the currency symbol, the amount and the period together, with the period smaller than the number. “$290 / year, billed annually” leaves no room for doubt. Many SaaS pages show “$24 /mo billed annually” instead. That looks cheaper, but the visitor has to do the maths to find out what they’ll actually be charged.

Pick one approach and use it everywhere. If you show a monthly equivalent for yearly billing, put the full yearly charge right under it. Use font-variant-numeric: tabular-nums so the digits stay the same width when prices change.

Feature lists: what to include and in what order

Put the three features that set a plan apart at the top of its list. Leave shared basics such as SSL or uptime to the comparison table. Starting the Team card with “Everything in Pro” shortens the list and makes the upgrade path clear.

Keep each item to one line where you can. Long lists are fine because subgrid absorbs the extra height. Long sentences aren’t, because people scan lists rather than read them.

CTA copy and placement

Give each button a label that names its plan, such as “Start Pro trial” or “Choose Team”. Screen readers often list every link on a page, and in that list three links all called “Get started” are useless. If your design really needs identical visible text, add visually hidden text inside the link: Get started<span class="visually-hidden"> with Pro</span>.

Put the CTA at the bottom of the card, lined up across all plans. Some long cards repeat the CTA near the top as well. That makes sense for cards with ten or more features and is unnecessary on short ones.

Aligning cards with CSS Grid and subgrid

Subgrid lines up names, prices and buttons across cards whose feature lists are different lengths. Make the plans container a grid, let each card span five rows with grid-row: span 5, and give each card grid-template-rows: subgrid. Each row (name, description, price, features, button) then sizes to the tallest content in that row across all cards.

Feature What it solves in a pricing table Baseline status Date
CSS Grid Multi-column card layout Widely available Shipped in major browsers in 2017
CSS subgrid Aligning prices, lists and CTAs across cards Widely available March 15, 2026 (Newly available September 15, 2023)
Size container queries (@container) Cards respond to their container’s width, not the viewport Widely available August 14, 2025
:has() selector CSS-only billing toggle, featured-card styling Widely available June 2026 (Newly available December 2023)
Style container queries for custom properties Theming cards from a parent variable Newly available May 2026 (Firefox 151)
CSS custom properties Brand colours and tokens in one place Widely available Long-standing

The subgrid dates come from the web-features explorer, the dataset behind Baseline. MDN Web Docs also lists subgrid as Widely available and working across browsers since September 2023. For :has(), web.dev’s Google I/O 2024 roundup gives the December 2023 Newly available date, and web.dev’s June 2026 Baseline digest lists it among the features that became Widely available. The style query milestone comes from web.dev’s May 2026 Baseline digest.

Did you know?

Firefox supported CSS subgrid almost four years before Chrome. According to SitePoint, Firefox shipped it in version 71 in December 2019, while Chrome and Edge followed in version 117 in August 2023.

Equal height cards

Cards in the same grid row are already equal height, because the default align-items: stretch makes every card fill its row. Equal height isn’t enough, though. To line up the price information inside the cards, the inner rows have to line up too, and only subgrid does that.

A worked example: Starter has a one-line description and Team has a two-line one. Without subgrid, Team’s price sits one line lower than Starter’s. With subgrid, row 2 grows to two lines in every card, so all three prices start at the same height.

Designer tip

Count your card’s direct children and set grid-row: span N to match. Five children with span 5 line up perfectly. Add a sixth element in normal flow and the rows shift. That’s why the badge in the template is absolutely positioned.

Pinning the button to the bottom

Each button can sit at the bottom of its column without position: absolute. With subgrid, the button gets its own row and align-self: end keeps it at the bottom of that row. Absolute positioning would take the button out of the flow and cause overlaps when the content grows.

Fallback with flexbox

The @supports not (grid-template-rows: subgrid) block turns each card into a flex column. flex: 1 on the feature list (or margin-top: auto on the button) pushes the CTA to the bottom. The buttons still line up, but the prices only line up if the descriptions are the same length. Now that subgrid is Widely available, few visitors will ever see the fallback. It costs four lines and does no harm, so keep it.

Responsive without breakpoint guesswork: container queries

Container queries let the cards respond to the width they’re actually given, not the width of the browser window. Set container-type: inline-size on .pricing and use @container (min-width: 52rem) to switch to three columns. The same component then works in a full-width hero, a narrow page-builder column or a WordPress block without new breakpoints.

@container vs @media for pricing sections

@media (min-width: …) @container (min-width: …)
Measures The viewport The pricing section itself
In a sidebar on desktop Tries to fit three columns and squashes them Stays stacked because the container is narrow
In page builders Breaks when a column gets narrower Adapts automatically
Support Universal Size queries Widely available since August 14, 2025
Gotcha None An element can’t query itself, so the container must be a parent of .plans

That last row catches people out. In the template, .pricing is the container and .plans is the grid inside it. If you put container-type on .plans and query it, nothing happens.

Why not use repeat(auto-fit, minmax(16rem, 1fr)) with no query at all? With three plans, it produces two cards plus one at medium widths, and the orphaned third card looks like an afterthought. A single container query gives you just two states, stacked or three across, and both look deliberate.

Mobile order: show the featured plan first?

You can show the popular plan first on mobile, but do it in the HTML rather than with CSS order. order: -1 inside a narrow container query moves the card visually, while keyboard focus and screen readers still follow the DOM order. WCAG 2.2’s Meaningful Sequence and Focus Order criteria cover exactly this kind of mismatch.

The cleaner fix is to put the featured plan first in the HTML, then place it in the middle on wide layouts with grid-column: 2 and send Starter to column 1. Keyboard users then reach the recommended plan first on every screen size, which is what you wanted anyway. If you’d rather keep low-to-high order everywhere, leave the DOM alone and let the badge do the work on mobile.

Monthly/yearly toggle: CSS-only and JS versions

The monthly/yearly toggle needs no JavaScript. Two radio inputs share a name, each with a visible label, and a rule such as .pricing:has(#bill-yearly:checked) .price-yearly { visibility: visible; } swaps the prices. A few lines of JavaScript are only needed to announce the change to screen reader users.

CSS-only toggle with :has()

The template keeps both prices in the same card and stacks them in one grid cell with grid-area: 1 / 1. Stacking both spans in one cell is meant to reserve room for the longer price, which helps avoid layout shift when switching from “$29 / month” to “$290 / year, billed annually”, but check that your layout actually leaves enough space for the longer text. visibility: hidden also hides the inactive price from assistive technologies, though you should still test with screen readers to confirm that only the visible price is announced.

There are other ways to store the prices:

  • Two spans per price (used here): the least duplication possible, and the price text stays real, selectable and translatable.
  • Data attributes with content: attr(data-yearly): one element, but the price becomes generated content. Screen readers handle that less reliably, and nobody can select or copy it.
  • Custom properties holding numbers: CSS can’t print a custom property’s value as text without counters, so this gets fiddly fast.

Designer tip

Build the toggle from two radio inputs with visible “Monthly” and “Yearly” labels. Both labels then work as click targets, the arrow keys move between them, and :has(#bill-yearly:checked) swaps the prices without a script.

Two radios also fix the most common toggle complaint: the “Monthly” label does nothing when clicked. A single checkbox styled as a switch has only one label, so visitors click “Monthly”, nothing happens and they assume it’s broken. With two radios, each option has its own working label.

Never hide the radios with display: none, because that removes them from the tab order. The template uses opacity: 0 with absolute positioning and draws a focus ring on the label with input:focus-visible + label.

JavaScript version with live price announcements

When the radio changes, screen readers announce the new selection (“Yearly, selected”). They don’t announce that six prices further down the page have changed. A polite live region fills that gap. Put it in the HTML from the start, because screen readers often ignore live regions that are added at the moment of change.

Show the live-region HTML and script
<p class="visually-hidden" aria-live="polite" data-billing-status></p>
const pricing = document.querySelector('.pricing');
const status = pricing.querySelector('[data-billing-status]');

pricing.addEventListener('change', (event) => {
  if (event.target.name !== 'billing') return;
  status.textContent = event.target.value === 'yearly'
    ? 'Showing yearly prices. Yearly billing includes 2 months free.'
    : 'Showing monthly prices.';
});

The script only adds the announcement. If it fails to load, the CSS toggle still works. If you load prices from an API, render the monthly prices on the server first. Otherwise visitors see empty cards or a “$0” flash before the script runs.

Radio group vs role=switch: which to use

Use a radio group for Monthly/Yearly and save role="switch" for a single on/off option. The W3C WAI-ARIA Authoring Practices Guide defines a switch as an element with role="switch", aria-checked="true" when on, and an accessible label. That pattern suits one choice such as “Bill yearly” and is a poor fit for two named options. Germany’s BFIT-Bund accessibility handbook also notes that screen readers often don’t announce role="switch" as a switch at all, and read it as a toggle button or a checkbox instead.

Pattern Markup Screen reader output Works without JS Recommendation
Radio group <fieldset>, <legend>, two type="radio" inputs with labels Announced as radio buttons with the group name and position Yes, with :has() Best default for Monthly/Yearly
Checkbox as switch <input type="checkbox" role="switch"> plus one label Often announced as a checkbox or toggle Yes, with :has(:checked) Fine if the label is “Bill yearly”
Button switch <button role="switch" aria-checked> Switch, toggle or checkbox, depending on the screen reader No, JS must flip aria-checked Only when you already rely on JS
Two buttons with aria-pressed Two <button> elements Toggle buttons, pressed or not pressed No Works, but radios do the same natively
Clickable <div> <div onclick> Nothing useful, and no keyboard access No Avoid

Did you know?

Even a correctly coded role="switch" is often read out as a checkbox. The BFIT-Bund handbook on accessible interface elements notes that screen readers don’t reliably announce the switch role, which is one more reason to use a native radio group for billing periods.

Highlight one plan with a stronger border, a soft shadow, a filled CTA and a small badge, and skip a large scale(). The template targets the plan with .plan:has(.badge), so adding or removing the badge in the HTML updates the styling automatically. Nobody has to remember a modifier class.

Practical rules for the featured card:

  1. Use one highlight. Two “Most popular” badges cancel each other out.
  2. Prefer a border and shadow to scale(1.05). Scaling makes text blurry in some browsers, overlaps the neighbouring cards and can cause horizontal overflow in narrow layouts. If you want scale, apply it only inside the wide container query.
  3. Put the badge on the top edge. Centring it on the border with translate: -50% -50% keeps it out of the subgrid rows. In the stacked layout, the 2rem gap between cards keeps it clear of the card above.
  4. Check contrast in both states. Under WCAG 2.1 AA, badge text, the filled button and any tinted card background each need at least 4.5:1 against their background. White on #4f46e5 clears that comfortably.

Contrast is where most pricing pages fail. A DEV Community write-up of an automated axe-core 4.11 scan of 30 SaaS pricing pages, published in April 2026, found colour contrast was the most common violation, on 12 of the 30 pages. Pastel “featured” backgrounds with light grey text are a typical cause.

Feature comparison tables

When plans differ on more than five or six features, add a comparison matrix below the cards. Use a real <table>, because a feature-by-plan grid is tabular data. Screen readers can then announce both the plan and the feature for every cell, which no arrangement of <div> elements does without heavy ARIA.

Semantic table markup

<div class="compare-wrap" role="region" aria-labelledby="compare-cap" tabindex="0">
  <table class="compare">
    <caption id="compare-cap">Compare plan features</caption>
    <thead>
      <tr>
        <th scope="col">Feature</th>
        <th scope="col">Starter</th>
        <th scope="col">Pro</th>
        <th scope="col">Team</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">Projects</th>
        <td>3</td><td>Unlimited</td><td>Unlimited</td>
      </tr>
      <tr>
        <th scope="row">Client review links</th>
        <td><span class="no" aria-hidden="true"></span><span class="visually-hidden">Not included</span></td>
        <td><span class="yes" aria-hidden="true"></span><span class="visually-hidden">Included</span></td>
        <td><span class="yes" aria-hidden="true"></span><span class="visually-hidden">Included</span></td>
      </tr>
    </tbody>
  </table>
</div>

The icons are hidden from assistive technology, and the visually hidden text says “Included” or “Not included”. A bare check-mark glyph can be read as “check mark”, “heavy check mark” or skipped entirely. An empty cell with only an icon tells a screen reader user nothing.

Sticky headers and first column

A sticky header row and a sticky first column keep plan and feature names visible while the table scrolls. The CSS is six lines.

Show the comparison table CSS
.compare-wrap { overflow-x: auto; max-width: 100%; }
.compare { border-collapse: separate; border-spacing: 0; min-width: 36rem; width: 100%; }
.compare th, .compare td { padding: .75rem 1rem; border-bottom: 1px solid #e5e7eb; text-align: center; }
.compare thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.compare th[scope="row"] { position: sticky; left: 0; background: #fff; text-align: start; }
.compare-wrap:focus-visible { outline: 3px solid #4f46e5; }

Watch for one edge case. Inside an overflow-x: auto wrapper, top: 0 sticks to the wrapper, not the page, so the header only stays put if the wrapper also scrolls vertically. For long tables, give the wrapper a max-height such as 80vh. Or drop the wrapper on wide screens and keep it only inside a narrow container query.

Mobile patterns: stacked cards vs horizontal scroll

On phones, use either horizontal scroll with a sticky first column or stacked cards, from one set of markup. Smashing Magazine’s guide to pricing page design names the core problem: as you scroll a comparison table on a phone, the plan names and feature names scroll out of view, and comparing becomes very hard.

  • Horizontal scroll with a sticky first column (shown above). Feature names stay pinned while the plans scroll sideways. It stays one table, and tabindex="0" with role="region" lets keyboard users scroll it.
  • Stacked cards. Below a set container width, set the rows to display: block and print each column’s plan name with td::before { content: attr(data-plan); }. Changing display on table elements can strip table semantics in some browsers, so test with a screen reader. Adrian Roselli recommends adding explicit role="table", role="row" and role="cell" when you do this.

Building a separate comparison table just for phones is a maintenance trap. When the desktop table changes, the phone copy goes out of date unless someone remembers to update both. Keep one source of markup and change only how it’s presented.

Accessibility checklist for pricing tables

An accessible pricing table needs a clear heading order, CTAs that name their plan, a native radio toggle, visible focus, 4.5:1 contrast and text alternatives for icons. The April 2026 axe-core scan reported on DEV Community found that only 9 of 30 SaaS pricing pages had zero WCAG 2.1 AA violations, so 70% failed. Figma, Netlify and Twilio were among the clean ones. Automated tools only catch some of the real problems, so you still need a manual pass.

  • Heading order: one <h2> for the pricing section and one <h3> per plan. Prices are text, not headings, so no <h1> prices.
  • Meaningful CTA labels: “Start Pro trial”, not three links called “Sign up”. Use visually hidden text or aria-label if the visible text has to match.
  • Toggle semantics: a radio group in a <fieldset> with a <legend>. Never a clickable <div>.
  • Keyboard: Tab reaches the toggle and every CTA, and the arrow keys move between the radios. Nothing interactive is hidden with display: none.
  • Focus styles: a visible outline on labels and links. WCAG 2.2 adds a requirement that focus isn’t obscured, so watch for sticky headers that cover focused rows.
  • Contrast: 4.5:1 for body text, badge text and button text, including on the featured card’s tinted background and in any dark variant.
  • No icon-only meaning: check and cross icons get text alternatives.
  • Price changes announced: a polite live region if prices change after the page loads.
  • Reflow: no horizontal page scroll at 320 CSS pixels wide, apart from the comparison table’s own scroll region.
  • Testing: run axe-core (browser extension or CI), then tab through by keyboard, then listen with NVDA on Windows and VoiceOver on macOS or iOS.

Designer tip

Mark plan names up as h3 under a single h2 “Pricing” and keep prices as plain text. Then use the screen reader’s heading list (NVDA’s Elements List or the VoiceOver rotor) as a quick check: you should see “Pricing”, then one heading per plan, and nothing else.

Tailwind CSS pricing table version

Tailwind CSS v4 has built-in utilities for everything this component needs: grid-rows-subgrid and row-span-5 for alignment, @container with container variants such as @4xl: for layout, and has-checked: plus group-has-[…] for the billing toggle. The markup below targets the v4.3 line, which began with v4.3.0 on May 8, 2026. Patch v4.3.3 followed on July 16, 2026, so check npm for the newest patch before you pin a version. Tailwind v3 remains on a separate v3 LTS tag.

<section class="group @container mx-auto max-w-6xl px-4 py-12 text-gray-800" aria-labelledby="pricing-title">
  <h2 id="pricing-title" class="mb-4 text-center text-3xl font-bold">Pricing</h2>

  <fieldset class="mx-auto mb-10 flex w-fit gap-1 rounded-full border border-gray-200 p-1">
    <legend class="sr-only">Billing period</legend>
    <label class="cursor-pointer rounded-full px-5 py-2 font-semibold has-checked:bg-indigo-600 has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-indigo-600">
      <input type="radio" name="billing" value="monthly" class="sr-only" checked> Monthly
    </label>
    <label class="cursor-pointer rounded-full px-5 py-2 font-semibold has-checked:bg-indigo-600 has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-indigo-600">
      <input type="radio" id="yr" name="billing" value="yearly" class="sr-only"> Yearly
      <span class="text-sm font-medium">2 months free</span>
    </label>
  </fieldset>

  <div class="grid gap-8 @4xl:grid-cols-3 @4xl:gap-6">
    <article class="relative row-span-5 grid grid-rows-subgrid gap-3 rounded-2xl border-2 border-indigo-600 bg-white p-8 shadow-xl shadow-indigo-600/20">
      <p class="absolute left-1/2 top-0 -translate-x-1/2 -translate-y-1/2 rounded-full bg-indigo-600 px-3 py-1 text-sm font-semibold text-white">Most popular</p>
      <h3 class="text-xl font-semibold">Pro</h3>
      <p class="text-gray-600">For small studios shipping client work every month.</p>
      <p class="grid text-4xl font-bold tabular-nums">
        <span class="[grid-area:1/1] group-has-[#yr:checked]:invisible">$29 <small class="text-base font-normal text-gray-600">/ month</small></span>
        <span class="invisible [grid-area:1/1] group-has-[#yr:checked]:visible">$290 <small class="text-base font-normal text-gray-600">/ year, billed annually</small></span>
      </p>
      <ul class="grid content-start gap-2">
        <li>Unlimited projects</li>
        <li>Client review links</li>
        <li>100 GB storage</li>
      </ul>
      <a href="/signup?plan=pro" class="self-end rounded-lg bg-indigo-600 px-4 py-3 text-center font-semibold text-white focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-gray-800">Start Pro trial</a>
    </article>
    <!-- Repeat the article for Starter and Team; drop the badge and use an outlined CTA. -->
  </div>
</section>

Each radio sits inside its own label, and the label is styled with has-checked:. Don’t use peer-checked: with the two radios as siblings in a row. The peer selector also matches the second label when the first radio is checked, so both labels light up. For the dark variant in Tailwind, swap bg-white for bg-slate-800, text-gray-800 for text-slate-100 and the indigo-600 utilities for indigo-400 with text-gray-900 on filled buttons.

How the other resources were chosen

The free resources below are the ones you’re most likely to compare, because they dominate this search. Each was judged on what this job needs, roughly in this order of weight:

  1. Whether the code is actually free to use, and under what licence.
  2. Whether it needs JavaScript or a framework.
  3. Whether it covers the full job: toggle, featured plan, comparison table and mobile layout.
  4. Whether a Figma file exists for design handoff.
  5. How current the CSS is.

Descriptions come from each maker’s own page, demo and documentation, checked in November 2026.

CodyHouse Pricing Tables

CodyHouse, created by co-founders Claudia Romano and Sebastiano Guerriero, offers its pricing tables as a free component on codyhouse.co. You get HTML, CSS and a jQuery script that adds a monthly/yearly switch with a 3D “bouncing” rotation when the billing period changes. The switch itself is built from radio inputs and labels, which is a good start.

The markup is where it shows its age. Each plan holds a nested list with separate monthly and yearly items, so every card exists twice. The layout uses a single desktop breakpoint, with no grid, subgrid or container queries. The demo CSS also hides button text on small screens with text-indent and color: transparent, so sighted mobile users see a button with no clear label.

  • Format: HTML, CSS, JavaScript (jQuery)
  • Needs: jQuery
  • Price: free (November 2026)
  • Licence: components are covered by the CodyHouse licence. You can use them in personal and commercial projects, including client work, but not in a product that competes with CodyHouse. Redistributing components inside themes, templates or plugins requires the paid Extended License, a one-time payment. The separate CodyHouse Framework is MIT licensed, and the Extended License terms apply to the components rather than to the framework.
  • Best for: studying a polished switch animation, or projects that already load jQuery

Licence note

CodyHouse components are free to use in personal and commercial projects, but redistributing them inside a theme or template requires the paid Extended License. Check this before you package one into a product.

W3Schools: How To Create a Responsive Pricing Table

W3Schools, published by Refsnes Data, has a short “How To” tutorial that builds one responsive pricing table with HTML and CSS. A media query stacks the columns on small screens. It’s free to read, includes a “Try it Yourself” editor and needs no JavaScript.

It teaches one basic pattern and stops there. There’s no billing toggle, no comparison table, no featured-plan treatment, and nothing that lines up rows across columns unless the content is fixed. Much of the page is navigation, ads and upsells such as seasonal promotions and app banners.

  • Format: HTML, CSS
  • Needs: nothing
  • Price: free (November 2026)
  • Licence: published under W3Schools’ own terms of use. The snippet carries no open-source licence, so treat it as a pattern to learn from and rebuild rather than an asset to ship.
  • Best for: complete beginners learning how a pricing column is put together

Flowbite pricing blocks

Flowbite, a Tailwind CSS component library from Themesberg, has seven pricing blocks in its marketing section, each with a Figma design file. Only the default pricing cards come with free code. The tabs, horizontal, feature list, comparison, highlighted and toggle variants all show “Unlock the code” and need a paid Flowbite Pro licence. Several of them also depend on Flowbite’s JavaScript.

The block pages don’t say which Tailwind version they target. Before you paste one into a v4 project, check Flowbite’s installation guide for your Tailwind version.

  • Format: HTML with Tailwind CSS classes, Figma
  • Needs: Tailwind CSS, plus Flowbite JS for some variants
  • Price: default cards free. Other variants need a paid Pro licence (checked November 2026).
  • Licence: the open-source Flowbite library is MIT licensed. Pro blocks are covered by Flowbite’s paid licence.
  • Best for: Tailwind teams who want matching Figma files and are willing to pay for the toggle and comparison variants

CodePen pricing-table pens

CodePen’s “pricing-table” tag collects hundreds of community pens. Some are excellent modern CSS experiments and many are old jQuery demos, and nothing on the tag page tells them apart. CodePen’s documentation says public pens are MIT licensed by default, while private pens carry no licence. Under MIT you can use the code commercially as long as you keep the copyright and licence notice.

To filter quickly, open a pen’s JS settings and check for jQuery or other external scripts. Look through the CSS for float and fixed pixel heights. Then tab through the demo to see whether the toggle works from the keyboard.

  • Format: HTML, CSS, JS (varies by pen)
  • Needs: varies. The tag page itself needs JavaScript to render.
  • Price: free (November 2026)
  • Licence: public pens default to MIT unless the author says otherwise in the pen
  • Best for: visual ideas that you then rebuild on the semantic structure above

Free pricing table resources compared

The best free option depends on your stack. For a production page with a toggle and no dependencies, the template at the top of this page covers the most ground. Flowbite suits Tailwind teams who need Figma files, and CodePen is the place for visual ideas. Workik, an AI code-generator site that also ranks for this search, is included for completeness. Its example is filler text in a builder-specific grid, with prices marked up as several <h1> elements and the monthly and yearly content duplicated and hidden with a utility class. That makes it a pattern to avoid rather than a template to adopt.

Resource Stack Free code? Needs JS Billing toggle Comparison table Style variants Figma file Best for
DesignSeer template (above) HTML, CSS or Tailwind v4 Yes No (optional live-region script) Yes, CSS-only Yes 5 (base plus 4) No Production SaaS pages
CodyHouse HTML, CSS, jQuery Yes Yes (jQuery) Yes No 1 No Switch animation reference
W3Schools HTML, CSS Yes No No No 1 No Learning the basics
Flowbite Tailwind CSS Default cards only Some variants Pro only Pro only 7 blocks Yes Tailwind teams with Figma handoff
CodePen tag Varies Yes (MIT by default) Often Some pens Some pens Hundreds of pens No Visual inspiration
Workik Builder HTML/CSS Example code shown Builder dependent Duplicated markup No Varies No Not recommended as a base

Of the ranking resources, Flowbite’s toggle is paywalled and CodyHouse’s needs jQuery. If you want a free pricing table with a monthly/yearly switch and no jQuery, the CSS-only template at the top of this page covers it.

Pricing UX: annual discounts, number of plans and badges

The safest default is three plans with one highlighted, plus an annual option framed as “2 months free” right next to the toggle. These are benchmarks from industry research, not guarantees. Test them against your own analytics before treating any of them as rules.

Benchmark Figure Source Caveat
Most common annual discount 16.7%, the same as 2 months free Recurly research on SaaS subscription benchmarks Recurly’s benchmark page is undated
Commonly cited annual discount range About 18 to 20% Monetizely, citing the book Price to Scale A rule of thumb, not a measured average
“2 months free” vs percentage framing About 30% better conversion with identical terms ProfitWell study, as cited by Monetizely Secondary citation of an older study
Pages offering monthly and annual billing 56% of 245 pricing pages SaaSFrame review of 225 SaaS products, November 2026 Usually shown with a toggle
Pages that state the annual discount 33% of 245 pricing pages SaaSFrame review, November 2026 Two thirds leave the saving for visitors to work out
Pages with a free plan / a free trial 46% each (113 of 245) SaaSFrame review, November 2026 68 pages offer neither, which usually means a demo-led sale

The maths behind “2 months free” is simple. Charge 10 months’ price for 12 months of service, and the discount is 2 ÷ 12, or 16.7%. In the template, $29 a month becomes $290 a year, against $348 at the monthly rate. “2 months free” turns an abstract percentage into something people can picture, and SaaSFrame’s figures show that most pricing pages don’t state the saving at all.

Designer tip

Put the “2 months free” note inside the toggle’s Yearly label, not in small print on each card. The saving then appears once, at the moment the visitor is choosing.

A headline annual discount has a downside. It can train buyers to expect discounts everywhere, and very cheap plans gain little from annual billing. If your monthly price is already low and churn is low, a smaller discount or none at all can be the better business choice.

How many plans to show

Three plans is the default because it gives a low, a middle and a high anchor, with the middle card as the natural choice. Two plans (the two-plan style above) work when the decision really is binary, such as free vs paid. One plan suits a single product. If you have an enterprise tier with custom pricing, a slim “Contact sales” row under the cards usually reads better than a fourth card with no number on it.

Badge wording

One “Most popular” label on the middle plan is the familiar pattern. It only works if it’s true or clearly a recommendation. “Recommended for studios” is more honest than claiming popularity for a plan launched last week.

Troubleshooting common pricing table bugs

Most pricing table bugs come from a handful of causes: a card’s span count not matching its children, hidden inputs, or fixed widths. The fixes are short.

Problem Likely cause Fix
Buttons not aligned across cards Cards are independent flex or block boxes Use grid-template-rows: subgrid with grid-row: span N. Fallback: a flex column with margin-top: auto on the CTA
Rows misaligned in one card That card has an extra in-flow element (badge, note) Position the badge absolutely, or add one row to every card
Rows break after removing elements Span count no longer matches children (for example, in the comparison-first style) Set grid-row: span N to the new number of children
Cards jump when toggling billing Monthly and yearly prices differ in length Stack both prices in one grid cell with grid-area: 1 / 1 and toggle visibility
Featured card overflows on mobile transform: scale() or a fixed width Scale only inside the wide @container query, and use min-width: 0 on grid items
Horizontal page scroll on phones Comparison table or long words force the width Wrap the table in an overflow-x: auto region, and add overflow-wrap: anywhere to long feature names
Toggle can’t be reached by keyboard Radios hidden with display: none Hide them visually with opacity: 0 and positioning, and style :focus-visible + label
Both toggle labels highlighted at once Sibling ~ or Tailwind peer-checked across two radios Use input:checked + label, or wrap each radio in its own label with has-checked:
Dark theme fails contrast Original indigo kept as text on a dark surface Lighten the brand colour (for example #818cf8) and use dark text on filled buttons
Prices flash or show $0 on load Prices injected by JavaScript after render Server-render the default prices and let CSS or JS only swap them
Container query does nothing container-type set on the element being queried Put container-type: inline-size on a parent such as .pricing
Sticky header doesn’t stick A parent with overflow becomes the scroll container Give the wrapper a max-height or remove the overflow on wide layouts

FAQ

How do I create a pricing table in HTML and CSS?

Wrap the plans in a <section> with one <h2>. Give each plan an <article> containing an <h3> name, a description, a price, a <ul> of features and a link as the CTA. Lay the cards out with CSS Grid and use subgrid to line up their rows. The code at the top of this page is a complete working example.

Is there a free CSS pricing table template I can use commercially?

Yes. The HTML and CSS on this page are free for commercial use with no attribution, and you can paste them straight into CodePen or save them as two files. CodyHouse’s component is free for your own and client sites but needs jQuery. Flowbite’s default cards are free, while its toggle and comparison variants need Flowbite Pro. Public CodePen pens are MIT licensed by default, so keep the licence notice.

How do I make a responsive pricing table?

Stack the cards in one column by default, then switch to three columns once the pricing section is wide enough. Do this with container-type: inline-size on the section and an @container (min-width: 52rem) rule. A @media query also works, but it measures the viewport rather than the space the cards actually have.

How do I add a monthly/yearly toggle to a pricing table?

Add a <fieldset> with two radio inputs named billing and visible “Monthly” and “Yearly” labels. Keep both prices in each card and use .pricing:has(#bill-yearly:checked) to show the yearly one. If you want screen readers to announce the change, add an aria-live="polite" message with a few lines of JavaScript.

Can I make a pricing toggle with only CSS?

Yes. The :has() selector, Baseline Widely available since June 2026, lets a parent react to a checked radio, and that’s enough to swap prices without a script. The toggle stays keyboard-operable because it’s built from native radio inputs.

How do I make pricing cards the same height?

Cards in the same grid row stretch to equal height by default. To line up the content inside them as well (names, prices, lists), give each card grid-template-rows: subgrid and grid-row: span 5. Subgrid has been Baseline Widely available since March 15, 2026.

How do I align buttons at the bottom of pricing cards?

With subgrid, the button gets its own shared row, so it lines up across cards automatically. Add align-self: end to keep it at the bottom of that row. Without subgrid, make the card a flex column and give the button margin-top: auto. You don’t need position: absolute.

How do I make a dark pricing table?

Override the custom properties: a dark background and surface, light text, and a lighter brand colour such as #818cf8 with dark text on filled buttons. The dark style above shows the full set. To follow the visitor’s system theme, put the same values inside @media (prefers-color-scheme: dark).

Should a pricing table use <table> or divs?

Use cards (<article> elements) for the plan overview and a real <table> for a feature-by-plan comparison. Comparison data is tabular, and <th scope="col"> and <th scope="row"> let screen readers announce the plan and the feature for every cell.

How do I highlight the most popular plan?

Add a badge element to that card and style the card with .plan:has(.badge): a 2px brand border, a soft shadow and a filled CTA. Highlight only one plan, check that badge and button text reach at least 4.5:1 contrast, and avoid large scale() values that overflow on mobile.

How do I build a pricing table with Tailwind CSS?

In Tailwind CSS v4, put @container on the section, @4xl:grid-cols-3 on the grid and row-span-5 grid-rows-subgrid on each card. For the toggle, wrap each radio in its own label styled with has-checked:, and show prices with group-has-[#yr:checked]:visible. Start from the Tailwind block above, choose the style that fits your plan lineup, then run axe-core and a screen reader pass before you ship.

About this article

Written by

Corey Lindahl covers website and landing page templates, UI and code snippets, blog and CMS themes, and design tools for DesignSeer. He checks each listing's license terms, file formats, framework versions and pricing against the creator's official page and documentation, then explains what you can actually use in a client or commercial project.

  • Fact-checked by Graham Sutter against the sources listed below before publication.
  • Published
Sources (8)
  1. Subgrid | Web platform features explorer (web-platform-dx.github.io)
  2. Subgrid – CSS | MDN (developer.mozilla.org)
  3. CSS Container Queries and Subgrid – SitePoint (sitepoint.com)
  4. New in the web: I/O 2024 | web.dev (web.dev)
  5. Rachel Andrew talk: Baseline features (speaking.rachelandrew.co.uk)
  6. Baseline digest May 2026 | web.dev (web.dev)
  7. Switch Pattern | APG | WAI | W3C (w3.org)
  8. Wechselschalter | BFIT-Bund Handreichungen (handreichungen.bfit-bund.de)