Live Preview
Default yellow highlight styling:
This paragraph contains some important information you should notice.

By the end of this tutorial, you’ll highlight relevant text with <mark> for search results, references, and contextual emphasis.
Wrap highlighted words in <mark> tags.
Mark text relevant in the current context.
Highlight matched query terms.
Highlight vs importance — know the difference.
Customize highlight colors with CSS.
Use sparingly for meaningful highlights.
<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.
<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.
Wrap the text you want to highlight between opening and closing <mark> tags:
<mark>Your highlighted text here</mark><mark> requires both opening and closing tags.class or the mark selector.| Pattern | Code Snippet | Result |
|---|---|---|
| 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 style | Browser default | Yellow background |
| Attributes | Global only | class, id |
<mark> vs <strong>| Tag | Meaning | Best for |
|---|---|---|
<mark> | Relevant / referenced text | Search matches, quoted highlights |
<strong> | Strong importance | Warnings, key instructions |
<em> | Emphasized stress | Tone change when spoken |
<b> | Stylistic bold | Visual weight without semantics |
<mark> vs <span>| Approach | Markup | Notes |
|---|---|---|
| Semantic highlight | <mark>term</mark> | Correct for relevance |
| Styled span | <span style="background:yellow"> | Avoid — no semantic meaning |
| Screen readers | May announce as highlighted | Only with mark |
The <mark> element has no unique attributes — only global attributes apply:
class GlobalApply custom highlight colors or styles via CSS classes.
class="search-hit"id GlobalUnique identifier for scripting or linking to a highlighted passage.
id="highlight-1"<p>This paragraph contains some <mark>important</mark> information.</p>Basic highlights, instructional emphasis, and search result patterns.
Default yellow highlight styling:
This paragraph contains some important information you should notice.
Wrap key words inside a paragraph with <mark>.
<p>This paragraph contains some <mark>important</mark> information.</p>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.
Draw attention to a specific word in instructions or warnings.
<p>Make sure to pay <mark>attention</mark> to the following instructions.</p>The classic use case — wrap matched search terms in <mark>.
<p>Search results for "<mark>web development</mark>" include various tutorials and resources.</p>Override the default yellow highlight or create themed variants:
background Highlight colorcolor Text contrastpadding Inner spacingborder-radius Rounded highlights/* 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
Default: highlight · Search: query · Accent: note
Use <mark> thoughtfully for inclusive content:
Place <mark> around words that are relevant in context.
Default yellow background makes the text visually distinct.
Override colors, padding, and border-radius for themed highlights.
Users quickly spot search matches and referenced passages.
The <mark> element is an HTML5 semantic tag with full support in all modern browsers and Internet Explorer 9+.
From IE9 to the latest mobile browsers — mark renders with a visible highlight in every environment.
Bottom line: Use <mark> confidently for semantic text highlighting in every production environment today.
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.
mark for search matches and referencesstrong when meaning importance, not highlightstrong or em with mark<mark>Bookmark these before you highlight text on your pages.
<mark> highlights relevant text.
Classic use: wrap matched query terms.
Use caseHighlight ≠ importance.
ComparisonBrowsers render a highlighter style.
RenderingOverride colors with CSS classes.
StylingHTML5 tag — IE9+ and all modern browsers.
Compatibilitymark = highlighted for relevance. strong = important or urgent. Different semantic meanings.class and id apply.mark or mark.classname with CSS background and color properties.Try basic highlights, instructions, and search results in the interactive editor.
6 people found this page helpful