HTML5: How to define the root of an HTML document?
Solution:
HTML Code:
<!DOCTYPE html><!-- Opening tag for declaring the document type -->
<html><!-- Opening tag for the root element of the HTML document -->
<head><!-- Opening tag for the document's header section -->
<meta charset="utf-8"><!-- Metadata tag specifying the character encoding of the document -->
<title>How to define the root of an HTML document</title><!-- Title of the HTML document -->
</head><!-- Closing tag for the document's header section -->
<body><!-- Opening tag for the document's body section -->
<p>We are learning HTML html element. </p><!-- Paragraph element containing text content -->
</body><!-- Closing tag for the document's body section -->
</html><!-- Closing tag for the root element of the HTML document -->
Explanation:
- This HTML code represents a basic HTML document structure with the root <html> element.
- The <!DOCTYPE html> declaration specifies the document type as HTML5.
- The <html> element is the root element of the HTML document, containing all other HTML elements.
- Inside the <html> element, there are two main sections: <head> and <body>.
- The <head> element contains meta-information about the HTML document, such as the character encoding and the title.
- Inside the <head> element, there is a <meta> tag specifying the character encoding of the document and a <title> tag defining the title of the HTML document.
- The <body> element contains the visible content of the HTML document, such as text, images, and other elements.
- Inside the <body> element, there is a <p> (paragraph) element containing text content.
Live Demo:
See the Pen html-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics