Headings
Headings are one of the most
essential parts of any webpage. They help organize content, improve
readability, and are important for search engine optimization (SEO).
What
Are Heading Tags?
HTML provides six levels of
headings, from <h1> (most important) to <h6> (least important):
<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>
How
They Look in the Browser
Each heading tag displays the text
in a different font size by default, with <h1> being the largest and <h6> the smallest.
Let’s test this using your local
XAMPP or WAMP setup.
๐งช
Example: Create a Simple Page with Headings
- Open your XAMPP/WAMP server and make sure Apache is running.
- Create a new file
named headings.html in the htdocs (XAMPP) or www (WAMP) folder.
- Paste the following code:
<!DOCTYPE
html>
<html>
<head>
<title>HTML Headings Example</title>
</head>
<body>
<h1>This is Heading 1</h1>
<h2>This is Heading 2</h2>
<h3>This is Heading 3</h3>
<h4>This is Heading 4</h4>
<h5>This is Heading 5</h5>
<h6>This is Heading 6</h6>
</body>
</html>
- Open your browser
and go to:
- http://localhost/headings.html (for XAMPP)
- http://localhost/yourfoldername/headings.html (if it's in a subfolder)
You’ll see all six headings
displayed with decreasing size.
๐ Best Practices for Headings
- Use <h1> only once
per page, typically for the main title.
- Use <h2> for section headings, <h3> for subsections, and so on.
- Headings should be used for structure, not just
to make text look bigger or bolder.