Writing pages with no CSS
A page built this way links one stylesheet and writes no CSS. Everything it looks like comes from the elements it uses, a few documented attributes, and the tokens a theme sets. Our choice: a closed vocabulary rather than utility classes, so a page says what each part is, not how it should look, and a checker can tell when a page leaves the system.
The rules
- Link
css/domestic.cssonce, in<head>. Optionally link a theme fromcss/themes/after it and setdata-themeon<html>. - Write no
<style>element and nostyleattribute, except to set a layout primitive's documented custom property (--stack-gap,--grid-min,--cluster-justify, …) or a semantic--dui-*token. - Use the native element that already has the meaning:
<button>,<a href>,<dialog>,<details>,<label>,<fieldset>,<table>,<search>,<time>. The first rule of ARIA applies: norolewhere an element exists. - Use only the attributes, words and classes in the vocabulary below. A word that is not listed does nothing, so it is a mistake, not a style.
- Give each page the landmarks in the skeletons below: a skip link, one
<header>, a labelled<nav>, one<main id>and a<footer>, and exactly one<h1>(WCAG 2.4.1, 1.3.1). - Label every control with a
<label for>or a wrapping<label>, and name every landmark and region you have more than one of witharia-labeloraria-labelledby(WCAG 4.1.2). - Load
web-components/<name>.jsas a module for eachdui-*element on the page. Without it the markup still works as plain HTML (progressive enhancement). - Check the page from a clone of this repository:
node scripts/check-markup.mjs page.htmlfails on a<style>, an undocumented attribute, word or class, an inline style that sets anything else, and adui-*element whose module is not loaded. Then check it with axe and at 320px wide (WCAG 1.4.10).
Compose before you invent. Most interface "components" are arrangements of elements that already look finished together, such as a sign-in card (a data-card holding a form), a stat row (a .grid of small cards) or a confirm dialog (a data-dialog with a <footer> of buttons). This is rung 3 of the decision ladder. When a page needs something no composition can say, that is a gap in domestic-ui. Open an issue instead of adding CSS to the page. The vocabulary is part of the public API.
An application page
The frame of every app screen: the app shell with its sidebar, then a page header and the content. Swap the dashboard for a data table, large form or list-detail. The plain HTML demo has full dashboard, settings and orders screens written the same way.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Overview · Northwind</title>
<meta name="description" content="The skeleton of an application page: app shell, sidebar navigation, page header and content, with no CSS of its own.">
<link rel="stylesheet" href="../../css/domestic.css">
</head>
<body>
<a class="visually-hidden" href="#main">Skip to main content</a>
<dui-app-shell data-app-shell>
<header>
<button type="button" aria-controls="app-nav" aria-expanded="true" hidden>
<svg data-icon viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false"><path d="M4 6h16M4 12h16M4 18h16"></path></svg>
Menu
</button>
<a href="app-page.html" data-link="quiet"><strong>Northwind</strong></a>
<dui-menu>
<button type="button" popovertarget="user-menu">Maria Santos</button>
<div id="user-menu" popover data-popover>
<a href="#profile">Profile</a>
<a href="#preferences">Preferences</a>
<hr>
<button type="button">Sign out</button>
</div>
</dui-menu>
</header>
<nav id="app-nav" aria-label="Main" data-nav>
<ul>
<li><a href="app-page.html" aria-current="page">Overview</a></li>
<li><a href="#orders">Orders</a></li>
<li><a href="#customers">Customers</a></li>
<li>
<details>
<summary>Settings</summary>
<ul>
<li><a href="#settings-general">General</a></li>
<li><a href="#settings-billing">Billing</a></li>
</ul>
</details>
</li>
</ul>
</nav>
<main id="main" class="stack">
<header data-page-header>
<h1>Overview</h1>
<p>How the warehouse is doing this week.</p>
<div class="cluster">
<a href="#new-order" data-button="primary">New order</a>
<button type="button" data-button="secondary">Export</button>
</div>
</header>
<div data-dashboard>
<section aria-labelledby="open-orders-title">
<h2 id="open-orders-title">Open orders</h2>
<p>18</p>
<p data-text="small muted">4 more than last week</p>
</section>
<section aria-labelledby="shipped-title">
<h2 id="shipped-title">Shipped this week</h2>
<p>126</p>
<p data-text="small muted">Since Monday</p>
</section>
<section aria-labelledby="late-title">
<h2 id="late-title">Late</h2>
<p>2</p>
<p><span data-badge="danger">Needs attention</span></p>
</section>
<section data-dashboard-tile="full" aria-labelledby="recent-title">
<h2 id="recent-title">Recent orders</h2>
<section data-scroll="inline" aria-labelledby="recent-caption" tabindex="0">
<table data-table>
<caption id="recent-caption">The five newest orders</caption>
<thead>
<tr>
<th scope="col">Order</th>
<th scope="col">Customer</th>
<th scope="col">Status</th>
<th scope="col" data-table-cell="number">Total</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><a href="#nw-2051">NW-2051</a></th>
<td>Maple Street Bakery</td>
<td><span data-badge="warning">Open</span></td>
<td data-table-cell="number">$216.00</td>
</tr>
<tr>
<th scope="row"><a href="#nw-2050">NW-2050</a></th>
<td>Harbor Lane Café</td>
<td><span data-badge="accent">Packed</span></td>
<td data-table-cell="number">$126.00</td>
</tr>
<tr>
<th scope="row"><a href="#nw-2049">NW-2049</a></th>
<td>Riverside Dental</td>
<td><span data-badge="success">Delivered</span></td>
<td data-table-cell="number">$185.00</td>
</tr>
<tr>
<th scope="row"><a href="#nw-2048">NW-2048</a></th>
<td>Summit Climbing Gym</td>
<td><span data-badge>Shipped</span></td>
<td data-table-cell="number">$255.00</td>
</tr>
<tr>
<th scope="row"><a href="#nw-2047">NW-2047</a></th>
<td>Pine & Co. Interiors</td>
<td><span data-badge="danger">Late</span></td>
<td data-table-cell="number">$345.00</td>
</tr>
</tbody>
</table>
</section>
</section>
</div>
</main>
<footer>
<p data-text="small muted">Northwind is an example app. MIT licensed.</p>
</footer>
</dui-app-shell>
<script type="module" src="../../web-components/dui-app-shell.js"></script>
<script type="module" src="../../web-components/dui-menu.js"></script>
</body>
</html>
A content page
A page that is not an app: a site header with the brand and a <nav>, the content in <main>, small print in <footer>. The plain document page layout gives these landmarks one centered column, so nothing touches the window edge.
examples/pages/content-page.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Shipping guide · Northwind</title>
<meta name="description" content="The skeleton of a content page: site header, an article and a footer, laid out from its landmarks with no CSS of its own.">
<link rel="stylesheet" href="../../css/domestic.css">
</head>
<body>
<!-- dui:snippet name="Document page" page="layouts/page" -->
<a class="visually-hidden" href="#main">Skip to main content</a>
<header>
<a href="#home" data-link="quiet"><strong>Northwind</strong></a>
<nav aria-label="Main" data-nav="horizontal">
<ul>
<li><a href="#features">Features</a></li>
<li><a href="#pricing">Pricing</a></li>
<li><a href="#guides" aria-current="page">Guides</a></li>
<li><a href="#sign-in">Sign in</a></li>
</ul>
</nav>
</header>
<main id="main">
<article>
<h1>Shipping your first order</h1>
<p data-text="lead">From a new order to a parcel on its way, in four steps.</p>
<h2>Pick and pack</h2>
<p>Open the order, check each line against the shelf, and scan the items into the parcel. Northwind warns you when a count does not match.</p>
<h2>Choose a carrier</h2>
<p>Rates from your connected carriers appear side by side. The cheapest one that meets the promised date is selected for you.</p>
<div class="grid">
<article data-card>
<h3>Standard</h3>
<p>Three to five working days. Tracking included.</p>
</article>
<article data-card>
<h3>Express</h3>
<p>Next working day when packed before 3 PM.</p>
</article>
<article data-card>
<h3>Collect</h3>
<p>The customer picks the parcel up from your warehouse.</p>
</article>
</div>
<h2>Print and ship</h2>
<p>Print the label and packing slip together, then mark the order as shipped. The customer gets the tracking link by email.</p>
<p class="cluster">
<a href="#new-order" data-button="primary">Create an order</a>
<a href="#guides" data-button="secondary">All guides</a>
</p>
</article>
</main>
<footer>
<p data-text="small">Northwind is an example company. MIT licensed.</p>
</footer>
<!-- /dui:snippet -->
</body>
</html>
A landing page
A content page made of bands: each <section data-band> in <main> runs the full window width with its content kept in the column. data-band="hero" opens the page with a hero-size title, and data-surface="inverse" turns a band dark for a call to action.
examples/pages/landing-page.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Northwind · Ship orders from one place</title>
<meta name="description" content="The skeleton of a landing page: a hero band, full-width sections and a dark call to action, laid out with no CSS of its own.">
<link rel="stylesheet" href="../../css/domestic.css">
</head>
<body>
<!-- dui:snippet name="Landing page" page="layouts/page" -->
<a class="visually-hidden" href="#main">Skip to main content</a>
<header>
<a href="#home" data-link="quiet"><strong>Northwind</strong></a>
<nav aria-label="Main" data-nav="horizontal">
<ul>
<li><a href="#features" aria-current="page">Features</a></li>
<li><a href="#pricing">Pricing</a></li>
<li><a href="#guides">Guides</a></li>
<li><a href="#sign-in">Sign in</a></li>
</ul>
</nav>
</header>
<main id="main">
<section data-band="hero" aria-labelledby="hero-title">
<h1 id="hero-title">Ship every order from one place</h1>
<p data-text="lead">Northwind picks the carrier, prints the label and tells the customer, so your team only packs.</p>
<p class="cluster">
<a href="#sign-up" data-button="primary">Start free</a>
<a href="#demo" data-button="secondary">Book a demo</a>
</p>
</section>
<section data-band aria-labelledby="features-title">
<h2 id="features-title">Built for small warehouses</h2>
<div class="grid">
<article data-card>
<h3>Rates side by side</h3>
<p>Every connected carrier, priced for each parcel.</p>
</article>
<article data-card>
<h3>One label run</h3>
<p>Labels and packing slips print together.</p>
</article>
<article data-card>
<h3>Tracking by email</h3>
<p>Customers get the link the moment you ship.</p>
</article>
</div>
</section>
<section data-band data-surface="inverse" aria-labelledby="cta-title">
<h2 id="cta-title">Ready for your first parcel?</h2>
<p>Set up takes ten minutes. No card needed.</p>
<p class="cluster">
<a href="#sign-up" data-button="primary">Start free</a>
</p>
</section>
</main>
<footer>
<p data-text="small">Northwind is an example company. MIT licensed.</p>
</footer>
<!-- /dui:snippet -->
</body>
</html>
A sign-in page
A <main> whose only child is one card is a narrow page, centered on both axes when there is no site header: sign-in, sign-up and error pages.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sign in · Northwind</title>
<meta name="description" content="A sign-in page: one card centered on the page, laid out from its landmarks with no CSS of its own.">
<link rel="stylesheet" href="../../css/domestic.css">
</head>
<body>
<!-- dui:snippet name="Sign-in page" page="layouts/page" -->
<main id="main">
<article data-card aria-labelledby="sign-in-title">
<h1 id="sign-in-title">Sign in to Northwind</h1>
<p data-text="muted">Welcome back. Enter your details to continue.</p>
<form class="stack" method="post" action="#sign-in">
<div data-field>
<label for="sign-in-email">Email</label>
<input type="email" id="sign-in-email" name="email" autocomplete="email" required>
</div>
<div data-field>
<label for="sign-in-password">Password</label>
<input type="password" id="sign-in-password" name="password" autocomplete="current-password" required>
</div>
<label><input type="checkbox" name="remember"> Remember me on this device</label>
<button type="submit" data-button="primary">Sign in</button>
</form>
<footer>
<p data-text="small"><a href="#reset">Forgot your password?</a></p>
<p data-text="small">New to Northwind? <a href="#sign-up">Create an account</a></p>
</footer>
</article>
</main>
<!-- /dui:snippet -->
</body>
</html>
The vocabulary
Every attribute, word, class, custom element and custom property a page may use, read from the API comments in css/ (the same list the checker uses). Each attribute links to its docs page. Native attributes (aria-current, aria-sort, open, popover, closedby) are not listed because they are HTML.
Attributes (words combine, space-separated, where it makes sense: data-button="primary small"):
data-action-bar: bare (docs)data-alert:danger,info,success,warning(docs)data-app-shell: bare, orcontained,page(docs)data-badge: bare, oraccent,danger,neutral,outline,primary,success,warning(docs)data-band: bare, orhero(docs)data-breadcrumb: bare (docs)data-button: bare, ordanger,icon,large,primary,quiet,secondary,small(docs)data-card: bare, orlink(docs)data-color-scheme: bare, ordark,light(docs)data-contrast: bare, ormore(docs)data-dashboard: bare (docs)data-dashboard-tile:full,wide(docs)data-density:comfortable,compact(docs)data-dialog: bare, ordrawer,end,start(docs)data-disclosure:accordion,plain(docs)data-field: bare (docs)data-field-error: bare (docs)data-field-hint: bare (docs)data-filter-bar: bare (docs)data-form-sections: bare (docs)data-icon: bare, ormirror(docs)data-link:nav,quiet(docs)data-list-detail: bare (docs)data-motion: bare, ornone,reduced(docs)data-nav: bare, orhorizontal,vertical(docs)data-page-header: bare (docs)data-pagination: bare (docs)data-popover: bare, orblock-start,inline-end,inline-start(docs)data-prose: bare (docs)data-scroll:block,inline(docs)data-split: bare, or1:1,1:2,2:1(docs)data-surface:inverse(docs)data-table: bare, orsticky(docs)data-table-cell:number,sortable(docs)data-text:lead,muted,small(docs)data-theme:calm,compact,neutral,soft(docs)
Classes: cluster, grid, stack, visually-hidden.
Custom elements (load web-components/<name>.js as a module): dui-app-shell, dui-combobox, dui-menu, dui-table, dui-tabs, dui-toaster, dui-toolbar, dui-tooltip.
Knobs, the only custom properties a style attribute should set besides semantic --dui-* tokens: --cluster-align, --cluster-gap, --cluster-justify, --dui-contrast, --dui-size-pane, --dui-size-sidebar, --dui-size-sidebar-aux, --grid-gap, --grid-min, --stack-gap.
Which pattern for which job
| You need | Use |
|---|---|
| The frame of an app: bar, sidebar, content | App shell |
| A title, description and actions at the top of a screen | Page header |
| Summary numbers and panels that reflow | Dashboard |
| A row of headline numbers | Stat row |
| A list or table with nothing in it yet | Empty state |
| Team members with their roles | People list |
| Recent events, newest first | Notifications list |
| The signed-in person's links and sign out | Account menu |
| A grid of teasers, each with one link | Card in a .grid |
| Rows of records, sorting, selection | Data table with <dui-table> |
| Narrowing a list or table | Filter bar |
| A long form in groups, with Save at the bottom | Large forms and the action bar |
| Settings, or a list beside the selected item | List-detail |
| Views of one thing, one at a time | Tabs, only when the views are peers; otherwise links |
| A confirmation or a short task on top of the page | Dialog |
| Actions behind one button | Menu button |
| A status message | Alerts: inline, live or a toast |
| Show more or less | Disclosure |