Post

Style ranges of text from script without wrapping them in elements: register a Highlight, style it with ::highlight(). It has been newly available since March. One browser is still holding it back.

::highlight(search-match) { background-color: Mark; } What that deletes is the span-wrapping your find-in-page or editor code does today, purely to get a background behind a range.

Chrome and Edge now pass 99% of the suite and Firefox 95%, up from 70% when I wrote this up in March. Safari passes 65%.

0 reposts0 likes

Safari’s failures are the visible kind: highlight painting over text sized with font-relative or container-relative units, vertical writing mode, and text shadows inside highlights.