HTML5: How to define an HTML heading?
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 HTML heading</title><!-- Title of the HTML document -->
</head><!-- Closing tag for the document's header section -->
<body><!-- Opening tag for the document's body section -->
<h1>This is H1</h1><!-- Heading level 1 -->
<h2>This is H2</h2><!-- Heading level 2 -->
<h3>This is H3</h3><!-- Heading level 3 -->
<h4>This is H4</h4><!-- Heading level 4 -->
<h5>This is H5</h5><!-- Heading level 5 -->
<h6>This is H6</h6><!-- Heading level 6 -->
</body><!-- Closing tag for the document's body section -->
</html><!-- Closing tag for the root element of the HTML document -->
Explanation:
- This HTML code demonstrates the use of heading elements from h1 to h6.
- Heading elements are used to define headings or titles for sections of content.
- There are six levels of headings in HTML, starting from h1 (the highest level) to h6 (the lowest level).
- Each heading element represents a different level of importance or hierarchy in the document structure.
Live Demo:
See the Pen heading-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