What is an HTML Heading?
Syntax of HTML Headings
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>This is an H1 heading</h1>
<h2>This is an H2 heading</h2>
<h3>This is an H3 heading</h3>
<h4>This is an H4 heading</h4>
<h5>This is an H5 heading</h5>
<h6>This is an H6 heading</h6>
</body>
</html>
Sizes and Styling of HTML Headings
<style>
h1 {
font-size: 2em;
color: blue;
text-align: center;
}h2 {
font-size: 1.5em;
color: green;
text-align: center;
}
</style>
Centering HTML Headings
text-align
property:<h1 style="text-align:center;">Centered H1 Heading</h1>
Practical Examples and Uses
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Main Title</h1>
<p>This is an introductory paragraph.</p>
<h2>Subheading 1</h2>
<p>Details about subheading 1.</p>
<h3>Sub-subheading</h3>
<p>Further details about the sub-subheading.</p>
<h2>Subheading 2</h2>
<p>Details about subheading 2.</p>
</body>
</html>
Note:- The default property of the HTML heading tag is block.