CSS Snippets

Copy. Paste. Ship.

Home › Code Snippets › CSS › Pricing Matrix

Part of our complete guide: CSS Snippets →

UI Component · HTML + CSS

CSS Pricing Matrix

Three-tier pricing cards, a monthly/yearly toggle without JavaScript, and a feature comparison matrix. Copy-paste ready.

Last updated: October 2026 · 8 min read

A pricing matrix shows 3 tiers side by side with prices, features, and a highlighted "recommended" tier. The billing toggle uses the CSS :checked pseudo-class — no JavaScript needed. Below 768px, cards stack vertically.

What you get: Complete pricing section with 3 tiers, monthly/yearly toggle, feature comparison table, and a "Most Popular" badge. All responsive, all pure CSS.

Why pricing tables matter

The pricing page is the highest-intent page on any SaaS site. Visitors who reach it have already decided they're interested. The layout either confirms their decision or creates friction that pushes them away. Studies consistently show that clear pricing with a recommended tier converts 20-40% better than a "Contact Sales" form.

Three tiers is the sweet spot. Two tiers feels too binary — buyers feel forced. Four or more creates decision fatigue. The middle tier is almost always the "recommended" one, both because it converts best and because it anchors the other prices. The comparison matrix below the cards handles edge cases (specific features certain buyers care about) without cluttering the main cards.

The monthly/yearly toggle is where most implementations use JavaScript — but it doesn't need to. Using hidden radio buttons and the :checked pseudo-class gives the same behavior with zero JS. This is one of the few cases where CSS-only UI actually works better than the JS alternative.

🎬 Live Pricing Table

Toggle between monthly and yearly. All 3 tiers with comparison matrix below.

Starter
For individuals getting started
$00/mo
  • Up to 3 projects
  • Community support
  • Basic analytics
  • Custom domains
  • Team collaboration
Start Free
Team
For growing teams and agencies
$4939/mo
  • Everything in Pro
  • Team collaboration
  • SSO & advanced security
  • Custom domains
  • Priority phone support
Start 14-Day Trial

Full comparison

Feature Starter Pro Team
Projects3UnlimitedUnlimited
Team members11Unlimited
Custom domains×✓✓
AnalyticsBasicAdvancedAdvanced
SSO××✓
SupportCommunityEmailPhone
SLA××✓

Complete code

<div class="pricing-wrap">
  <div class="billing-toggle">
    <input type="radio" name="billing" id="billing-monthly" value="monthly" checked>
    <input type="radio" name="billing" id="billing-yearly" value="yearly">
    <label for="billing-monthly">Monthly</label>
    <label for="billing-yearly">Yearly <span class="save-badge">Save 20%</span></label>
  </div>

  <div class="pricing-grid">
    <!-- Starter -->
    <div class="pricing-card">
      <div class="tier-name">Starter</div>
      <div class="tier-desc">For individuals getting started</div>
      <div class="tier-price">
        <span class="currency">$</span><span class="price-monthly">0</span><span class="price-yearly">0</span><span class="period">/mo</span>
      </div>
      <ul class="tier-features">
        <li>Up to 3 projects</li>
        <li>Community support</li>
        <li>Basic analytics</li>
        <li class="muted">Custom domains</li>
        <li class="muted">Team collaboration</li>
      </ul>
      <a href="#" class="tier-cta secondary">Start Free</a>
    </div>

    <!-- Pro (featured) -->
    <div class="pricing-card featured">
      <div class="tier-name">Pro</div>
      <div class="tier-desc">For freelancers and small teams</div>
      <div class="tier-price">
        <span class="currency">$</span><span class="price-monthly">19</span><span class="price-yearly">15</span><span class="period">/mo</span>
      </div>
      <ul class="tier-features">
        <li>Unlimited projects</li>
        <li>Priority email support</li>
        <li>Advanced analytics</li>
        <li>Custom domains</li>
        <li class="muted">Team collaboration</li>
      </ul>
      <a href="#" class="tier-cta primary">Start 14-Day Trial</a>
    </div>

    <!-- Team -->
    <div class="pricing-card">
      <div class="tier-name">Team</div>
      <div class="tier-desc">For growing teams and agencies</div>
      <div class="tier-price">
        <span class="currency">$</span><span class="price-monthly">49</span><span class="price-yearly">39</span><span class="period">/mo</span>
      </div>
      <ul class="tier-features">
        <li>Everything in Pro</li>
        <li>Team collaboration</li>
        <li>SSO &amp; advanced security</li>
        <li>Custom domains</li>
        <li>Priority phone support</li>
      </ul>
      <a href="#" class="tier-cta secondary">Start 14-Day Trial</a>
    </div>
  </div>
