Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

h2 — second-level heading

The h2 element marks a subsection heading, typically below the main h1 heading. It expresses content structure rather than merely changing text appearance.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<h2>Heading text</h2>

h2 represents a subsection heading. In a typical hierarchy, h1 introduces the main topic, h2 a subsection, and h3 a further subdivision. Multiple h2 headings can describe peer subsections.

The element accepts phrasing content, such as text and em, and global attributes such as id. Both its opening and closing tags are required. Do not place a p paragraph or another heading inside it.

Choose the level for structure, not the desired text size. In the example, Practice heads a subsection of Study guide; the surrounding section explicitly groups its content.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Study guide</title>
</head>
<body>
  <h1>Study guide</h1>
  <section>
    <h2>Practice</h2>
    <p>Complete one exercise.</p>
  </section>
</body>
</html>

Result

Study guide
Practice
Complete one exercise.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources