Friday, 29 November 2024

Using the mark Tag for highlighting Text in HTML

The <mark> element in HTML is used to highlight text. In general, it is used to emphasize certain content or indicate something that is important or relevant in the context of the surrounding text, such as search results or important keywords in an article.

The <mark> element can be useful in the following cases.

 

1.   Search Results: To highlight search terms in a result set.

2.   Important Annotations: When you want to emphasize specific portions of text for the user's attention.

3.   Educational Purposes: Highlighting key terms or important points in tutorials, lessons, or articles.

 

The <mark> element usually renders text with a yellow background by default, but you can change this styling using CSS.

 

mark-element.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Mark Example</title>
</head>

<body>
  <p>HTML is not a programming language; it's a <mark>markup language.</mark> 
    This means it uses <mark>tags</mark> to define elements within a document. 
    These tags tell the web browser how to display the content.</p>
</body>

</html>

Above snippet generate below screen.

 


‘<mark>’ element ensures that the highlighted text is accessible and meaningful for screen readers or other assistive technologies, enhancing the experience for users with disabilities.


  

Previous                                                    Next                                                    Home

No comments:

Post a Comment