HTML Headings

HTML headings are titles and sub-titles on a page. There are six levels, from <h1> (the most important) to <h6> (the least important).

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Output in the browser

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Browsers show h1 in the biggest size and h6 in the smallest. You can change the size and look with CSS.


Rules for using headings

  • Use only one <h1> on a page. It is the main title of the page.
  • Use headings in order: h1, then h2 for sections, then h3 for sub-sections. Do not jump from h1 to h4.
  • Do not use a heading only to make text big or bold. Use CSS for that.
  • Do not put a heading inside a paragraph.

Why headings are important

  • SEO: search engines use headings to understand what your page is about.
  • Accessibility: screen reader users jump from heading to heading to scan the page.
  • Readability: visitors can scan a page quickly.

Example of a page outline

<h1>Learn HTML</h1>
  <h2>HTML Basics</h2>
    <h3>Elements</h3>
    <h3>Attributes</h3>
  <h2>HTML Forms</h2>

The indent is only to show the levels. HTML does not need it.


Summary

  • Headings go from h1 to h6.
  • One h1 per page, and keep the order.
  • Next: HTML Paragraphs.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.