Headings tag in HTML

0
72
Learn HTML5
This entry is part 3 of 4 in the series Learn HTML5

HTML provides not only plain paragraph tags, but six separate header tags to indicate headings of various sizes and thicknesses. Enumerated as heading 1 through heading 6, heading 1 has the largest and thickest text while heading 6 is the smallest and thinnest, down to the paragraph level. This topic details proper usage of these tags.

Using Headings

Headings can be used to describe the topic they precede and they are defined with the <h1> to <h6> tags. Headings support all the global attributes.

  • <h1> defines the most important heading.
  • <h6> defines the least important heading.

Defining a heading

Correct structure matters

Search engines and other user agents usually index page content based on heading elements, for example to create a table of contents, so using the correct structure for headings is important.

In general, an article should have one h1 element for the main title followed by h2 subtitles – going down a layer if necessary. If there are h1 elements on a higher level they shoudn’t be used to describe any lower level content.

Example document (extra intendation to illustrate hierarchy):

Series NavigationPrevious: Doctypes in HTMLNext: Paragraphs in HTML

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.