The Ultimate Guide to HTML Header Elements
What header elements are
HTML header elements (h1–h6) define headings that structure page content. They convey document hierarchy to users and assistive technologies.
Semantic roles and hierarchy
- h1: Main page title — use once per page for the primary topic.
- h2: Top-level sections under h1.
- h3–h6: Nested subsections, in descending importance. Maintain logical nesting (don’t skip from h1 to h4 without intermediate levels) unless a clear structural reason exists.
Accessibility considerations
- Use headings to create a meaningful document outline for screen reader navigation.
- Ensure heading text is descriptive and concise.
- Avoid using headings purely for visual styling; use CSS for appearance and keep semantic tags for structure.
- Maintain proper contrast and readable font sizes.
SEO best practices
- Use a single, descriptive h1 containing the main keyword/topic.
- Use headings to break content into scannable sections with relevant keywords, but avoid keyword stuffing.
- Headings can appear in search snippets—make them informative and user-focused.
Visual styling tips
- Control font size, weight, spacing, and color with CSS rather than changing tag semantics.
- Responsive scaling: adjust sizes with relative units (rem, em, %) or CSS clamp().
- Keep visual hierarchy consistent across pages.
Common pitfalls to avoid
- Using multiple h1s for styling rather than structure.
- Skipping heading levels arbitrarily.
- Relying on heading tags for SEO tricks (over-optimization harms readability).
- Making headings vague or non-descriptive.
Practical examples
- Page title:
Ultimate Guide to HTML Header Elements
- Section:
Accessibility
- Subsection:
Screen reader tips
Quick checklist
- One clear h1 per page.
- Logical heading order and nesting.
- Descriptive, concise text for each heading.
- Styling via CSS only.
- Test with a screen reader and on mobile.
If you want, I can generate an optimized heading structure for a specific article—tell me the article’s topic and length.