totn HTML

HTML: <mark> tag

This HTML tutorial explains how to use the HTML element called the <mark> tag with syntax and examples.

Description

The HTML <mark> tag is used to mark or highlight text that is of special interest or relevance in an HTML document. Browsers traditionally render the text found within the <mark> tag as text with a yellow background color. This tag is also commonly referred to as the <mark> element.

Syntax

In HTML, the syntax for the <mark> tag is:

<body>
<p>The Math test is on <mark>Friday</mark>.</p>
</body>

Sample Output


Attributes

Only the Global Attributes apply to the <mark> tag. There are no attributes that are specific to the <mark> tag.

Note

  • The HTML <mark> element is found within the <body> tag.
  • Most browsers will render the <mark> tag with a yellow background color but you can change this behavior with CSS.
  • The <mark> tag defines text that has relevance and is not intended to be used to merely apply highlighter styling. If you wish to style your text to appear highlighted, instead, use a <span> tag with the proper CSS.

Browser Compatibility

The <mark> tag has basic support with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko) 4+
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE) 9+
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <mark> tag below, exploring examples of how to use the <mark> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.