Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight HTML text without wrapping it with tags?

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!

like image 378
Sleepster Avatar asked Nov 29 '09 18:11

Sleepster


People also ask

How do I highlight certain text in HTML?

The <mark> tag defines text that should be marked or highlighted.

How do you highlight text in HTML CSS?

How Do I Highlight Text In CSS? To Highlight text in HTML you have to use an inline element such as the <span> element and apply a specific background style on it. This will create the highlighting effect, which you can tweak in many different ways to create different looks.


1 Answers

No, it is not possible.

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).

like image 106
Mike Atlas Avatar answered Oct 01 '22 23:10

Mike Atlas