The CSS Custom Highlight API lets you style text highlights created with window.getSelection()
or Range
objects—something previously limited to ::selection
. Using ::highlight(name)
, you can apply custom CSS to specific text ranges via JavaScript. This enables fine-grained control over multiple, overlapping highlights with distinct visual styles, ideal for editors, annotations, or search results.