- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <mark> Tag
HTML Tags
HTML <mark> Tag
The mark tag highlights text like a yellow highlighter pen. Use it for words that are relevant to what the reader is doing right now, like their search term in the results.
That "right now" is the key. <mark> is not for important text (that is <strong>) or for decoration. It says: this is the bit you were looking for.
Syntax
html
<mark>Highlighted text here</mark>It has no special attributes, only the global ones such as class, id, style and title.
Example
html
<!DOCTYPE html>
<html>
<head>
<title>MARK Tag Example</title>
<style>
.highlighted {
background-color: #ffeb3b;
color: #000;
padding: 2px 4px;
border-radius: 2px;
}
</style>
</head>
<body>
<h1>HTML <mark> Tag Example</h1>
<p>
This is an example of <mark class="highlighted" id="search-term" title="Highlighted Text">highlighted text</mark> in a paragraph.
</p>
<p>
Example: The keyword <mark>HTML tutorial</mark> was found in the search results.
</p>
</body>
</html>Both highlighted phrases appear with a yellow background. The first one has its own style from the highlighted class; the second uses the browser's default.
Where mark makes sense
- Search results, with the searched word highlighted.
- A quote where you highlight the part you are discussing.
- Code examples where you point at the line that changed.
Changing the color
A softer highlight
css
mark {
background-color: #fde68a;
color: inherit;
}If you change the background, check that the text is still easy to read, especially in dark mode.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
- Screen readers usually do not announce
<mark>. If the highlight carries meaning, say so in words too, for example "3 results for 'html'". - Do not highlight half the page. When everything is marked, nothing stands out.
- For text that matters more, use the strong tag.
HTML <mark> Tag exercises
Highlight a match
Write this paragraph: Results for grid in CSS. Highlight only the word grid, as a search page would.
Result
