Building a responsive pricing table
The user wants a CSS grid-based responsive pricing table with interactive hover effects and tooltips using plain HTML, CSS, and JavaScript. I need to ensure it's mobile-friendly, stacking to one column. I’ll create 3 or 4 pricing cards within the grid layout. For hover effects, I’ll include card elevation, shadow effects, and button scaling, along with tooltips using data attributes. I also need basic JavaScript to toggle tooltip visibility for accessibility on touch devices. Let's ensure it’s concise yet detailed!Implementing hover effects and tooltips
I’m considering how to create interactive hover effects primarily with CSS, while also potentially using JavaScript for dynamic tooltip positioning. I plan to provide an HTML file with either inline or separated CSS and JS for easy copy-pasting, including some notes on customization. Using accessible semantics like <section> and <button> is key, along with a CSS Grid layout. For the tooltips, I'll suggest a structure and related CSS, but I’ll also incorporate JavaScript for mobile usability, ensuring keyboard focus works well too!Creating interactive tooltip functionality
I’m thinking about how to implement click events for toggling the tooltip--active class using JavaScript, allowing tooltips to show or hide based on user interaction. I might highlight a recommended plan through JavaScript as well, but since the user asked for a combination of HTML, CSS, and some JS, I’ll focus on providing a compact solution. I plan to present the code as three sections: HTML, CSS, and JS, or as a complete HTML skeleton for easy copy and paste. I'll ensure it’s responsive, featuring a card layout with headers, prices, features, and a call-to-action!Designing the pricing section
I need to structure the HTML for the pricing section clearly. It'll include a heading and a pricing grid with various plans, like a "Basic" plan priced at $9/month, along with features and tooltips for extra info.
For CSS, I'll use root variables and gradient highlights for the recommended plan, with hover effects, transitions, and tooltip styles. The JavaScript will handle interactions for showing tooltips and closing them on outside clicks. I’ll make sure everything is mobile-friendly too. Finally, I'll prepare to present this as a copy-paste solution into an HTML file!Drafting the pricing table code
I’m considering whether to load external fonts, but it seems simpler to stick with system fonts. I’ll start by drafting the HTML in a single file format: a basic structure with the necessary meta tags.
For the CSS, I’ll define some root variables and set up a responsive pricing grid with specific styling for each plan. I’ll also include tooltips for feature descriptions and ensure everything is accessible. Additionally, I want to add interactive hover effects, like scaling for the cards and a gradient border for highlighted plans. Now, let’s put it all together with the final code and brief explanations! Below is a complete, self‑contained example of a responsive pricing table built with CSS Grid, interactive hover effects, and JS‑enhanced tooltips.
Copy this into a file like pricing-table.html and open it in your browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Responsive Pricing Table</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
:root {
--bg: #0f172a;
--card-bg: #ffffff;
--text: #111827;
--muted: #6b7280;
--border: #e5e7eb;
--accent: #6366f1;
--accent-soft: rgba(99, 102, 241, 0.1);
--accent-strong: #4f46e5;
--danger: #f97373;
--success: #22c55e;
--shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);
--radius-lg: 1.25rem;
--radius-full: 999px;
--transition-fast: 170ms ease-out;
--transition-slow: 240ms ease;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
sans-serif;
background: radial-gradient(circle at top, #1f2937 0, #020617 55%);
color: #e5e7eb;
}
.pricing {
max-width: 1120px;
margin: 0 auto;
padding: 3.5rem 1.5rem 4.5rem;
}
.pricing__intro {
text-align: center;
margin-bottom: 3rem;
}
.pricing__eyebrow {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.2rem 0.6rem;
border-radius: 999px;
background: rgba(148, 163, 184, 0.2);
color: #e5e7eb;
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.pricing__eyebrow-dot {
width: 6px;
height: 6px;
border-radius: 999px;
background: #22c55e;
box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.4);
}
.pricing__title {
margin: 0.8rem 0 0.3rem;
font-size: clamp(1.95rem, 4vw, 2.4rem);
letter-spacing: -0.03em;
font-weight: 700;
}
.pricing__subtitle {
margin: 0;
max-width: 520px;
margin-inline: auto;
color: #9ca3af;
font-size: 0.95rem;
}
/* Toggle: monthly / yearly (non-functional, visual only) */
.billing-toggle {
margin-top: 1.8rem;
display: inline-flex;
align-items: center;
gap: 1rem;
padding: 0.35rem;
border-radius: var(--radius-full);
background: rgba(15, 23, 42, 0.6);
border: 1px solid rgba(148, 163, 184, 0.4);
backdrop-filter: blur(12px);
color: #e5e7eb;
font-size: 0.82rem;
}
.billing-toggle__pill {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.6rem;
border-radius: var(--radius-full);
background: rgba(22, 101, 52, 0.18);
font-size: 0.7rem;
color: #bbf7d0;
}
.billing-toggle__pill strong {
font-weight: 600;
}
.billing-toggle__switch {
position: relative;
width: 52px;
height: 26px;
border-radius: 999px;
background: #020617;
border: 1px solid rgba(148, 163, 184, 0.7);
padding: 2px;
}
.billing-toggle__knob {
position: absolute;
top: 2px;
left: 2px;
width: 20px;
height: 20px;
border-radius: 999px;
background: linear-gradient(135deg, #4f46e5, #a855f7);
box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.5),
0 8px 16px rgba(15, 23, 42, 0.8);
transition: transform 180ms ease-out;
transform: translateX(0);
}
.billing-toggle__labels {
display: flex;
gap: 0.4rem;
align-items: center;
font-size: 0.8rem;
}
.billing-toggle__labels span {
opacity: 0.7;
}
.billing-toggle__labels span.billing-toggle__label--active {
opacity: 1;
font-weight: 600;
color: #e5e7eb;
}
/* PRICING GRID */
.pricing-grid {
margin-top: 2.5rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.8rem;
}
.plan {
position: relative;
display: flex;
flex-direction: column;
background: radial-gradient(circle at top left, #f9fafb 0, #f3f4f6 45%, #e5e7eb 100%);
border-radius: var(--radius-lg);
padding: 1.75rem 1.6rem 1.7rem;
color: var(--text);
border: 1px solid var(--border);
box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
overflow: hidden;
transform-origin: center top;
transition:
transform var(--transition-slow),
box-shadow var(--transition-slow),
border-color var(--transition-fast),
background 160ms ease-out;
isolation: isolate;
}
.plan::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
border: 1px solid transparent;
background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(14, 165, 233, 0.16))
border-box;
opacity: 0;
pointer-events: none;
transition: opacity var(--transition-slow);
mix-blend-mode: multiply;
}
.plan:hover,
.plan:focus-within {
transform: translateY(-6px) scale(1.01);
box-shadow: var(--shadow-soft);
border-color: rgba(129, 140, 248, 0.75);
background: radial-gradient(circle at top left, #ffffff 0, #f9fafb 55%, #eef2ff 100%);
}
.plan:hover::before,
.plan:focus-within::before {
opacity: 1;
}
.plan--popular {
background: radial-gradient(circle at top, #eef2ff 0, #eff6ff 45%, #f9fafb 100%);
border-color: rgba(79, 70, 229, 0.9);
}
.plan--popular::before {
opacity: 1;
}
.plan__badge {
position: absolute;
top: 1.1rem;
right: -3.5rem;
padding: 0.2rem 0;
width: 9rem;
text-align: center;
background: linear-gradient(135deg, #4f46e5, #ec4899);
color: white;
font-size: 0.7rem;
letter-spacing: 0.08em;
text-transform: uppercase;
transform: rotate(40deg);
box-shadow: 0 10px 26px rgba(15, 23, 42, 0.4);
font-weight: 600;
}
.plan__header {
margin-bottom: 1.2rem;
}
.plan__name {
margin: 0;
font-size: 1.05rem;
letter-spacing: 0.06em;
text-transform: uppercase;
color: #4b5563;
}
.plan__tagline {
margin: 0.2rem 0 0.5rem;
font-size: 0.9rem;
color: var(--muted);
}
.plan__price-row {
display: flex;
align-items: baseline;
gap: 0.2rem;
margin-top: 0.6rem;
}
.plan__price-main {
font-size: 2.1rem;
font-weight: 700;
letter-spacing: -0.04em;
color: var(--accent-strong);
}
.plan__currency {
font-size: 1rem;
align-self: flex-start;
padding-top: 0.5rem;
color: #4b5563;
}
.plan__period {
font-size: 0.9rem;
color: var(--muted);
margin-left: 0.15rem;
}
.plan__note {
font-size: 0.78rem;
color: #6b7280;
margin-top: 0.35rem;
}
.plan__divider {
border: 0;
border-top: 1px dashed rgba(148, 163, 184, 0.7);
margin: 1.1rem 0 1rem;
}
/* FEATURES LIST + TOOLTIPS */
.plan__features {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 0.55rem;
font-size: 0.88rem;
color: #374151;
}
.plan__feature {
display: flex;
align-items: flex-start;
gap: 0.45rem;
}
.plan__feature-icon {
margin-top: 0.08rem;
width: 14px;
height: 14px;
border-radius: 10px;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
font-weight: 700;
}
.plan__feature-icon--check {
background: rgba(16, 185, 129, 0.14);
color: #15803d;
}
.plan__feature-icon--minus {
background: rgba(248, 113, 113, 0.1);
color: #b91c1c;
}
.plan__feature-text {
flex: 1;
display: inline-flex;
align-items: center;
gap: 0.25rem;
flex-wrap: wrap;
}
.feature-label strong {
font-weight: 600;
}
.feature-label {
display: inline-flex;
align-items: center;
gap: 0.18rem;
}
/* Tooltip button */
.tooltip {
position: relative;
border: 0;
padding: 0;
margin-left: 0.12rem;
width: 17px;
height: 17px;
border-radius: 999px;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
font-weight: 600;
background: rgba(129, 140, 248, 0.1);
color: var(--accent-strong);
border: 1px solid rgba(129, 140, 248, 0.7);
cursor: pointer;
flex-shrink: 0;
transition:
background var(--transition-fast),
color var(--transition-fast),
border-color var(--transition-fast),
box-shadow var(--transition-fast),
transform 120ms ease-out;
}
.tooltip:hover,
.tooltip:focus-visible,
.tooltip.tooltip--active {
background: var(--accent-strong);
color: white;
border-color: transparent;
box-shadow: 0 8px 16px rgba(30, 64, 175, 0.35);
transform: translateY(-1px);
outline: none;
}
.tooltip:focus-visible {
outline: 2px solid #f97316;
outline-offset: 2px;
}
/* Tooltip bubble */
.tooltip::after {
content: attr(data-tooltip);
position: absolute;
z-index: 10;
left: 50%;
bottom: calc(100% + 0.45rem);
transform: translateX(-50%) translateY(6px);
min-width: 180px;
max-width: 240px;
padding: 0.5rem 0.6rem;
font-size: 0.76rem;
color: #e5e7eb;
background: radial-gradient(circle at top left, #111827 0, #020617 60%);
border-radius: 0.55rem;
border: 1px solid rgba(148, 163, 184, 0.7);
box-shadow: 0 18px 36px rgba(15, 23, 42, 0.9);
opacity: 0;
pointer-events: none;
white-space: normal;
line-height: 1.4;
transition:
opacity 150ms ease-out,
transform 150ms ease-out,
visibility 150ms ease-out;
visibility: hidden;
}
.tooltip::before {
content: "";
position: absolute;
left: 50%;
bottom: 100%;
transform: translateX(-50%);
border-width: 6px;
border-style: solid;
border-color: transparent transparent rgba(15, 23, 42, 0.96) transparent;
opacity: 0;
transition: opacity 150ms ease-out;
pointer-events: none;
visibility: hidden;
}
.tooltip:hover::after,
.tooltip:hover::before,
.tooltip:focus-visible::after,
.tooltip:focus-visible::before,
.tooltip.tooltip--active::after,
.tooltip.tooltip--active::before {
opacity: 1;
transform: translateX(-50%) translateY(0);
visibility: visible;
pointer-events: auto;
}
/* CTA AREA */
.plan__footer {
margin-top: 1.2rem;
display: flex;
flex-direction: column;
gap: 0.6rem;
}
.plan__cta {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.35rem;
padding: 0.7rem 0.9rem;
border-radius: var(--radius-full);
border: 1px solid rgba(148, 163, 184, 0.7);
background: #111827;
color: #f9fafb;
cursor: pointer;
font-size: 0.86rem;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
box-shadow: 0 10px 20px rgba(15, 23, 42, 0.6);
transition:
background var(--transition-slow),
color var(--transition-slow),
transform 140ms ease-out,
box-shadow 160ms ease-out,
border-color var(--transition-fast);
}
.plan__cta span {
font-size: 0.78rem;
}
.plan--popular .plan__cta {
background: linear-gradient(135deg, #4f46e5, #ec4899);
border-color: transparent;
box-shadow: 0 14px 32px rgba(79, 70, 229, 0.7);
}
.plan__cta:hover,
.plan__cta:focus-visible {
transform: translateY(-2px);
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.85);
background: linear-gradient(135deg, #0f172a, #111827);
border-color: rgba(129, 140, 248, 0.9);
}
.plan--popular .plan__cta:hover,
.plan--popular .plan__cta:focus-visible {
background: linear-gradient(135deg, #4338ca, #db2777);
box-shadow: 0 20px 50px rgba(79, 70, 229, 0.9);
}
.plan__cta:focus-visible {
outline: 2px solid #f97316;
outline-offset: 2px;
}
.plan__meta {
font-size: 0.78rem;
color: #6b7280;
display: flex;
justify-content: space-between;
gap: 0.5rem;
flex-wrap: wrap;
}
.plan__meta span {
display: inline-flex;
align-items: center;
gap: 0.2rem;
}
.plan__meta-dot {
width: 6px;
height: 6px;
border-radius: 999px;
background: #22c55e;
}
/* RESPONSIVE TWEAKS */
@media (max-width: 768px) {
.pricing {
padding-inline: 1.1rem;
}
.pricing-grid {
gap: 1.5rem;
}
.plan {
padding: 1.6rem 1.4rem 1.6rem;
}
.plan__badge {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<main class="pricing">
<header class="pricing__intro">
<div class="pricing__eyebrow">
<span class="pricing__eyebrow-dot"></span>
PRICING
</div>
<h1 class="pricing__title">Simple plans for every stage</h1>
<p class="pricing__subtitle">
Start free, then scale with predictable pricing. Toggle to see yearly discounts and hover items for more details.
</p>
<!-- Static example toggle (purely visual here) -->
<div class="billing-toggle" aria-hidden="true">
<div class="billing-toggle__labels">
<span class="billing-toggle__label billing-toggle__label--active">Monthly</span>
<div class="billing-toggle__switch">
<div class="billing-toggle__knob"></div>
</div>
<span>Yearly</span>
</div>
<div class="billing-toggle__pill">
<span>Save</span> <strong>20%</strong>
</div>
</div>
</header>
<section class="pricing-grid" aria-label="Pricing plans">
<!-- PLAN: Starter -->
<article class="plan" tabindex="-1">
<header class="plan__header">
<h2 class="plan__name">Starter</h2>
<p class="plan__tagline">For solo makers validating ideas.</p>
<div class="plan__price-row">
<span class="plan__currency">$</span>
<span class="plan__price-main">9</span>
<span class="plan__period">/month</span>
</div>
<p class="plan__note">Billed monthly. Cancel anytime.</p>
</header>
<hr class="plan__divider" />
<ul class="plan__features">
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label"><strong>3</strong> active projects</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
Up to <strong>10 GB</strong> storage
<button
type="button"
class="tooltip"
data-tooltip="Combined storage limit across all projects. You can upgrade storage later without changing plans."
aria-label="More info about storage limits"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
Basic analytics
<button
type="button"
class="tooltip"
data-tooltip="Includes page views, unique visitors, and referrers. Data retained for 30 days."
aria-label="More info about analytics"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--minus">–</div>
<div class="plan__feature-text">
<span>Email support (24–48h)</span>
</div>
</li>
</ul>
<footer class="plan__footer">
<button type="button" class="plan__cta">
<span>Start free</span>
</button>
<div class="plan__meta">
<span><span class="plan__meta-dot"></span> No credit card</span>
<span>For side projects</span>
</div>
</footer>
</article>
<!-- PLAN: Growth (Popular) -->
<article class="plan plan--popular" tabindex="-1">
<span class="plan__badge">Most Popular</span>
<header class="plan__header">
<h2 class="plan__name">Growth</h2>
<p class="plan__tagline">For teams shipping product.</p>
<div class="plan__price-row">
<span class="plan__currency">$</span>
<span class="plan__price-main">29</span>
<span class="plan__period">/month</span>
</div>
<p class="plan__note">
Best for growing teams that need collaboration and advanced analytics.
</p>
</header>
<hr class="plan__divider" />
<ul class="plan__features">
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label"><strong>15</strong> active projects</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
<strong>100 GB</strong> secure storage
<button
type="button"
class="tooltip"
data-tooltip="Redundant, encrypted storage with daily snapshots and 30-day backup retention."
aria-label="More info about secure storage"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
Advanced analytics
<button
type="button"
class="tooltip"
data-tooltip="Funnels, cohorts, custom segments, and data export via CSV & API."
aria-label="More info about advanced analytics"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
Team workspaces
<button
type="button"
class="tooltip"
data-tooltip="Invite unlimited viewers, with up to 10 editors. Role-based access controls included."
aria-label="More info about team workspaces"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span>Priority chat & email support</span>
</div>
</li>
</ul>
<footer class="plan__footer">
<button type="button" class="plan__cta">
<span>Upgrade to Growth</span>
</button>
<div class="plan__meta">
<span><span class="plan__meta-dot"></span> Most teams choose this</span>
<span>Usage-based overages</span>
</div>
</footer>
</article>
<!-- PLAN: Scale -->
<article class="plan" tabindex="-1">
<header class="plan__header">
<h2 class="plan__name">Scale</h2>
<p class="plan__tagline">For companies with complex needs.</p>
<div class="plan__price-row">
<span class="plan__currency">$</span>
<span class="plan__price-main">79</span>
<span class="plan__period">/month</span>
</div>
<p class="plan__note">
Includes premium support, SSO, and onboarding assistance.
</p>
</header>
<hr class="plan__divider" />
<ul class="plan__features">
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
Unlimited projects
<button
type="button"
class="tooltip"
data-tooltip="Create as many projects as you like, subject to fair-use resource limits."
aria-label="More info about unlimited projects"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
<strong>2 TB</strong> storage & custom retention
<button
type="button"
class="tooltip"
data-tooltip="Default retention up to 2 years. Can be extended for compliance use cases."
aria-label="More info about data retention"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span class="feature-label">
SSO & advanced security
<button
type="button"
class="tooltip"
data-tooltip="SAML/SCIM, audit logs, IP allowlists, and granular role-based access control."
aria-label="More info about security features"
>?</button>
</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span>Dedicated customer success manager</span>
</div>
</li>
<li class="plan__feature">
<div class="plan__feature-icon plan__feature-icon--check">✓</div>
<div class="plan__feature-text">
<span>24/7 emergency support</span>
</div>
</li>
</ul>
<footer class="plan__footer">
<button type="button" class="plan__cta">
<span>Talk to sales</span>
</button>
<div class="plan__meta">
<span><span class="plan__meta-dot"></span> Custom contracts</span>
<span>Volume discounts</span>
</div>
</footer>
</article>
</section>
</main>
<script>
// Basic tooltip logic:
// - Click to toggle (good for touch screens)
// - One tooltip open at a time
// - Close on outside click or Escape
(function () {
const tooltips = Array.from(document.querySelectorAll(".tooltip"));
function closeAllTooltips() {
tooltips.forEach((btn) => {
btn.classList.remove("tooltip--active");
btn.setAttribute("aria-expanded", "false");
});
}
tooltips.forEach((btn) => {
// For accessibility, mark them as toggle buttons
btn.setAttribute("aria-haspopup", "true");
btn.setAttribute("aria-expanded", "false");
btn.addEventListener("click", (event) => {
event.stopPropagation();
const isActive = btn.classList.contains("tooltip--active");
closeAllTooltips();
if (!isActive) {
btn.classList.add("tooltip--active");
btn.setAttribute("aria-expanded", "true");
} else {
btn.setAttribute("aria-expanded", "false");
}
});
});
// Close when clicking anywhere else
document.addEventListener("click", () => {
closeAllTooltips();
});
// Close all on Escape
document.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
closeAllTooltips();
}
});
})();
</script>
</body>
</html>
If you’d like, I can next:
- Turn the billing toggle into a working monthly/yearly switch, or
- Simplify the design for a lighter, more minimal table.