DEV Community

loading...
Cover image for HTML mark tag a digital marker

HTML mark tag a digital marker

dailydevtips1 profile image Chris Bongers Originally published at daily-dev-tips.com ・2 min read

Although Mark is also a name, it's not what this HTML attribute is used for.

Mark is used to describing a highlight of a text, to mark it, or highlight it.

How it works:

<p>This is some <mark>highlighted text</mark> using the Mark tag.</p>
Enter fullscreen mode Exit fullscreen mode

And that will result in:

Mark element in HTML result

Custom styling the Mark tag

We can also add custom styling to our mark tag.

mark {
  background: purple;
  color: white;
}
Enter fullscreen mode Exit fullscreen mode

This will give the following result:

Mark tag with custom CSS

Common use cases for the mark tag

One place where you often find the mark tag being used is on search result pages.

You'll find the word you were looking for highlighted.

<h3>Search results for "Pikachu"</h3>
<p><mark>Pikachu</mark> is a mouse like PokΓ©mon.</p>
<p>The evolution of Pichu is <mark>Pikachu</mark>.</p>
Enter fullscreen mode Exit fullscreen mode

Search results with mark tag

Demo

You can have a play with the following Codepen I set up to showcase the mark tag.

Browser support

The mark tag is really well supported and safe to use.

HTML mark element browser support

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Discussion (0)

pic
Editor guide