Mark Tag in HTML5

Introduction 

 
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 the 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
  1. <p>Do not forget to buy   
  2.     <mark>milk</mark> today.  
  3. </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  
 
Attributes Description             
None  

 
Global Attributes

 
The following attributes are standard across all HTML 5 tags.
 
HTML5 Global Attributes
accesskey draggable style
class hidden tabindex
dir spellcheck  
contenteditable id title
contextmenu lang  

 
Event Handler Content Attributes

 
Here are the standard HTML 5 event handler content attributes.
 
onabort onerror* onmousewheel
onblur* onfocus* onpause
oncanplay onformchange onplay
oncanplaythrough onforminput onplaying
onchange oninput onprogress
onclick oninvalid onratechange
oncontextmenu onkeydown onreadystatechange
ondblclick onkeypress onscroll
ondrag onkeyup onseeked
ondragend onload* onseeking
ondragenter onloadeddata onselect
ondragleave onloadedmetadata onshow
ondragover onloadstart onstalled
ondragstart onmousedown onsubmit
ondrop onmousemove onsuspend
ondurationchange onmouseout ontimeupdate
onemptied onmouseover onvolumechange
onended onmouseup onwaiting
 
For example
  1. <!DOCTYPE HTML>  
  2. <html>  
  3.     <body>  
  4. The mark tag was introduced in HTML 5.   
  5.         <mark style="background-color:yellow;">The HTML mark tag is used for indicating text as marked or highlighted</mark> for reference purposes,  
  6. due to its relevance in another context. The mark tag is supported in all major browsers. Use the   
  7.         <mark> tag if you want to highlight parts of your text.  
  8. 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.  
  9.             <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.  
  10.         </body>  
  11.     </html> 
FireFox  
 
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.