The <mark> element represents text that is marked or highlighted for reference or notation because it is relevant in the surrounding context.
Common uses: search-result matches, or calling out a passage inside a <blockquote> / <q> (like a highlighter pen). Do not confuse it with <strong> (importance), and do not use it for code syntax highlighting — use <code> with CSS instead.
Baseline · Widely available.
Not deprecated. Stable across modern browsers since about July 2015.
Not for “make it yellow” alone.
If you only want a background color with no relevance meaning, prefer <span> + CSS. Use mark when the highlight has semantic purpose.
Syntax
HTML Syntax
syntax.html
<p>Search for <mark>salamander</mark> in the article.</p>
Both start and end tags are required. Wrap only the relevant phrase.
Reference
Attributes
<mark> has no element-specific attributes — only globals.
Switch examples to see <mark> for search, quotes, and vs strong.
Yellow background is typical UA styling for mark.
Preview
Several species of salamander inhabit the Pacific Northwest.
Search relevance — matched term highlighted.
Code
HTML Examples
Short, copy-ready snippets. Use Try It Yourself for a live editor.
Example 1 — Highlight Search Matches
Mark terms that match the user’s current search.
HTML
<p>Search results for "salamander":</p>
<p>
Several species of <mark>salamander</mark> inhabit
the temperate rainforest of the Pacific Northwest.
</p>
<p>
Most <mark>salamander</mark>s are nocturnal.
</p>
Several species of salamander inhabit the temperate rainforest of the Pacific Northwest.
Most salamanders are nocturnal.
How It Works
Wrap each match in <mark>…</mark>.
Keep surrounding text outside the mark so only the hit is highlighted.
Optional class="match" if you want separate CSS for search UI.
Repeat for every occurrence that belongs to the same query.
Example 2 — Mark Text in a Quotation
Call out a passage of special interest inside a quote.
HTML
<blockquote>
It is a period of civil war. During the battle,
<mark>Rebel spies managed to steal secret plans</mark>
to the Empire’s ultimate weapon.
</blockquote>
Use mark when the point is “this matches / note this for reference.”
Use strong when the point is “this is important.”
Do not use mark only to bold or yell at the reader.
Pick one meaning so assistive tech and CSS stay clear.
Edge Cases & Pitfalls
Most mark mistakes are wrong semantics or over-highlighting.
semantics
Confusing mark with strong
Relevance vs importance. MDN: do not treat them as interchangeable.
code
Syntax highlighting abuse
Do not wrap every keyword in mark. Use code + CSS classes instead.
style-only
Yellow for decoration only
If there is no reference meaning, use span + CSS background.
overuse
Highlighting everything
If most of the paragraph is marked, nothing stands out. Mark sparingly.
quotes
Do not invent quote emphasis
In quotations, mark is your highlight for scrutiny — keep the quoted text accurate.
Compatibility
Browser Support
The <mark> element is core HTML in every modern browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<mark>
Widely available since about July 2015. Default yellow-style highlight is common in user agents.
98%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerIE 9+
Supported
<mark>Widely supported
Bottom line: Safe for search UIs and reference highlights. Keep semantics distinct from strong and decorative spans.
Remember
Key Takeaways
Role:<mark> highlights relevant text for reference.
Uses: search matches and call-outs in quotations.
Not strong: importance belongs on strong, not mark.
Not code theme: syntax color uses code + CSS.
One line: wrap relevant phrases in <mark> when the highlight means something.
UA style
Default CSS Settings
Many browsers style mark like a highlighter (exact colors vary):
default.css
mark {
background-color: mark; /* or a yellow-ish UA color */
color: marktext;
}
You can restyle with CSS. Keep enough contrast for readability.
Frequently Asked Questions
The mark element highlights text for reference or notation because it is relevant in the current context — for example search matches or passages you call out in a quotation.
No. mark means relevance or highlighting for reference. strong means importance or seriousness. Do not swap them.
No. Use code (or similar) with CSS for code coloring. mark is for relevance in context, not token styling.
No. It only supports Global Attributes. Styling comes from CSS (browsers often use a yellow background by default).
Yes. In quotes it often marks text of special interest that was not highlighted in the original source — like a highlighter pen.
Add a class on mark (for example class="match") so you can style search highlights differently from other marks.