How to highlight HTML text without wrapping it with tags?

dom, highlight, highlighting, html, javascript

Solution

No, it is not possible in a portable manner across all browsers.

You can't tell the browser to render a piece of text differently without inherently changing the DOM, regardless of whether you do it statically or dynamically (with Javascript, for example, as a post processing step).

Edit: In Chrome starting around 2019, you can use Scroll To Text Fragment, but this is not an HTML or browser standard feature.

Problem

Is it possible to highlight text in an HTML document using without wrapping it with `<span>` or any other tag for that matter? For example, in the HTML code `<p>The quick fox</p>` I would like to highlight `quick` but without adding a DOM element around it. Adding a DOM element to a parent element is fine. Thanks!

Original source

Related problems