Skip to content

08. mark Tag

The <mark> element highlights text, similar to using a highlighter pen on printed text. It’s useful for drawing attention to specific content, search results, or important passages. The mark element has semantic meaning, indicating that the marked text is relevant in a particular context.

<p>This is <mark>highlighted text</mark> in a paragraph.</p>

By default, browsers render <mark> with:

  • Yellow background color
  • High contrast with text
  • Similar to highlighter pen

Highlighting search terms in results:

<p>Search results for "HTML":
The <mark>HTML</mark> tutorial covers basic tags.</p>

Drawing attention to key points:

<p>Remember: <mark>Always validate your HTML</mark> before publishing.</p>

Highlighting relevant portions:

<blockquote>
<p>The <mark>most important</mark> thing is to keep learning.</p>
</blockquote>

You can customize the appearance with CSS:

<mark>Highlighted text</mark>
<style>
mark {
background-color: #ffeb3b;
padding: 2px 4px;
border-radius: 2px;
}
</style>

Use <mark> when text is relevant in a specific context:

<!-- Good: Relevant in search context -->
<p>Search for "HTML": <mark>HTML</mark> is a markup language.</p>

Avoid highlighting too much text:

<!-- Avoid: Too much highlighting -->
<p><mark>This entire paragraph is highlighted</mark> which defeats the purpose.</p>