Skip to main content

HTML Basics

HTML Headings

Written by Updated HTML Headings exercises

Headings are the outline of your page, from h1 for the main title down to h6 for the smallest sub-point. People skim them to decide what to read, screen reader users jump between them, and search engines use them to understand the page.

Each tag in detail is covered in the h1 to h6 tags. This lesson is about using them well.

What Are HTML Headings?

There are six levels, <h1> to <h6>. Each one is a level below the one before, like chapters, sections and sub-sections in a book.

Example

html

<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>

The six headings appear from largest to smallest. Those sizes are only browser defaults; the level is what matters.

Example: Headings in Real Use

Real Example

html

<h1>HTML Tutorial</h1>
<h2>Introduction</h2>
<h3>What is HTML?</h3>
<h4>History of HTML</h4>

Read just the headings of a page, and you should get its table of contents: the tutorial, its introduction, then the questions inside it.

Styling Headings with CSS

Styling Header

html

<h1 style="color: #29AB87; font-family: Arial;">Welcome to My Website</h1>

The heading's color and font change, but it is still an <h1> with the same meaning. Always style headings with CSS rather than choosing a smaller or bigger tag for the look.

Rules that help readers and search engines

  • One <h1> per page, for its main title.
  • Do not skip levels on the way down. After <h2> comes <h3>, not <h4>. Jumping back up to a new <h2> is fine.
  • Keep them short and clear. "Pricing" beats "Here is everything you need to know about our prices".
  • Do not use headings for bold text, and do not use bold text for headings. Screen readers only treat real heading tags as headings.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

HTML Headings exercises

Page heading

Write the main heading of the page: Frontend Handbook.

Result

Check your answer to see it here.