3.3. Headings

Standard HTML tags allow for six levels of headings, <h1> through <h6>. The higher the heading number, the smaller the heading. Figure 3-3 shows a simple page with all six headers and a line of standard text.

The user agent's settings affect the size of the different headings.

The code to generate the document shown in Figure 3-3 appears here:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <title>Sample Headings</title>
</head>
<body>
<p>
<h1>Heading One</h1>
<h2>Heading Two</h2>
<h3>Heading Three</h3>
<h4>Heading Four</h4>
<h5>Heading Five</h5>
<h6>Heading Six</h6>
A line of normal text.</p>
</body>
</html>

Notice how the headings have implicit line breaks and how the entire document is set inside paragraph tags. Although there are no attributes that you can use to modify the format and behavior of heading tags, you can change their appearance and behavior with styles (which are discussed in Part II of this book).

As a general rule, you should not include any other tags within a heading.

Figure 3-3. Figure 3-3

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.