pseudo-element
::highlight() — CSS reference
Styles named ranges registered through CSS.highlights. A rule by itself creates no range; register a Highlight with Range objects. The highlight does not wrap or mutate the original text nodes. Feature-detect the API and keep text readable if absent.
Formal Syntax & Structure
css syntaxcss
::highlight(name) { background-color: gold; }Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS reference lab</title><style>::highlight(found) {background-color:#ffd966;color:#202020}</style><body><p id="a">Find the keyword here.</p><script>if (CSS.highlights && typeof Highlight!=="undefined") {const r=document.createRange();r.setStart(a.firstChild,9);r.setEnd(a.firstChild,16);CSS.highlights.set("found",new Highlight(r));}</script></body></html>