Inline
HTML5
The mark text element represents text that is marked or highlighted for reference or notation purposes due to its relevance in a particular context.
<mark>highlighted text</mark>
The <mark> element is typically rendered with a yellow background, like a highlighter pen.
Use <mark> for:
- Search result highlighting
- Current match in a search
- Referenced portions in quotes
- Relevant passages for the current context
- Highlighted annotations
<!-- Contextual relevance/highlighting -->
<p>Search: <mark>HTML</mark></p>
<!-- Strong importance -->
<p><strong>Warning:</strong> Do not proceed</p>
<p>I <em>really</em> need this</p>
<!-- Keywords, no importance -->
<p>Features: <b>fast</b>, <b>reliable</b></p>
Customize the highlight appearance:
Most screen readers don’t announce <mark> differently from regular text. The highlighting is primarily visual.
For important highlights, provide textual context:
<p><mark>$99.99</mark></p>
<p>Special price: <mark>$99.99</mark> (save $50!)</p>
For search highlighting, consider ARIA attributes:
<p aria-label="Search result: HTML elements">
Results for <mark>HTML elements</mark>
Too many highlights lose impact:
<p><mark>This</mark> is <mark>very</mark> <mark>important</mark> <mark>information</mark>.</p>
<p><mark>This is very important information.</mark></p>
Using JavaScript to highlight search terms:
| Browser | Version | Notes |
|---|
| Chrome | 7+ | Full support |
| Firefox | 4+ | Full support |
| Safari | 5.1+ | Full support |
| Edge | 79+ | Full support |
| IE | 9+ | Full support |
The <mark> element is an HTML5 feature with excellent browser support.