HTML - Headings

Headings are used to specify the titles and subtitles of sections or sub-sections in an HTML document. Depending on the hierarchical importance and structural prominence of the text, six available levels from <h1> to <h6> can be used. <h1> defines the highest-level, most important heading, while <h6> defines the lowest level. Browsers automatically render headings in bold font and insert vertical margins (white space) before and after each heading. Heading tags are paired container tags, meaning every opening tag must be matched by a closing tag with a forward slash (e.g., </h1>).

Heading Syntax & Code Example


<h1>Heading Level 1 - Main Page Topic</h1>
<h2>Heading Level 2 - Major Section Title</h2>
<h3>Heading Level 3 - Subsection Title</h3>
<h4>Heading Level 4 - Detailed Topic Point</h4>
<h5>Heading Level 5 - Minor Sub-point</h5>
<h6>Heading Level 6 - Lowest Level Reference</h6>
							

Visual Browser Output

Heading Level 1

Heading Level 2

Heading Level 3

Heading Level 4

Heading Level 5
Heading Level 6

The Six Heading Levels: Detailed Breakdown

Each heading tag serves a distinct structural and semantic role in your document layout:

Tag Default Browser Font Size Semantic Role & Usage
<h1> 2.00em (approx. 32px) The primary headline of the entire page. Should summarize the central topic.
<h2> 1.50em (approx. 24px) Major chapter or section headings across the document.
<h3> 1.17em (approx. 18.7px) Sub-topics grouped beneath an <h2> section.
<h4> 1.00em (approx. 16px) Specific sub-items, code breakdown headers, or side notes within an <h3>.
<h5> 0.83em (approx. 13.3px) Minor headings, sidebar widget headers, or tertiary footnotes.
<h6> 0.67em (approx. 10.7px) The smallest heading level, rarely used except in complex academic papers.

Why Heading Hierarchy is Critical for SEO & Bloggers

Search engines such as Google use headings to index the structure and topical depth of your articles. Follow these golden rules to maximize your website rankings:

  • Single H1 Rule: Use exactly one <h1> tag per page representing the main article title. Including multiple H1 tags dilutes your page's primary keyword focus.
  • Never Skip Levels: Always maintain a logical nesting order (e.g., jump from <h1> to <h2>, then <h3>). Jumping directly from <h1> to <h4> confuses search engine crawlers and screen readers.
  • Do Not Use Headings for Visual Sizing: Never wrap text in an <h3> tag simply because you want it to look bold or larger. Always use CSS (e.g., font-size: 20px; font-weight: bold;) for visual styling, reserving heading tags strictly for structural semantics.
  • Include Target Keywords Naturally: Google gives higher ranking weight to terms contained within H1 and H2 tags. Include relevant synonyms and student search terms within your headings.

Hands-on Practice Session for Students

Lab Assignment 6: Build an Educational Article with Proper Heading Nesting.

Problem Statement: Write a clean HTML5 webpage introducing "Computer Memory Types" using a strict 3-tier heading structure (H1 for page title, H2 for Primary vs Secondary memory, and H3 for specific memory types like RAM, ROM, HDD, SSD).

Solution Code:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Computer Memory Hierarchy - BCA Practical 6</title>
</head>
<body>
    <h1>Guide to Computer Memory Systems</h1>
    <p>Computer memory is divided into primary internal storage and secondary storage.</p>

    <h2>1. Primary (Main) Memory</h2>
    <h3>A. Random Access Memory (RAM)</h3>
    <p>Volatile memory used to store active programs and instructions during execution.</p>

    <h3>B. Read Only Memory (ROM)</h3>
    <p>Non-volatile memory containing bootstrap loader and fundamental firmware instructions.</p>

    <h2>2. Secondary Storage Devices</h2>
    <h3>A. Hard Disk Drive (HDD)</h3>
    <p>Magnetic storage offering high capacity at an economical cost per gigabyte.</p>

    <h3>B. Solid State Drive (SSD)</h3>
    <p>Flash memory storage providing ultra-fast read/write speeds for modern operating systems.</p>
</body>
</html>
							

Viva & University Exam Questions (BCA Exam Preparation)

The <title> tag resides inside the <head> section and is displayed on the browser tab, window bar, and search engine results snippet. The <h1> tag resides inside the <body> and represents the main visible heading on the actual webpage.
All heading tags (<h1> through <h6>) are block-level elements. They always start on a new line and expand across the full available width of their parent container.
Yes. Wrapping an anchor link inside an <h1> tag (e.g., <h1><a href="index.htm">Site Title</a></h1>) is completely valid in HTML and is frequently used for site logos and headers.

Frequently Asked Questions (FAQ)

Screen readers provide a keyboard shortcut (typically pressing 'H') that allows visually impaired visitors to skip directly from heading to heading. This enables them to skim through article sections quickly without listening to the entire page line by line.
Yes! You can completely override the default browser styles using CSS properties like font-size, color, font-family, line-height, and text-transform. Learn more in our HTML With CSS Tutorial.
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!