Mark

background-clip: text makes the highlight part of the typography instead of an overlay.

Description

mark does not paint a yellow background: it applies a linear gradient from $color-secondary to $color-primary, clips it to the text with background-clip: text and makes the color transparent, so the letters themselves take the gradient.

The gradient endpoints follow $color-secondary and $color-primary, so --forma-color-primary / --forma-color-secondary retint every highlight at runtime.

Highlight in running text

Works on any text, stays readable in light and dark mode, and no class or wrapper is needed. The wrapper div here only exists to retint the gradient for the demo.

forma-css is light, semantic and zero-JS by design.

HTML
<div style="--forma-color-primary:red;--forma-color-secondary:green">
  <h3>forma-css is <mark>light, semantic and zero-JS</mark> by design.</h3>
</div>