w3resource

HTML5: How to specify the main content of a document?

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 specify the main content of a document</title><!-- Sets the title of the document -->
</head><!-- Ends the head section -->
<body><!-- Contains the content of the document -->
<article><!-- Represents an independent piece of content in a document -->
<h1>search engines</h1><!-- Displays a top-level heading -->
<p>Google, Bing, and Yahoo! are the most used search engines today.</p><!-- Provides information about search engines -->
<h1>Google</h1><!-- Displays a top-level heading -->
<p>The world's most popular search engine.</p><!-- Provides information about Google -->
<h1>Bing</h1><!-- Displays a top-level heading -->
<p>Microsoft's entry into the burgeoning search engine market. Better late than never.</p><!-- Provides information about Bing -->
<h1>Yahoo!</h1><!-- Displays a top-level heading -->
<p>The 2nd largest search engine on the web.</p><!-- Provides information about Yahoo! -->
</article><!-- Ends the article section -->
</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 content of the document is defined.
  • The <article> element represents an independent piece of content in a document.
  • Inside the <article> element, there are multiple <h1> (heading) and <p> (paragraph) elements that provide information about different search engines.
  • Each <h1> represents a top-level heading, and the corresponding <p> element provides information about the search engine mentioned in the heading.

Live Demo:

See the Pen main-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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html-css-exercise/basic/main-answer.php