w3resource

HTML5: How to define marked/highlighted text?

Go to Exercise page

Solution :

HTML Code:

<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html><!-- Begins the HTML document -->
<head><!-- Contains metadata about the document -->
<meta charset="utf-8"><!-- Specifies the character encoding for the document -->
<title>How to define marked/highlighted text</title><!-- Sets the title of the document -->
</head><!-- Ends the head section -->
<body><!-- Contains the content of the document -->
<mark>w3resource</mark><!-- Defines highlighted/marked text -->
is a web development tutorial. <!-- Regular text content -->
</body><!-- Ends the body section -->
</html><!-- Ends the HTML document -->

Explanation:

  • The HTML document begins with a declaration of its type and version (<!DOCTYPE html>).
  • The <html> element encloses the entire HTML document.
  • The <head> section contains metadata about the document, including the character encoding and the title.
  • Inside the <body> section, the <mark> element is used to define highlighted or marked text.
  • The text "w3resource" is enclosed within the <mark> tags, indicating that it should be visually highlighted.
  • The rest of the text "is a web development tutorial." is displayed as regular content.

Live Demo:

See the Pen mark-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes Yes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.