The rules
A design is one CSS file. It can contain @mixin rules, plus top-level @keyframes and @font-face rules. It cannot contain selectors or custom properties on :root. Use @media inside a mixin.
Inside a mixin you can write anything that is valid in a style rule. That includes declarations, nested rules, ::before and ::after, @media, @container and @supports. Do not rely on the markup of this page. It can change at any time. The mixin names are the only contract.
You do not have to define every mixin. A mixin you do not define does nothing, and the browser defaults apply.
What a design looks like
This is a complete design. Save it as designs/my-design.css and open ?design=my-design.
@mixin --page {
font: 1.2rem/1.6 Georgia, serif;
background: lightyellow;
}
@mixin --heading {
color: crimson;
&::before { content: "ยง "; }
}
@mixin --link {
color: navy;
&:hover { background: gold; }
}
Mixins: page and regions
--page- The entire page. Use it for the base font, text color and margins. You can also use it for page-wide decorations, such as backgrounds, with the
::beforeand::afterpseudo-elements. --container- The wrapper around the introduction, the main content and the sidebar. Use it for the overall layout: grid, columns, width, padding. You can also use it for decorations behind the layout, with
::beforeand::after. --masthead- The top of the page, which holds the site title and subtitle.
--site-title- The name of the site. Often used for image replacement.
--site-subtitle- The tagline of the site.
--summary- The short summary at the start of the page.
--preamble- The introduction text.
--content- The main content of the page: all of the sections and the footer.
--section- Every section of the main content. It holds a heading and the text, lists or code that follow it.
--footer- The footer of the page. It holds a row of links. Use
display: flexandgapto space them.
Mixins: text
--heading- Every section heading in the introduction and in the main content.
--text- Every paragraph of text.
--link- Every link. Define the
&:visited,&:hoverand&:focus-visiblestates inside it. --code- Every piece of inline code. It does not apply to code inside a code block.
--code-block- Every block of preformatted code, including the code inside it.
--term-list- Every list of terms and their descriptions, such as the lists of mixins on this page.
--term- Every term in those lists.
--term-description- The description of each term.
Good to know
Mixins in this page take no arguments. The mixin name is the only thing the page and the design have to agree on.
The markup of this page is not a public contract. It can change at any time, so avoid selectors that depend on it. Choose the mixin by the role of the element, not by how you want it to look.
CSS mixins are an experimental feature. Use a recent Chromium browser, open about://flags, and enable the "Experimental Web Platform features" flag.
Please keep the page accessible: keep a visible focus indicator, keep enough contrast and respect prefers-reduced-motion.