HTML <mark> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

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.

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.

Attributes

<mark> has no element-specific attributes — only globals.

AttributeDescriptionTry it
(none required)A bare <mark> highlights the enclosed textTry it
class (global)Optional hook to style search matches separately (e.g. class="match")Try it
Use in quotesMark interest inside blockquote / qTry it
vs strongmark = relevance; strong = importanceTry it

Global Attributes

The <mark> tag also supports the Global Attributes in HTML.

Live Preview

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.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

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>
Try It Yourself

How It Works

  1. Quote the source with blockquote (or q for short quotes).
  2. Wrap the interesting clause in mark.
  3. Meaning: your highlight, not necessarily the original author’s emphasis.
  4. Keep the quote accurate — mark does not change the quoted words.

Example 3 — mark vs strong

Relevance highlight versus importance.

HTML
<p>
  Your search for <mark>deadline</mark> found one match.
</p>
<p>
  <strong>Warning:</strong> the form closes in one hour.
</p>
Try It Yourself

How It Works

  1. Use mark when the point is “this matches / note this for reference.”
  2. Use strong when the point is “this is important.”
  3. Do not use mark only to bold or yell at the reader.
  4. 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.

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 Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer IE 9+
Supported
<mark> Widely supported

Bottom line: Safe for search UIs and reference highlights. Keep semantics distinct from strong and decorative spans.

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.

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.

Next: marquee

See the obsolete marquee element and what to use instead.

marquee tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful