HTML Heading Tags (h1-h6)
HTML provides six levels of heading tags, from <h1> to <h6>. These tags are used to define titles and subtitles, creating a hierarchical structure for your web page's content. A proper heading structure is crucial for both search engine optimization (SEO) and accessibility, as it helps machines and screen readers understand the outline of your document.
The Six Levels of Headings
- <h1>: The most important heading. It should represent the main title of the page and be used only once per page.
- <h2>: Represents a major section of the content. There can be multiple
<h2>tags on a page. - <h3>: Represents a sub-section within an
<h2>section. - <h4>, <h5>, <h6>: Represent further nested sub-sections. Use them to create a deeper hierarchy as needed.
Best Practices for SEO & Accessibility
- Maintain Hierarchy: Never skip heading levels (e.g., do not go from an
<h1>directly to an<h3>). This breaks the logical structure for screen readers and search engines. - Use for Structure, Not Style: Headings should define the structure of your content, not just to make text big or bold. For styling, use CSS.
- Be Descriptive: Your headings should accurately describe the content of the section that follows.
Browser Compatibility
Heading tags (<h1> to <h6>) are fundamental to HTML and are universally supported by all modern and legacy web browsers, including Google Chrome, Mozilla Firefox, Apple Safari, Microsoft Edge, and Internet Explorer.
