← All elements

Marker Highlight Text

by @admin · 5 views

<p class="pc-marker">
  Our <mark>handmade</mark> ceramics are <mark>glazed twice</mark> and fired in small batches.
</p>

About this hover effect

Inline highlighter marks that show a soft band at rest and sweep a stronger colour across the words on hover.

How it works

Each mark element has two background gradients. The wide pale band is always visible, and a stronger band starts at zero width. On hover the background-size of the strong band grows to full width, so the colour appears to sweep across the words. box-decoration-break: clone keeps the effect clean when the phrase wraps onto two lines.

Ways to customise it

  • Change #ffe9a8 and #ffc933 to your two highlight colours.
  • Change the 60 percent height to make the band thicker.
  • Change the 0.45s transition for a slower sweep.

Good to know

The mark element tells assistive tools that the words are highlighted, which is the right meaning for this effect. Check the text keeps enough contrast against the stronger band colour.

Open an example, copy the HTML and the CSS, and paste them into your page. There is nothing to install and no JavaScript to load.

More in Hover

View all →