HTML mark Element

HTML <mark> Element: Shine a Light on Key Text

Sometimes, you want to draw the reader’s eye to something important — a keyword, a match, a standout term. The <mark> element lets you do just that. It gives text semantic emphasis and visual highlighting, especially useful for search interfaces and annotations.

What Is the <mark> Element?

The <mark> element highlights text that is relevant to a user’s current action or context — like search results or selected keywords. By default, browsers render it with a yellow background, similar to a highlighter pen.

Basic Syntax

<p>My favorite fruit is <mark>banana</mark>. I eat one every day!</p>
My favorite fruit is banana. I eat one every day!

The word "banana" stands out visually — and semantically.

Common Use Cases

  • Highlighting search result matches
  • Annotating or emphasizing passages in a document
  • Marking important changes or new content
  • Temporarily drawing attention to key phrases

Example: Search Results Page

<p>Search results for “apple”:</p>
<p>The <mark>apple</mark> is sweet and crisp.</p>
Search results for “apple”:  
The apple is sweet and crisp.

Example: Contextual Highlight in an Article

<article>
  <h2>Benefits of Cherries</h2>
  <p>Cherries are <mark>rich in antioxidants</mark> and help reduce inflammation.</p>
</article>

Styling with CSS

The <mark> tag comes with default yellow background styling, but you can customize it with CSS:

mark {
  background-color: #ffe066;
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

Accessibility and Semantics

Screen readers may announce <mark> with emphasis or a tonal cue. Use it only when you want to highlight text that has a reason for standing out in the current context — not just to make something look yellow.

Best Practices

  • Use <mark> to highlight relevant user-focused text
  • Avoid using it purely for visual effect — <strong> or <em> might be better for emphasis
  • Keep highlights short and context-aware

Summary

The <mark> element helps you highlight what matters — whether it’s a fruit name in a recipe search or a key update in your blog. You’ve now learned how to:

  • Use <mark> for semantic text highlighting
  • Support search, annotation, and real-time emphasis
  • Style it with CSS and keep it accessible

Check your understanding 1

What is the main purpose of the <mark> element in HTML?
Choose one answer. You can try again.

Answer and explanation

To highlight text for emphasis or reference

The <mark> element semantically highlights text, often used to emphasize search results or important parts of the content.

Check your understanding 2

The <mark> element should only be used for decorative styling without semantic meaning.
Choose one answer. You can try again.

Answer and explanation

False

The <mark> element provides semantic meaning that the enclosed text is highlighted for a reason, such as search results or attention.

Check your understanding 3

Choose the option that lists all and only the correct statements.

  1. Highlighting search terms in a document
  2. Marking up important warnings
  3. Changing the font size
  4. Emphasizing text in a paragraph
Which of the following are appropriate uses for the <mark> element?
Choose one answer. You can try again.

Answer and explanation

Statements 1 and 2

The <mark> element is intended to highlight text that requires user attention, such as search terms or warnings, rather than general emphasis or styling.

Check your understanding 4

Which default style is applied by browsers to the <mark> element?
Choose one answer. You can try again.

Answer and explanation

Yellow background highlight

Most browsers render the <mark> element with a yellow background highlight to visually indicate the marked text.

Check your understanding 5

The <mark> element improves accessibility by signaling highlighted text to assistive technologies.
Choose one answer. You can try again.

Answer and explanation

True

Since <mark> carries semantic meaning, screen readers and other assistive technologies can interpret it as important highlighted text.

Check your understanding 6

Choose the option that lists all and only the correct statements.

  1. <em>
  2. <strong>
  3. <u>
  4. <del>
Which HTML elements are similar in purpose to <mark> but serve different semantic roles?
Choose one answer. You can try again.

Answer and explanation

Statements 1 and 2

<em> and <strong> emphasize importance or stress in content, whereas <mark> highlights text without implying emphasis.

What’s Next?

Next, we’ll wrap up with a review of how semantic HTML improves structure, accessibility, and SEO — bringing it all together for better web design.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: HTML Multimedia →