12 CSS Code Blocks 08 / 12

Inline Code Snippet Pill Styling

Editorial article styling on cream textured paper showing standalone <code>&lt;code&gt;</code> pills woven into serif prose — tiny <code>2px 8px</code> padding, full pill <code>border-radius: 999px</code>, color variants (green / blue / orange), and <code>vertical-align: middle</code> so the line-height never breaks around them.

Best forlong-form technical articles, design system documentation, blog posts mixing prose and short identifiers, and any reading surface where inline code references need to feel typographically settled, not jarring.

Pure CSS MIT licensed
Live Demo Open in tab
Open in playground

The code

<section class="ccb-inl" aria-label="Inline code pill styling demo">
  <div class="ccb-inl__prose">
    <p class="ccb-inl__lead">When you set <code class="ccb-inl__c">display: grid</code> on a container, every direct child becomes a grid item. Use <code class="ccb-inl__c ccb-inl__c--blue">gap</code> instead of margins to space them, and reach for <code class="ccb-inl__c">minmax()</code> when columns need to flex.</p>
    <p>Avoid setting a fixed <code class="ccb-inl__c ccb-inl__c--warn">height</code> on the wrapper — let the content define it. If you must clamp it, pair <code class="ccb-inl__c">max-height</code> with <code class="ccb-inl__c">overflow: auto</code> so nothing gets visually clipped <em class="ccb-inl__em">without a scroll affordance</em>.</p>
    <p>Finally, run <code class="ccb-inl__c ccb-inl__c--blue">npm run build</code> and confirm the <code class="ccb-inl__c">line-height</code> stays uniform — the pill should never push a line taller than its neighbors.</p>
  </div>
</section>
/* ─── 08 Inline Code Snippet Pill Styling ──────── */
@import url('https://fonts.googleapis.com/css2?family=Spline+Sans+Mono:wght@500;600&family=Newsreader:ital,opsz,wght@0,18..72,400;0,18..72,500;1,18..72,400&display=swap');

.ccb-inl {
  --ccb-inl-paper: #fcfbf7;
  --ccb-inl-ink: #23201c;
  --ccb-inl-muted: #6b6459;
  --ccb-inl-pill-bg: #eef0e8;
  --ccb-inl-pill-ink: #3f6b3a;
  --ccb-inl-accent: #b4532a;

  width: 100%;
  min-height: 360px;
  background: var(--ccb-inl-paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,.04) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ccb-inl-ink);
  font-family: 'Newsreader', Georgia, serif;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
  box-sizing: border-box;
}
.ccb-inl *, .ccb-inl *::before, .ccb-inl *::after { box-sizing: border-box; }

.ccb-inl__prose {
  max-width: 540px;
  font-size: 18px; line-height: 1.85; letter-spacing: .005em;
}
.ccb-inl__prose p { margin-bottom: 1.2em; }
.ccb-inl__prose p:last-child { margin-bottom: 0; }

.ccb-inl__c {
  font-family: 'Spline Sans Mono', monospace;
  font-size: .82em; font-weight: 600;
  background: var(--ccb-inl-pill-bg);
  color: var(--ccb-inl-pill-ink);
  padding: 2px 8px; border-radius: 999px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,.05);
  white-space: nowrap;
}
.ccb-inl__c--warn { background: #f7e9e1; color: var(--ccb-inl-accent); }
.ccb-inl__c--blue { background: #e6eef7; color: #2d5d8a; }
.ccb-inl__em { color: var(--ccb-inl-muted); }
.ccb-inl__lead::first-letter {
  font-size: 3.2em; float: left; line-height: .8;
  padding: 6px 10px 0 0;
  color: var(--ccb-inl-accent); font-weight: 500;
}

Search CodeFronts

Loading…