Home   Web Top   Bottom Contents   Prev   Next

Headings — <h1> Through <h6>

Topics on This Page

Headings
Example


Headings

Until now, the <p> tag is the only block tag that you've seen. In general, block tags describe the structure of your page (most inline tags describe formatting rather than structural elements).

<h?> ... </h?>   (? is a digit 1-6)

Attributes:
  align="left|right|center|justify"  (deprecated)

Contents:
  Inline elements

The <h?> tags are used to define headings (sometimes called headlines). Use <h1> for your most important headings — it displays using a very large font size. <h2> through <h6> use progressively smaller font sizes. All <h?> tags display their text beginning on a fresh line with a blank line before and after the heading.

Like <p>, <h?> tags can only contain inline elements. You may recall that inline elements include text, inline tags, and certain empty tags such as <br> and <img>. An <h?> tag cannot contain other block tags. You cannot place an <h?> tag inside another <h?> tag, you cannot place a <p> tag inside an <h?> tag, and you cannot place an <h?> tag inside a <p> tag.

As with <p>, the align attribute is a deprecated tag. This means that you can use it in transitional HTML/XHTML but not in strict HTML/XHTML. The default is align="left". You can also control the alignment via the CSS text-align property, and you must use that method if you're using strict HTML/XHTML.


Example

Here are examples of each of the <h?> tags. Try putting a <p> tag inside one of the <h?> tags to see what error the validator reports.


Home   Web Top   Bottom Contents   Prev   Next