Pure TailwindMIT licensed

Inline Highlighted Text Tailwind Blockquote

Annotated quote with two highlighter styles on real <mark> elements: a rounded wash that repeats its padding on every wrapped line (box-decoration-clone) and a slanted-edge marker swipe. The port fixes two bugs in the original's swipe — its z-index:-1 pseudo-element slid behind the stage background, and as one absolute box it smeared across line breaks — by redrawing it as a cloned angled gradient, and makes the first highlight draw across on load.

Live Demo
Plain CSSTailwind v4
Try it

Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time

Untitled UI React · Affiliate link

Get Untitled UI Pro

The code

<section class="tbq-15 w-full min-h-svh grid place-items-center bg-tbq15-bg px-5 py-14 font-tbq15-serif text-tbq15-ink" aria-label="Inline highlighted text blockquote demo">
  <div class="grid w-full justify-items-center gap-8">
    <figure class="max-w-[58ch]">
      <p class="mb-4 font-tbq15-sans text-[11.5px] font-bold tracking-[0.2em] uppercase text-tbq15-mut">Annotated · from the postmortem</p>
      <blockquote>
        <p class="text-[clamp(20px,2.6vw,26px)] leading-[1.7] text-pretty">The outage taught us that <mark class="rounded-[0.3em] bg-transparent bg-linear-to-r from-tbq15-hl to-tbq15-hl bg-[length:100%_100%] bg-no-repeat px-[0.3em] py-[0.08em] text-inherit box-decoration-clone transition-[background-size] duration-1000 ease-[cubic-bezier(0.6,0,0.3,1)] starting:bg-[length:0%_100%] motion-reduce:transition-none">alerting is a design problem, not a tooling problem</mark> — we had forty dashboards and zero answers. The fix wasn't another graph; it was deciding, in advance, <mark class="rounded-[0.4em_0.2em_0.45em_0.25em] bg-transparent bg-[linear-gradient(100deg,transparent_0.2em,var(--color-tbq15-hl2)_0.42em,var(--color-tbq15-hl2)_calc(100%_-_0.42em),transparent_calc(100%_-_0.2em))] px-[0.4em] py-[0.04em] text-inherit box-decoration-clone">which three numbers mean the site is healthy</mark> and paging on nothing else.</p>
      </blockquote>
      <figcaption class="mt-5 font-tbq15-sans text-[13px] text-tbq15-mut">Incident review, <cite class="italic">Q3 Reliability Report</cite> — highlights by the SRE lead</figcaption>
    </figure>
    <p aria-hidden="true" class="rounded-full border border-black/10 bg-white px-3.5 py-2 font-tbq15-mono text-[11.5px] text-tbq15-mut">&lt;mark&gt; · box-decoration-clone · angled-gradient swipe</p>
  </div>
</section>
@import "tailwindcss";

