Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




HTML - Mark Tag


The mark tag or <mark> tag in HTML is used to highlight a text that can be inside of any other HTML element.


Why do we need Mark Tag in HTML?


So far we never had any dedicated tags in HTML that can highlight texts. With the mark tag in semantic tags we can highlight a text in HTML.


Just note that mark tag uses default color as yellow for highlighting the texts. However, we can change the default color to some other color in CSS properties.


Let us see the mark tag in use with the below example.


Example :



<html>
<body>
    <p>This is the <mark>highlighted</mark> content</p>	
</body>
</html>


Output :




So, if you look at the above code. We have used the mark tag to mark a text,


<mark>highlighted</mark>

for the below paragraph.


<p>This is the <mark>highlighted</mark> content</p>

Now, if you look at the above output. The text is marked with the yellow color which is the default color for mark tag.


Now, let us see how can we change the default color using CSS properties.


Changing the default color of mark tag in HTML


Example :



<html>
<body>
    <p>This is the <mark style="background-color: green;">highlighted</mark> content</p>	
</body>
</html>


Output :




So, if you look the above code, we have changed the color to green using the background-color property of CSS.


<mark style="background-color: green;">

And the color got changed from yellow to green.