Headings are used to structure content on a webpage.
They create a hierarchy, making your content readable, organized, and SEO-friendly.
HTML provides six levels of headings, from <h1> (most important) to <h6> (least important).
TagDescriptionUse Case<h1>Main heading / Page titleOnly one per page; most important<h2>Section headingSubsections under <h1><h3>Sub-section headingSubsections under <h2><h4>Sub-sub-section headingSubsections under <h3><h5>Minor headingSubsections under <h4><h6>Least important headingSubsections under <h5>
<h1>This is a Heading 1</h1> <h2>This is a Heading 2</h2> <h3>This is a Heading 3</h3> <h4>This is a Heading 4</h4> <h5>This is a Heading 5</h5> <h6>This is a Heading 6</h6>
<h1> per page for SEO and accessibility.<h1> → <h2> → <h3><h1> → <h4> → <h6>Headings can be styled using CSS for font, color, and size:
<style>
h1 {
color: #2c3e50;
font-family: Arial, sans-serif;
font-size: 36px;
}
h2 {
color: #e74c3c;
font-family: Verdana, sans-serif;
}
</style>
<h1> and <h2> for ranking.Create a webpage demonstrating all heading levels with CSS styling:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML Headings Practice</title>
<style>
h1 { color: #1abc9c; font-family: Arial, sans-serif; }
h2 { color: #3498db; font-family: Verdana, sans-serif; }
h3 { color: #9b59b6; }
h4 { color: #e67e22; }
h5 { color: #e74c3c; }
h6 { color: #7f8c8d; }
</style>
</head>
<body>
<h1>Main Heading (H1)</h1>
<h2>Section Heading (H2)</h2>
<h3>Sub-section Heading (H3)</h3>
<h4>Sub-sub-section Heading (H4)</h4>
<h5>Minor Heading (H5)</h5>
<h6>Least Important Heading (H6)</h6>
<p>This is a normal paragraph under headings.</p>
</body>
</html>