@theme {
  --color-tbq15-bg: #fbfaf7;
  --color-tbq15-bg: oklch(0.985 0.004 95);
  --color-tbq15-ink: #231f17;
  --color-tbq15-ink: oklch(0.24 0.015 80);
  --color-tbq15-mut: #625d54;
  --color-tbq15-mut: oklch(0.48 0.015 80);
  --color-tbq15-hl: #f9d54499;
  --color-tbq15-hl: oklch(0.88 0.16 95 / 0.6);
  --color-tbq15-hl2: #fbb4e29e;
  --color-tbq15-hl2: oklch(0.85 0.1 340 / 0.62);
  --font-tbq15-serif: 'Newsreader', Georgia, serif;
  --font-tbq15-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-tbq15-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
   stage is sized before the browser build compiles. */

.tbq-15 {
  width: 100%;
  min-height: 100svh;
}

Setup — do this once per project

Skip this if your project already runs Tailwind v4.

1Load Tailwind
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

Compiles in the browser — perfect for a CodePen or a quick test, not for production.

2Add the stylesheetRequiredthe @theme block is what makes the custom utilities exist
@import "tailwindcss";

@theme {
  --color-tbq15-bg: #fbfaf7;
  --color-tbq15-bg: oklch(0.985 0.004 95);
  --color-tbq15-ink: #231f17;
  --color-tbq15-ink: oklch(0.24 0.015 80);
  --color-tbq15-mut: #625d54;
  --color-tbq15-mut: oklch(0.48 0.015 80);
  --color-tbq15-hl: #f9d54499;
  --color-tbq15-hl: oklch(0.88 0.16 95 / 0.6);
  --color-tbq15-hl2: #fbb4e29e;
  --color-tbq15-hl2: oklch(0.85 0.1 340 / 0.62);
  --font-tbq15-serif: 'Newsreader', Georgia, serif;
  --font-tbq15-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-tbq15-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
   stage is sized before the browser build compiles. */

.tbq-15 {
  width: 100%;
  min-height: 100svh;
}
3Fonts used by this demooptional — skip if you have your own type stack
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400..700;1,6..72,400..700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap">

What changed in the port

Which parts became utilities, which stayed CSS, and why.

  • color-mix(in oklch, var(--hl) 55%, transparent) moved into the token itself (oklch(… / 0.6)) so the gradient stops can reference it directly.
  • The skewed ::before swipe was redrawn rather than ported: one arbitrary bg-[linear-gradient(100deg,…)] plus box-decoration-clone, so each wrapped line gets its own slanted stroke.
  • UI upgrade from the CSS original: bug fixes — the original's swipe used z-index:-1 without a stacking context and painted behind the stage background, and as one absolute box it smeared across line breaks. The cloned gradient has neither problem.
  • UI upgrade: the first highlight now sweeps in over a second (starting:bg-[length:0%_100%]), and caption copy darkened 0.54 → 0.48.
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Inline Highlighted Text Tailwind Blockquote
Source: https://codefronts.com/snippets/tailwind-css-blockquotes/inline-highlighted-text-tailwind-blockquote/

Annotated quote with two highlighter styles on real <mark> elements: a rounded wash that repeats its padding on every wrapped line (box-decoration-clone) and a slanted-edge marker swipe. The port fixes two bugs in the original's swipe — its z-index:-1 pseudo-element slid behind the stage background, and as one absolute box it smeared across line breaks — by redrawing it as a cloned angled gradient, and makes the first highlight draw across on load.
## HTML
```html
<section class="tbq-15 w-full min-h-svh grid place-items-center bg-tbq15-bg px-5 py-14 font-tbq15-serif text-tbq15-ink" aria-label="Inline highlighted text blockquote demo">
  <div class="grid w-full justify-items-center gap-8">
    <figure class="max-w-[58ch]">
      <p class="mb-4 font-tbq15-sans text-[11.5px] font-bold tracking-[0.2em] uppercase text-tbq15-mut">Annotated · from the postmortem</p>
      <blockquote>
        <p class="text-[clamp(20px,2.6vw,26px)] leading-[1.7] text-pretty">The outage taught us that <mark class="rounded-[0.3em] bg-transparent bg-linear-to-r from-tbq15-hl to-tbq15-hl bg-[length:100%_100%] bg-no-repeat px-[0.3em] py-[0.08em] text-inherit box-decoration-clone transition-[background-size] duration-1000 ease-[cubic-bezier(0.6,0,0.3,1)] starting:bg-[length:0%_100%] motion-reduce:transition-none">alerting is a design problem, not a tooling problem</mark> — we had forty dashboards and zero answers. The fix wasn't another graph; it was deciding, in advance, <mark class="rounded-[0.4em_0.2em_0.45em_0.25em] bg-transparent bg-[linear-gradient(100deg,transparent_0.2em,var(--color-tbq15-hl2)_0.42em,var(--color-tbq15-hl2)_calc(100%_-_0.42em),transparent_calc(100%_-_0.2em))] px-[0.4em] py-[0.04em] text-inherit box-decoration-clone">which three numbers mean the site is healthy</mark> and paging on nothing else.</p>
      </blockquote>
      <figcaption class="mt-5 font-tbq15-sans text-[13px] text-tbq15-mut">Incident review, <cite class="italic">Q3 Reliability Report</cite> — highlights by the SRE lead</figcaption>
    </figure>
    <p aria-hidden="true" class="rounded-full border border-black/10 bg-white px-3.5 py-2 font-tbq15-mono text-[11.5px] text-tbq15-mut">&lt;mark&gt; · box-decoration-clone · angled-gradient swipe</p>
  </div>
</section>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-tbq15-bg: #fbfaf7;
  --color-tbq15-bg: oklch(0.985 0.004 95);
  --color-tbq15-ink: #231f17;
  --color-tbq15-ink: oklch(0.24 0.015 80);
  --color-tbq15-mut: #625d54;
  --color-tbq15-mut: oklch(0.48 0.015 80);
  --color-tbq15-hl: #f9d54499;
  --color-tbq15-hl: oklch(0.88 0.16 95 / 0.6);
  --color-tbq15-hl2: #fbb4e29e;
  --color-tbq15-hl2: oklch(0.85 0.1 340 / 0.62);
  --font-tbq15-serif: 'Newsreader', Georgia, serif;
  --font-tbq15-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-tbq15-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
   stage is sized before the browser build compiles. */

.tbq-15 {
  width: 100%;
  min-height: 100svh;
}
```

How this works

Why the swipe is a gradient now. The original drew the marker as a skewed ::before with z-index:-1. Negative z-index paints below every block in the stacking context — including the section background — so it never showed; and an absolutely positioned box on a wrapping inline spans the fragments' bounding box, smearing across lines. A background has neither problem:

<mark class="rounded-[0.4em_0.2em_0.45em_0.25em] bg-transparent box-decoration-clone
  bg-[linear-gradient(100deg,transparent_0.2em,var(--color-tbq15-hl2)_0.42em,
  var(--color-tbq15-hl2)_calc(100%_-_0.42em),transparent_calc(100%_-_0.2em))]">

The 100° angle makes each end slant like a chisel-tip marker, and box-decoration-clone repeats the whole stroke — slants, padding, radius — on every wrapped line.

Draw-in without JS. The first mark's colour is a gradient image sized 100% 100%; starting:bg-[length:0%_100%] gives it a zero-width start, so it sweeps across once when the page renders.

Make it yours

  • Colour per author: mint more --color-tbq15-hl* tokens.
  • Underline-style highlight: bg-[length:100%_40%] bg-bottom.
  • No animation: remove the starting: and transition- utilities.

Gotchas — read before shipping

  • Browsers style <mark> yellow with black text by default — bg-transparent text-inherit resets both.
  • Keep the angled gradient's stops in em so the slant scales with the type; percentage stops would leave short fragments almost empty.
  • Screen readers don't announce <mark> by default; if the highlight carries meaning, say so in text ("highlights by the SRE lead").

Browser support

ChromeSafariFirefoxEdge
111+16.4+128+111+

box-decoration-break: clone is unprefixed in Chrome 130 / Firefox 32 and -webkit- in Safari; Tailwind emits both.

Techniques used in this demo

Search CodeFronts

Loading…