</div>

<style>
.pricing-wrap { max-width: 900px; margin: 0 auto; }
.billing-toggle {
  display: flex; justify-content: center;
  align-items: center; gap: 0.5rem;
  margin-bottom: 2rem;
}
.billing-toggle input[type="radio"] { display: none; }
.billing-toggle label {
  padding: 0.5rem 1rem; border-radius: 0.5rem;
  cursor: pointer; color: #94a3b8;
  font-size: 0.85rem; font-weight: 600;
  transition: all 0.2s;
}
.billing-toggle input[value="monthly"]:checked ~ label[for="billing-monthly"],
.billing-toggle input[value="yearly"]:checked ~ label[for="billing-yearly"] {
  background: #3b82f6; color: #fff;
}
.billing-toggle .save-badge {
  background: #052e16; color: #22c55e;
  font-size: 0.68rem; font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  margin-left: 0.25rem;
  text-transform: uppercase;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}
.pricing-card {
  background: #1e293b; border: 1px solid #334155;
  border-radius: 1rem; padding: 1.75rem 1.5rem;
  display: flex; flex-direction: column;
  position: relative;
}
.pricing-card.featured {
  border-color: #3b82f6;
  background: linear-gradient(180deg, #1e3a8a 0%, #1e293b 100%);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}
.pricing-card.featured::before {
  content: 'MOST POPULAR';
  position: absolute; top: -10px; left: 50%;
  transform: translateX(-50%);
  background: #3b82f6; color: #fff;
  font-size: 0.65rem; font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  letter-spacing: 0.05em;
}

.tier-name { color: #fff; font-weight: 700; font-size: 1rem; margin-bottom: 0.25rem; }
.tier-desc { color: #94a3b8; font-size: 0.8rem; margin-bottom: 1rem; min-height: 2.4em; }
.tier-price { color: #fff; font-weight: 900; font-size: 2rem; line-height: 1; margin-bottom: 0.25rem; }
.tier-price .currency { font-size: 1rem; vertical-align: super; margin-right: 2px; }
.tier-price .period { color: #64748b; font-size: 0.75rem; font-weight: 500; margin-left: 0.25rem; }

.price-monthly { display: inline; }
.price-yearly { display: none; }
.pricing-wrap:has(#billing-yearly:checked) .price-monthly { display: none; }
.pricing-wrap:has(#billing-yearly:checked) .price-yearly { display: inline; }

.tier-features { list-style: none; padding: 0; margin: 1.25rem 0; flex: 1; }
.tier-features li {
  color: #cbd5e1; font-size: 0.82rem;
  padding: 0.4rem 0;
  display: flex; align-items: flex-start; gap: 0.5rem;
}
.tier-features li::before { content: '✓'; color: #22c55e; font-weight: 700; flex-shrink: 0; }
.tier-features li.muted { color: #64748b; }
.tier-features li.muted::before { content: '×'; color: #475569; }

.tier-cta {
  display: block; text-align: center;
  padding: 0.75rem; border-radius: 0.5rem;
  text-decoration: none; font-weight: 700;
  font-size: 0.85rem; transition: all 0.2s;
}
.tier-cta.primary { background: #3b82f6; color: #fff; }
.tier-cta.primary:hover { background: #2563eb; }
.tier-cta.secondary {
  background: transparent; border: 1px solid #334155;
  color: #cbd5e1;
}
.tier-cta.secondary:hover { background: #1e293b; border-color: #475569; }
</style>

How the billing toggle works (without JavaScript)

This is the trick worth understanding.

1. Two hidden radio buttons

The toggle has two <input type="radio"> elements, both hidden with display: none. Only one can be checked at a time (they share the same name attribute). The visual "buttons" are actually <label> elements linked to the radios via for.

<input type="radio" name="billing" id="billing-monthly" checked>
<input type="radio" name="billing" id="billing-yearly">
<label for="billing-monthly">Monthly</label>
<label for="billing-yearly">Yearly</label>

Clicking the "Yearly" label checks the yearly radio. Clicking "Monthly" checks the monthly radio.

2. :has() connects the toggle to the price

The modern :has() pseudo-class lets a parent element style itself based on its descendants. When #billing-yearly is checked, the whole .pricing-wrap gets that state — and can style its children accordingly:

.price-monthly { display: inline; }
.price-yearly  { display: none; }

.pricing-wrap:has(#billing-yearly:checked) .price-monthly { display: none; }
.pricing-wrap:has(#billing-yearly:checked) .price-yearly  { display: inline; }

When yearly is selected, all .price-monthly spans hide and all .price-yearly spans show. Two rules, zero JavaScript.

3. Why two price spans per card?

Each card has two price values — one for monthly, one for yearly. Both live in the DOM. Only one is displayed at a time. This lets the toggle swap prices instantly without any layout recalculation, because both values are already rendered.

4. The label highlight

The active label (the one whose radio is checked) gets the blue background. This is done via sibling selectors — the checked radio's state propagates to the next labels:

.billing-toggle input[value="monthly"]:checked ~ label[for="billing-monthly"] {
  background: #3b82f6;
  color: #fff;
}

🔬 Edge cases

The problems that break pricing tables in production.

:has() browser support

The :has() selector is Baseline since December 2023 — Chrome 105+, Safari 15.4+, Firefox 121+. It works in all modern browsers. For older browsers, the toggle simply won't swap prices. Add a static default and let users with older browsers see the monthly price only.

Toggle state on page reload

The radio button resets to "monthly" checked on every page load. If a user prefers yearly and navigates back to the pricing page, they have to click yearly again. Fix: persist to localStorage with 3 lines of JS (or accept that they'll re-select — most users don't mind).

Cards have unequal heights

If one tier has fewer features, its card is shorter than the others — the CTAs align unevenly. Fix: use display: flex; flex-direction: column on the card, and flex: 1 on the feature list. This pushes the CTA to the bottom of each card, so all CTAs align.

Comparison matrix overflows on mobile

A 4-column matrix on a 375px screen becomes unreadable. Fix: wrap in overflow-x: auto so it scrolls horizontally. Alternatively, convert it to per-card feature lists on mobile using CSS or separate markup.

"MOST POPULAR" badge overlaps card top

If the card has overflow: hidden (some card layouts add this), the badge gets clipped. Fix: don't use overflow: hidden on the featured card, or position the badge inside the card's padding.

Currency and locale formatting

The example uses $19 hardcoded. If your site serves multiple regions, the price needs to change. Fix: add per-currency spans or use a JS currency switcher. For static sites, only show the currency you actually charge in.

Accessibility: hidden radio buttons

display: none on radio inputs makes them invisible to screen readers too. Fix: use position: absolute; opacity: 0 instead of display: none, so screen readers can still focus and announce them.

Nested anchor links inside pricing cards

If the entire card is a link AND has a CTA button, you get nested anchors — invalid HTML. Fix: make the whole card clickable via an absolutely positioned overlay anchor with a higher z-index than the CTA button, or keep only the CTA clickable.

⚡ Performance

Aspect Cost Notes
CSS size~2KBNo JS, no dependencies
Toggle animationInstantdisplay swap, no transition
Render costVery lowStatic layout, no reflow on toggle

The biggest "cost" is decision fatigue. Every additional feature row in the comparison matrix slows down decision-making. Show only the features that differentiate tiers — if all three tiers have "Custom domains ✓", that row doesn't need to be there.

⚠️ Common mistakes

❓ Frequently asked questions

What makes a good pricing table?

A good pricing table shows tiers side by side, highlights the recommended tier, uses consistent feature rows, and makes the price the largest visual element. It should work on mobile without horizontal scrolling.

Should I use 3 or 4 pricing tiers?

Three tiers is the sweet spot. It gives buyers a clear comparison without overwhelming them. Add a fourth tier (Enterprise) only if you have enterprise customers with distinct needs.

How do I make the pricing table responsive on mobile?

Stack the cards vertically below 768px using flex-direction: column or grid-template-columns: 1fr. Keep the price prominent. Convert the comparison matrix to a per-card feature list on mobile if it's too wide.

Can I add a monthly/yearly toggle without JavaScript?

Yes, using the :checked pseudo-class and hidden radio inputs. Two radio buttons (monthly/yearly) toggle the visibility of two price spans. No JavaScript needed.

Should I highlight a recommended tier?

Yes. Use a border, a badge, or a slightly different background color to highlight one tier. Most SaaS sites highlight their middle tier as the recommended option.

What price should I display?

Display the price you want customers to pay, not a rounded-down number. If billing is annual, show the annual price (or the monthly-equivalent with a note). Be transparent about what's included.

How do I add a pricing table in React?

Same HTML/CSS — just replace class with className. For a monthly/yearly toggle, use useState instead of radio buttons. The CSS itself doesn't need to change.

Do pricing tables hurt conversion?

Poor pricing tables do — too many tiers, unclear features, or hidden fees. A clean, transparent table with a clear recommendation usually improves conversion versus a contact-sales form.

🔗 Related snippets

🌐 External resources

← All CSS Snippets