main

The dominant content of the document body. Contains the primary content unique to the page, excluding headers, footers, navigation, and sidebars.

Usage

Use the <main> element for:

  • The primary content area of a page
  • Content that is unique to this specific page
  • The target for skip links ("Skip to main content")

Important: There should only be one visible <main> element per page. If using multiple for SPA views, only one should be visible at a time (hide others with hidden attribute).

Examples

Default

Basic main element within a page structure.

.contained

Centered with max-width of 1200px.

.narrow

Optimized for reading content (65ch max-width).

.wide

Expanded width (1600px) for dashboards and data-heavy layouts.

.full

Full viewport width with side padding.

.with-sidebar

Two-column layout with sidebar.

.padded

Adds vertical padding for spacing. Combine with other variants.

Full page structure

Complete page layout example.

Variants

Class Description
.contained Max-width 1200px, centered with horizontal padding
.narrow Max-width 65ch for comfortable reading
.wide Max-width 1600px for dashboards and complex UIs
.full Full width with horizontal padding
.with-sidebar Grid layout with main content and sidebar columns
.padded Adds vertical padding (--size-xl)
.flex Flex container that fills available vertical space

Accessibility

  • The main element creates a main landmark for screen reader navigation
  • Only one visible main element per page (others must have hidden attribute)
  • Skip links should target the main element: <a href="#main">Skip to content</a>
  • Add id="main" and optionally tabindex="-1" to receive focus from skip links
  • Main should not be nested inside article, aside, footer, header, or nav

Related

  • <header> - Site header appears before main
  • <footer> - Site footer appears after main
  • <nav> - Primary navigation is outside main
  • <aside> - Sidebar content can be inside or outside main
  • <article> - Main content often contains articles
  • <section> - Thematic grouping within main