HTML <mark> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Text Highlighting

What You’ll Learn

By the end of this tutorial, you’ll highlight relevant text with <mark> for search results, references, and contextual emphasis.

01

Core Syntax

Wrap highlighted words in <mark> tags.

02

Semantic Meaning

Mark text relevant in the current context.

03

Search Results

Highlight matched query terms.

04

mark vs strong

Highlight vs importance — know the difference.

05

CSS Styling

Customize highlight colors with CSS.

06

Best Practices

Use sparingly for meaningful highlights.

What Is the <mark> Tag?

The mark element (<mark>) represents text highlighted for reference or relevance in the current context — like a highlighter pen on a page. It is most commonly used for search query matches, quoted passages, or text a user should notice.

💡
Not the same as bold or strong

<mark> means “this text is relevant here” (e.g. a search match). <strong> means “this text is important.” Use the right tag for the right purpose.

Browsers typically render <mark> with a yellow background by default, making highlighted words stand out visually without changing document structure.

📝 Syntax

Wrap the text you want to highlight between opening and closing <mark> tags:

syntax.html
<mark>Your highlighted text here</mark>

Syntax Rules

  • <mark> requires both opening and closing tags.
  • Use inside phrasing content: paragraphs, headings, list items, etc.
  • Do not nest mark inside mark unnecessarily.
  • Style with CSS via class or the mark selector.

⚡ Quick Reference

PatternCode SnippetResult
Basic highlight<mark>text</mark>text
In paragraph<p>Some <mark>word</mark></p>Some word
Search match<mark>query</mark>Highlighted term
Custom class<mark class="accent">accent
Default styleBrowser defaultYellow background
AttributesGlobal onlyclass, id

⚖️ <mark> vs <strong>

TagMeaningBest for
<mark>Relevant / referenced textSearch matches, quoted highlights
<strong>Strong importanceWarnings, key instructions
<em>Emphasized stressTone change when spoken
<b>Stylistic boldVisual weight without semantics

⚖️ Semantic <mark> vs <span>

ApproachMarkupNotes
Semantic highlight<mark>term</mark>Correct for relevance
Styled span<span style="background:yellow">Avoid — no semantic meaning
Screen readersMay announce as highlightedOnly with mark

🧰 Attributes

The <mark> element has no unique attributes — only global attributes apply:

class Global

Apply custom highlight colors or styles via CSS classes.

class="search-hit"
id Global

Unique identifier for scripting or linking to a highlighted passage.

id="highlight-1"
mark-in-paragraph.html
<p>This paragraph contains some <mark>important</mark> information.</p>

Examples Gallery

Basic highlights, instructional emphasis, and search result patterns.

Live Preview

Default yellow highlight styling:

This paragraph contains some important information you should notice.

Highlight Important Information

Wrap key words inside a paragraph with <mark>.

basic-mark.html
<p>This paragraph contains some <mark>important</mark> information.</p>

📚 Common Use Cases

Use <mark> for search result query highlighting, referenced quotes, study notes, documentation cross-references, and any text that is relevant because of the user’s current context.

Instructional Highlight

Draw attention to a specific word in instructions or warnings.

instruction-mark.html
<p>Make sure to pay <mark>attention</mark> to the following instructions.</p>
Try It Yourself

Styling <mark> with CSS

Override the default yellow highlight or create themed variants:

background Highlight color
color Text contrast
padding Inner spacing
border-radius Rounded highlights
mark-styles.css
/* Default override */
mark {
  background: #fef08a;
  color: #0f172a;
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
}

/* Search hit variant */
mark.search-hit {
  background: #fde68a;
  color: #78350f;
}

/* Blue accent variant */
mark.accent {
  background: #bfdbfe;
  color: #1e3a8a;
}

Custom highlight variants

♿ Accessibility

Use <mark> thoughtfully for inclusive content:

  • Use for relevance — mark indicates text highlighted because of context, not arbitrary decoration.
  • Ensure contrast — custom highlight backgrounds must meet WCAG contrast ratios with the text color.
  • Do not overuse — too many highlights reduce scannability for all users.
  • Prefer mark over styled spans — semantic markup helps assistive technology convey purpose.

🧠 How <mark> Works

1

Author wraps relevant text

Place <mark> around words that are relevant in context.

Markup
2

Browser applies highlight

Default yellow background makes the text visually distinct.

Rendering
3

CSS can customize appearance

Override colors, padding, and border-radius for themed highlights.

Styling
=

Scannable, relevant content

Users quickly spot search matches and referenced passages.

Universal Browser Support

The <mark> element is an HTML5 semantic tag with full support in all modern browsers and Internet Explorer 9+.

Baseline · HTML5

Text highlighting that works everywhere

From IE9 to the latest mobile browsers — mark renders with a visible highlight in every environment.

100% Core tag support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 9+ · Yellow highlight
Full support
Opera All modern versions
Full support
<mark> tag 100% supported

Bottom line: Use <mark> confidently for semantic text highlighting in every production environment today.

Conclusion

The <mark> tag is a simple, semantic way to highlight text that is relevant in the current context — especially search query matches and referenced passages.

Use it instead of styled spans, distinguish it from <strong> for importance, and customize the appearance with CSS when the default yellow is not enough.

💡 Best Practices

✅ Do

  • Use mark for search matches and references
  • Keep highlights relevant to the current context
  • Ensure sufficient color contrast with CSS
  • Use strong when meaning importance, not highlight

❌ Don’t

  • Highlight entire paragraphs with mark
  • Use mark as a generic yellow background
  • Replace strong or em with mark
  • Over-highlight — it loses meaning

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <mark>

Bookmark these before you highlight text on your pages.

6
Core concepts
🔍 02

Search Results

Classic use: wrap matched query terms.

Use case
⚖️ 03

Not strong

Highlight ≠ importance.

Comparison
🎨 04

Yellow Default

Browsers render a highlighter style.

Rendering
🎨 05

CSS Custom

Override colors with CSS classes.

Styling
06

Universal Support

HTML5 tag — IE9+ and all modern browsers.

Compatibility

❓ Frequently Asked Questions

It highlights text that is relevant or referenced in the current context, such as search query matches.
mark = highlighted for relevance. strong = important or urgent. Different semantic meanings.
No unique attributes. Only global attributes like class and id apply.
Most browsers use a yellow background with dark text, like a highlighter marker.
Yes. Style mark or mark.classname with CSS background and color properties.
Yes. Full support in all modern browsers and Internet Explorer 9 and later.

Practice Text Highlighting

Try basic highlights, instructions, and search results in the interactive editor.

Try It Yourself →

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.

6 people found this page helpful