Skip to content

<h2> - Level 2 Heading

Block-level HTML 1.0

The <h2> element represents a second-level heading, used for major sections within a page. It sits directly below <h1> in the heading hierarchy and helps organize content into logical sections.

Result
<h2>Section Title</h2>

The <h2> element creates a major section heading that subdivides content under the main <h1> title.

The <h2> element supports all global attributes like id, class, style, and lang.

<h2 id="about" class="section-heading">About Us</h2>

Use <h2> to divide your page into major sections:

Result
Result

Create a table of contents using <h2> with id attributes:

Result
Result

Always use headings in order, starting with <h1>:

<h1>Main Title</h1>
<h2>First Major Section</h2>
<h3>Subsection</h3>
<h2>Second Major Section</h2>
<h3>Another Subsection</h3>

Unlike <h1>, you can (and should) use multiple <h2> elements:

<h1>Ultimate Guide to HTML</h1>
<h2>What is HTML?</h2>
<p>HTML stands for...</p>
<h2>Basic Syntax</h2>
<p>HTML uses tags...</p>
<h2>Common Elements</h2>
<p>The most frequently used elements are...</p>
Result

Screen reader users often navigate by headings. Clear <h2> elements help them scan your content:

<!-- Screen reader announces: "Heading level 2: Getting Started" -->
<h2>Getting Started</h2>

Use descriptive text that makes sense out of context:

<h2>Installation Instructions</h2>
<h2>System Requirements</h2>
<h2>Frequently Asked Questions</h2>

Skipping heading levels confuses screen reader users:

<h1>Main Title</h1>
<h2>Section</h2>
<h3>Subsection</h3>

Search engines use <h2> elements to understand your page structure:

<h1>Complete Guide to React Hooks</h1>
<h2>What are React Hooks?</h2>
<!-- Search engines know this section explains hooks -->
<h2>useState Hook</h2>
<!-- This section covers useState specifically -->
<h2>useEffect Hook</h2>
<!-- This section covers useEffect specifically -->

Include relevant keywords naturally in <h2> headings:

<!-- Good: Natural keyword usage -->
<h2>How to Learn JavaScript for Beginners</h2>
<h2>JavaScript Tutorial: Variables and Data Types</h2>
BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE3+Full support

The <h2> element has been supported since the earliest browsers.

Self-contained content with its own heading hierarchy. Learn more →