HTML Reference ยท Inline Text
The <mark> element
Reference for the HTML <mark> element: highlighting text for relevance, such as search matches or quoted passages, with accessibility notes and technical details.
The <mark> element highlights text because it is relevant to what the reader is doing right now. The classic example is search results, where the words that match the query are marked. It is also used inside quotations to point out a passage the original author did not emphasize. Browsers show it with a yellow background by default.
<p>Results for "tide": the <mark>tide</mark> table for this week.</p>
Try it
Type a different word to see the matches move. The script builds <mark> elements with textContent, so what you type is never parsed as HTML.
Attributes
This element has no attributes of its own. It accepts the global attributes.
Usage notes
- Relevance, not importance.
<mark>says "this is relevant here", which can change from one visit to the next. For lasting importance use<strong>; for stress use<em>. - Not for decoration. If you only want a colored background, use CSS on a
<span>. - In quotations. When you highlight part of someone else's words inside
<blockquote>or<q>, add a note such as "emphasis added" so readers know the highlight is yours. - Accessibility. Many screen readers don't announce
<mark>by default. If the highlight carries information, also say it in text, for example "3 matches found". - Contrast. If you restyle
<mark>, keep enough contrast between the text and the highlight color, including in dark themes.
Technical summary
| Content categories | Flow content, phrasing content, palpable content |
| Permitted content | Phrasing content |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | Any element that accepts phrasing content |
| Implicit ARIA role | No corresponding role in ARIA in HTML; newer accessibility mappings expose it as mark |
| DOM interface | HTMLElement |
| Default display | inline (yellow background, black text) |
Browser support
Supported in all current browsers.
Related
<strong>โ strong importance<em>โ stress emphasis<b>โ attention without importance<search>โ a search section- Lesson: Formatting Text