The document's content: the container for every landmark on the page and the surface VB paints the page background on.
Description
The <body> element holds the document's content. Everything the user sees or hears goes inside it: one per document, as the second child of <html> after <head>.
<body> is not a landmark. HTML-AAM maps it to the generic role, so screen readers do not announce it and it gives no navigation shortcut. Page structure comes from the landmarks you put inside it: <header>, <nav>, <main>, <aside> and <footer>. Make a skip link the first focusable element in the body.
In Vanilla Breeze, <body> takes page structure: the page grid (data-page-layout) and the page background. Global configuration (theme, mode, fluid scaling, backdrop) belongs on <html>. See Theme attributes go on html.
Basic Example
A landmark skeleton: skip link first, then the regions. data-page-layout places each landmark in its grid area by element type.
<!DOCTYPE html><html lang="en" data-theme="modern" data-fluid> <head>...</head> <body data-page-layout="sidebar-left"> <a href="#main" class="skip-link">Skip to main content</a> <header>...</header> <nav aria-label="Primary">...</nav> <main id="main">...</main> <footer>...</footer> </body></html>
The .skip-link class is part of the core stylesheet; see Keyboard and Focus. Its styles position the link absolutely, so it stays out of the page grid. An unstyled link that is a direct child of a data-page-layout body would be auto-placed into a grid cell.
Theme attributes go on html
Put data-theme, data-mode, data-fluid and data-backdrop on <html>, not on <body>. VB's selectors for them start with :root, and ThemeManager writes them to document.documentElement. That includes the theme picker, the settings panel and saved preferences.
<html lang="en" data-theme="modern" data-mode="dark"> <body data-page-layout="sidebar-left">...</body></html> <html lang="en"> <body data-theme="modern" data-mode="dark">...</body></html>
data-theme on <body> causes three problems:
- The reset treats any
[data-theme]:not(:root) or [data-mode]:not(:root) element as a scoped override and re-applies color there. The <html> element, its scrollbars and its background (--page-bg-color) stay on the root theme.
- A theme's dark-mode adjustments are written for both attributes on one element:
[data-theme~="modern"][data-mode="dark"]. ThemeManager always puts data-mode on <html>, so with the theme on the body those adjustments never apply.
- When a user picks a theme,
ThemeManager sets it on <html>, but your attribute stays on <body>. Tokens set on the body override the root values for all content, so the user's choice is mostly ignored.
Scoped data-theme and data-mode belong on regions inside the body, such as an <aside data-mode="dark">, not on the body itself.
VB Styling
The reset (src/base/reset.css) gives <body> these defaults:
| Property |
Value |
Effect |
margin |
0 |
Removes the browser's default 8px body margin. The reset sets margin: 0 on every element. |
min-block-size |
100dvh (with a 100vh fallback) |
The body always fills the viewport, so the page background and a page-layout grid reach the bottom edge on short pages. dvh follows mobile browser toolbars. |
font-family |
var(--font-sans) |
The theme's body font |
line-height |
var(--line-height-normal) |
The default reading line height |
font-size-adjust |
var(--font-size-adjust) |
Keeps the x-height steady when fallback fonts render |
color |
var(--color-text) |
Theme text color, inherited by all content |
-webkit-font-smoothing |
antialiased |
Grayscale antialiasing in macOS WebKit and Blink |
background-* |
The --page-bg-* hooks |
See Page Background below |
Page Background
The reset paints the body background from custom properties, so you can restyle the page background without writing a body rule. Set them on :root. The body inherits them, and <html> also reads --page-bg-color, so overscroll areas match.
| Custom property |
Default |
What it does |
--page-bg-color |
var(--color-surface) |
Background color for both <body> and <html> |
--page-bg-gradient |
none |
Any background-image value, usually a gradient. Painted over --page-bg-image. |
--page-bg-image |
none |
Background image (for example url(texture.png)). Painted under --page-bg-gradient, so it shows where the gradient is absent or translucent. |
--page-bg-attachment |
scroll |
background-attachment. Use fixed to keep a gradient still while the content scrolls. |
--page-bg-size |
cover |
background-size |
--page-bg-position |
center |
background-position |
--page-bg-blend |
normal |
background-blend-mode, which blends the gradient and the image with each other and with --page-bg-color |
:root { --page-bg-gradient: linear-gradient(160deg, color-mix(in oklch, var(--color-surface) 80%, var(--color-primary)), color-mix(in oklch, var(--color-surface) 90%, var(--color-accent))); --page-bg-attachment: fixed;}
Other features set these properties too. ThemeManager writes --page-bg-color or --page-bg-gradient as inline styles on <html> when a user picks a page background in <settings-panel>. data-backdrop sets its own --page-bg-color, a tint that contrasts with the canvas cards. With data-backdrop-chrome="stretch" it resets the color to the surface and sets --page-bg-gradient to none.
Vanilla Breeze Attributes
data-page-layout
Turns the body into a page grid. Direct-child <header>, <nav>, <main>, <aside> and <footer> elements go to their grid areas by element type. Values: stack, sidebar-left, sidebar-right, holy-grail, app-shell, dashboard, article, landing. The grid also gets min-height: 100dvh. On wide screens, holy-grail and dashboard bodies are capped at 87.5rem and centered. See data-page-layout for templates, modifiers and small-screen behavior.
<body data-page-layout="holy-grail" data-layout-gap="l"> <header>...</header> <nav>...</nav> <main>...</main> <aside>...</aside> <footer>...</footer></body>
data-backdrop (on html) and the body
data-backdrop goes on <html>, but its rules all target the body and its direct children through :root[data-backdrop] > body:
- The body gets
padding: var(--canvas-gap), so the page background shows around the regions.
- Each direct-child
main, header, footer, nav and aside becomes a card with its own background, radius and shadow.
- Without
data-page-layout, the regions are centered at --canvas-width and spaced with margins. With it, they keep their grid areas and the grid gap grows to --canvas-gap.
- Below 37.5rem the body padding drops to 0 and the regions go flush.
Because the selectors use the child combinator, only direct children of the body become cards. A wrapper element between the body and the landmarks turns the effect off. For canvases on arbitrary elements, use <layout-canvas> / data-canvas.
data-canvas-depth
Set on <body> to add one ("1") or two ("2") "ghost card" shadows below <main>, like a stack of papers. It only works when <html> has data-backdrop and the chrome is card-style. It does nothing with data-backdrop="flush", stretch or integrated chrome, or below 37.5rem.
<html lang="en" data-backdrop> <body data-canvas-depth="2"> <header>...</header> <main>...</main> <footer>...</footer> </body></html>
Behavior Notes
- Scroll lock:
<site-search> sets document.body.style.overflow = 'hidden' while its overlay is open and clears it on close. Don't rely on an inline overflow style on the body while search is in use.
- Print: VB's print styles give the body a white background and black text (
body { background: #fff; color: #000; }), unless <html data-print-raw> is set. A data-page-layout body prints as display: block with its nav and aside hidden. See Printing.
Attributes
<body> supports global attributes. It has no element-specific attributes beyond:
- Window event handlers such as
onload, onhashchange, onpopstate and onbeforeunload. They are registered on window, not on the body. Prefer window.addEventListener() in a module script.
- Obsolete presentational attributes (
bgcolor, background, text, link, vlink, alink). Don't use them. Use the --page-bg-* hooks and theme tokens instead.
Accessibility
- Not a landmark: the body maps to the
generic role. Put all content in landmarks (<header>, <nav>, <main>, <aside>, <footer>) so screen reader users can jump between regions. Content outside a landmark is easy to miss.
- One
<main>: give the main content a single visible <main> landmark with an id the skip link can target.
- Skip link first: the first focusable element in the body should be a link to
#main, so keyboard users can skip the header and navigation.
- Don't add a role: don't put
role="application" or role="main" on the body. The first changes how screen readers handle keys for the whole page; the second duplicates <main>.