Skip to main content
On this page

Semantic heading elements for structuring page and section content

When to use​

  • To title a page, section, or content block so users can scan and navigate the content hierarchy
  • To create a logical document outline that assistive technology can traverse
  • When a designer has specified a heading size for a piece of content and it needs to render in the design token system

When not to use​

  • For body text or labels - use Text (P) instead.
  • For decorative large text that carries no structural meaning - use Text with appropriate styling rather than a heading element that would mislead screen reader users.
  • To make text bigger without implying document structure - use the as prop to separate visual size from semantic level rather than choosing the heading component based on appearance alone.

Anatomy​

  1. Heading text

Basic usage​

Use the numbered heading component (Heading1 through Heading4) that matches the correct semantic level in the document outline.

Loading...
Edit live code
<>
  <Heading1>Heading 1</Heading1>
  <Heading2>Heading 2</Heading2>
  <Heading3>Heading 3</Heading3>
  <Heading4>Heading 4</Heading4>
</>

Variants and features​

Heading levels​

Nebula provides four heading components: Heading1, Heading2, Heading3, and Heading4. Each renders the corresponding HTML element (h1 through h4) and applies the matching visual size from the design token system.

Choose the component based on its semantic level in the content hierarchy, not its visual size. Do not skip levels. If the page has an h1 and a section needs a sub-heading, use h2 regardless of how large or small you want it to appear.

Loading...
Edit live code
<>
  <Heading1>Your account</Heading1>
  <Heading2>Billing</Heading2>
  <Heading3>Payment method</Heading3>
  <Heading4>Direct Debit details</Heading4>
</>

Separating visual size from semantic level​

When the correct semantic level and the desired visual size do not match, use the as prop from styled-components to render a different HTML element while keeping the visual styling.

For example, a section heading that sits at h3 in the document outline but should appear at the Heading2 visual size:

Loading...
Edit live code
<Heading2 as="h3">Section title</Heading2>

Use this sparingly. If your design consistently requires as overrides, the page structure or design may need revisiting.

Responsive sizing​

All heading components resize automatically at the smallAndUp breakpoint. Margins between headings and adjacent content also adjust responsively. No extra configuration is needed.