MakeW3web

HTML Headings

HTML headings are used to define the titles and subtitles of the content on a web page. They provide a hierarchical structure to the content, making it easier for users to understand the organization and flow of information. Headings also help improve accessibility and search engine optimization (SEO).

There are six levels of headings in HTML, from `<h1>` (the largest and most important) to `<h6>` (the smallest and least important). The general rule is to use `<h1>` for the main title of the page, and then `<h2>` to `<h6>` for subheadings and subsections in decreasing order of importance.

Here's an example of how to use HTML headings:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HTML Headings Example</title>
</head>
<body>
    <h1>Main Title of the Page</h1>
    <p>This is a brief introduction to the content of the page.</p>
    
    <h2>Section 1</h2>
    <p>Content for section 1 goes here.</p>
    
    <h3>Subsection 1.1</h3>
    <p>Content for subsection 1.1 goes here.</p>
    
    <h3>Subsection 1.2</h3>
    <p>Content for subsection 1.2 goes here.</p>
    
    <h2>Section 2</h2>
    <p>Content for section 2 goes here.</p>
    
    <h3>Subsection 2.1</h3>
    <p>Content for subsection 2.1 goes here.</p>
    
    <h4>Sub-subsection 2.1.1</h4>
    <p>Content for sub-subsection 2.1.1 goes here.</p>
</body>
</html>

In this example, the `<h1>` tag represents the main title of the page, `<h2>` tags are used for section titles, `<h3>` tags are used for subsections, and the `<h4>` tag is used for a sub-subsection. Using headings in this way helps to establish a clear hierarchy of content, making it more accessible and easier to understand for both users and search engines.

Remember to use headings judiciously and avoid skipping levels. For example, don't jump from `<h2>` to `<h4>` without an `<h3>` in between. Consistent use of headings will help create a well-structured and visually appealing web page.

Was this page helpful?