This reference is built into PageRIJ — a live HTML, CSS & SVG authoring and learning environment.

HTML <h2> element

The <h2> element represents a second-level heading. It commonly introduces a main section within a page whose overall heading is an <h1>. For example, a page headed "Software guide" might have sections headed "Getting started," "Using the software," and "Troubleshooting," each using <h2>.

Sections at the same level use the same heading rank. A subdivision of an <h2> section normally begins with <h3>. This describes a relationship between the content sections: the <h3> element is not placed inside the <h2> element. Each heading contains its own heading text.

When introducing a deeper subsection, advance one heading level at a time. This gives readers and assistive technology a consistent hierarchy. Returning to a higher rank is also part of that structure: an <h2> can follow an <h4> when the intervening subsections have ended and a new main section begins.

The browser supplies a default appearance for <h2>, which can be changed with CSS. Changing the font size or weight does not change the heading's structural role. Its rank is chosen according to the section it introduces.

Attributes: GLOBALS.

Typical layout:
<h1>Software guide</h1>
<h2>Getting started</h2>
<h3>Installation</h3>
<p>Choose the installer for your operating system.</p>
Visual representation:

Software guide

Getting started

Installation

Choose the installer for your operating system.