HIGHLIGHT TEXT

You can highlight text in a web page, just like a highlighter pen on paper, using the new mark element in HTML5. This enables you to put additional new emphasis on a block of text, without using the older methods such as italicizing, bolding, or underlining:

<mark>text</mark>

Essentially, the mark element simply adds a yellow background color to enclosed text. The following CSS is built into all HTML5 web browsers:

mark {
 background-color: yellow;
}

Most non-HTML5 web browsers will understand <mark>, but you will need to explicitly assign it a CSS declaration, just as in the preceding example. A good general guideline is to assign a value regardless; this way both newer and older HTML web browsers work fine.

In order for ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.