Mark Tag in HTML5

The <mark> tag was introduced in HTML 5. The HTML <mark> tag is used for indicating text as marked or highlighted for reference purposes, due to its relevance in another context. The <mark> tag is supported in all major browsers. Use the <mark> tag if you want to highlight parts of your text. We can mark the text using many properties from global attributes of html5 e.g. by changing font ,background color ,font color etc. This tag must have opening and closing <mark> tag.

Syntax

The syntax of the <mark> tag is as.

<Mark>...</Mark>

example

<p>Do not forget to buy <mark>milk</mark> today.</p>

Attributes

HTML tags can contain one or more attributes. Attributes are added to a tag to provide the browser with more information about how the tag should appear or behave. Attributes consist of a name and a value separated by an equals (=) sign, with the value surrounded by double quotes.

There are 3 kinds of attributes that you can add to your HTML tags: Element-specific, global, and event handler content attributes. The attributes that you can add to this tag are listed below.

Element-Specific Attributes

The following table shows the attributes that are specific to this tag/element.

Attributes Introduced by HTML5
AttributesDescription             
None 

Global Attributes

The following attributes are standard across all HTML 5 tags.

HTML5 Global Attributes

accesskey draggablestyle
class hidden tabindex
dirspellcheck  
contenteditableidtitle
contextmenu lang 

Event Handler Content Attributes

Here are the standard HTML 5 event handler content attributes.

onabortonerror*onmousewheel
onblur*onfocus*onpause
oncanplayonformchangeonplay
oncanplaythroughonforminputonplaying
onchangeoninputonprogress
onclickoninvalidonratechange
oncontextmenuonkeydownonreadystatechange
ondblclickonkeypressonscroll
ondragonkeyuponseeked
ondragendonload*onseeking
ondragenteronloadeddataonselect
ondragleaveonloadedmetadataonshow
ondragoveronloadstartonstalled
ondragstartonmousedownonsubmit
ondroponmousemoveonsuspend
ondurationchangeonmouseoutontimeupdate
onemptiedonmouseoveronvolumechange
onendedonmouseuponwaiting

For example

<!DOCTYPE HTML>

<html>

<body>

The mark tag was introduced in HTML 5. <mark style="background-color:yellow;">The HTML mark tag is used for indicating text as marked or highlighted</mark> for reference purposes,

due to its relevance in another context. The mark tag is supported in all major browsers. Use the <mark> tag if you want to highlight parts of your text.

HTML tags can contain one or more attributes. Attributes are added to a tag to provide the browser with more information about how the tag should appear or behave.

<mark style="background-color:yellow;">Attributes consist of a name and a value separated by an equals (=) sign,</mark> with the value surrounded by double quotes.

</body>

</html>

Fire Fox  

mark1.gif 

Differences Between HTML 4.01 and HTML5

The <mark> tag is new in HTML5.

Differences from strong and em

Use strong when you need to indicate the importance of a piece of text, such as an error or warning message, and em should be for adding emphasis to text, stressing words to adapt the meaning of a sentence.

mark differs from these two as it is used purely for highlighting the relevance of a piece of text to the user and/or page's content. In the past you may have used em and strong for this purpose, which was arguably valid at the time due to the lack of a better element, but the introduction of mark simply means their use will be more strict.

Up Next
    Ebook Download
    View all
    Learn
    View all