Text highlighting used to mean surgery: split the text node, wrap a span, restyle, and hope the editor, the selection, and the screen reader all survived the operation. The Custom Highlight API removed the surgery. A Highlight object owns a set of Range objects, the registry at CSS.highlights gives it a name, and a highlight pseudo-element paints it — the DOM never changes.
Real products layer several categories at once. A search tool paints every match, then promotes the active match with a higher priority so it wins where ranges overlap. A glossary pass tints terms it can define. A collaboration layer marks other people’s cursors. Each category is one registry entry and one rule naming it.
The repetition shows up in the stylesheet: every category that should share a base — a readable background, an underline, a focus-friendly contrast — repeats those declarations, and a new category means editing every copy. The universal selector collapses the copies into one zero-specificity base rule that every named highlight rule overrides exactly where it means to differ.