HTML
<!-- index.html: the markup styles.css works on. Edit either tab; the preview updates as you type. -->
<header class="hero">
<p class="eyebrow">CSS playground</p>
<h1>Style this page</h1>
<p>Custom properties, flexbox, grid, transitions and a hover state, all in styles.css.</p>
</header>
<main class="grid">
<article class="card">
<span class="badge">Layout</span>
<h2>Grid</h2>
<p>The cards sit in a responsive grid. Shrink the preview and watch them reflow.</p>
</article>
<article class="card">
<span class="badge">Motion</span>
<h2>Transitions</h2>
<p>Hover a card and the lift and shadow ease in.</p>
</article>
<article class="card featured">
<span class="badge">Theme</span>
<h2>Variables</h2>
<p>Change <code>--accent</code> at the top of styles.css and every card follows.</p>
</article>
</main>
CSS
/* styles.css: change any value and the preview updates as you type. */
:root {
--accent: #7c3aed;
--ink: #1a1b1e;
--muted: #5c606b;
--surface: #ffffff;
--page: #f4f5f8;
--radius: 1rem;
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 2.5rem 1.5rem;
background: var(--page);
color: var(--ink);
line-height: 1.5;
}
.hero {
max-width: 48rem;
margin: 0 auto 2rem;
}
.eyebrow {
margin: 0 0 0.5rem;
color: var(--accent);
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.hero h1 {
margin: 0 0 0.5rem;
font-size: clamp(2rem, 5vw, 3rem);
line-height: 1.1;
background: linear-gradient(90deg, var(--accent), #db2777);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.hero p {
margin: 0;
color: var(--muted);
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
gap: 1rem;
max-width: 48rem;
margin: 0 auto;
}
.card {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 1.5rem;
background: var(--surface);
border-radius: var(--radius);
box-shadow: 0 1px 2px rgba(26, 27, 30, 0.08);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 30px rgba(26, 27, 30, 0.12);
}
.card h2 {
margin: 0;
font-size: 1.25rem;
}
.card p {
margin: 0;
color: var(--muted);
}
.badge {
align-self: flex-start;
padding: 0.2rem 0.6rem;
border-radius: 999px;
background: color-mix(in srgb, var(--accent) 12%, white);
color: var(--accent);
font-size: 0.75rem;
font-weight: 700;
}
.featured {
background: var(--accent);
color: white;
}
.featured p {
color: rgba(255, 255, 255, 0.85);
}
.featured .badge {
background: rgba(255, 255, 255, 0.2);
color: white;
}
code {
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.9em;
}