6. Structuring Text with Headings (h1 through h6)
Headings are essential for defining the hierarchy and structure of your document, which is vital for both users and search engines (SEO).
6.1 The Heading Hierarchy
HTML provides six levels of headings, from <h1> (the most important) to <h6> (the least important).
Rules for Usage:
- One
<h1>per page: The<h1>should summarize the primary topic of the entire page (like the title of a book chapter). - Maintain Order: Always proceed numerically (
h1->h2->h3). Do not skip levels (e.g., jumping directly fromh1toh4).
html
Main Title of the Page
Major Section Topic
<p>Introductory paragraph.</p>
<h3>Sub-Section Detail 1</h3>
<p>Content for detail 1.</p>
<h3>Sub-Section Detail 2</h3>
<p>Content for detail 2.</p>
Another Major Section Topic
More content here.
Note: While browsers often display h1 largest and h6 smallest, you should use headings for structure (semantics), not just for visual size. You will control the appearance using CSS later.