A marker scribbles back and forth behind one word until it is colored in, the way people fill a highlight by hand. One zigzag SVG path with round joins, drawn with a single dash.
Also known as: scribble behind text, rough notation highlight, zigzag marker highlight.
<div class="txt-scribble-highlight-text">Zero <span class="txt-scribble-highlight-text-word">setup<svg viewBox="0 0 100 40" aria-hidden="true"><path pathLength="1" d="M4 29 L10 10 L15 32 L21 8 L26 32 L32 8 L37 32 L43 8 L48 32 L54 8 L59 32 L65 8 L70 32 L76 8 L81 32 L87 9 L92 30 L96 15" /></svg></span> needed</div>
.txt-scribble-highlight-text {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
isolation: isolate;
white-space: nowrap;}
.txt-scribble-highlight-text-word {
position: relative;
display: inline-block;
margin: 0 0.1em;
}
.txt-scribble-highlight-text-word svg {
position: absolute;
z-index: -1;
left: 50%;
top: 50%;
width: 3.4em;
height: 1.36em;
transform: translate(-50%, -48%) rotate(-2deg);
fill: none;
stroke: color-mix(in srgb, var(--c) 38%, transparent);
stroke-width: 10;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 1 1.1;
stroke-dashoffset: 1.05;
animation: txt-scribble-highlight-text-scribble 0.9s cubic-bezier(0.45, 0, 0.55, 1) 0.3s forwards;
}
@keyframes txt-scribble-highlight-text-scribble {
to { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
.txt-scribble-highlight-text, .txt-scribble-highlight-text *, .txt-scribble-highlight-text::before, .txt-scribble-highlight-text::after, .txt-scribble-highlight-text *::before, .txt-scribble-highlight-text *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.