Skip to content

CSS contract

This page is generated from MDLeaf’s source code, so it always matches the app. Contract version:

1

.

Stability policy: within a contract version, properties and classes are only ever added, never renamed or removed. A breaking change increases the version, and this page keeps a migration note.

Stylesheets apply in this order; later ones win at equal specificity:

  1. KaTeX’s stylesheet
  2. The bundled fonts
  3. MDLeaf’s base stylesheet: contract defaults and all structural rules
  4. Your theme
  5. The page geometry from the profile (@page size and margins, and the read-only layout properties)
  6. Preview chrome (screen only: page gaps, shadows, zoom)

Because the profile comes after the theme, page size and margins always come from the profile. A theme may still style other @page properties.

html has the class mdl-mode-draft or mdl-mode-page; when printing it is always page mode.

Set these on :root. The defaults are those of the base stylesheet.

PropertyGroupDefaultDescriptionRead-only
—mdl-font-bodyFonts“Source Serif 4 Variable”, Georgia, serifBody text family
—mdl-font-headingFontsvar(—mdl-font-body)Heading family
—mdl-font-monoFonts“JetBrains Mono Variable”, ui-monospace, monospaceCode family
—mdl-font-sizeFonts11ptBase body size
—mdl-line-heightFonts1.45Body line height
—mdl-color-textColours#1b1b1bBody text
—mdl-color-mutedColours#5f6368Secondary text (captions, TOC leaders)
—mdl-color-accentColours#1a4d8fLinks and accents
—mdl-color-borderColours#d0d4d9Rules and borders
—mdl-color-page-bgColours#ffffffPage background
—mdl-heading-colorHeadingsvar(—mdl-color-text)Heading colour
—mdl-heading-weightHeadings700Heading weight
—mdl-h1-sizeHeadings2emHeading 1 size
—mdl-h2-sizeHeadings1.6emHeading 2 size
—mdl-h3-sizeHeadings1.3emHeading 3 size
—mdl-h4-sizeHeadings1.1emHeading 4 size
—mdl-h5-sizeHeadings1emHeading 5 size
—mdl-h6-sizeHeadings0.9emHeading 6 size
—mdl-heading-space-beforeHeadings1.2emSpace above headings
—mdl-heading-space-afterHeadings0.5emSpace below headings
—mdl-paragraph-spacingBlocks0.6emSpace between paragraphs
—mdl-blockquote-borderBlocks3px solid var(—mdl-color-border)Quote rule
—mdl-blockquote-colorBlocksvar(—mdl-color-muted)Quote text
—mdl-code-font-sizeCode0.9emInline and block code size
—mdl-code-bgCode#f4f5f7Code background
—mdl-code-colorCodevar(—mdl-color-text)Code text
—mdl-code-radiusCode3pxCorner radius
—mdl-code-paddingCode0.75em 1emCode block padding
—mdl-code-keywordCode#cf222eHighlighted keywords
—mdl-code-stringCode#0a3069Strings, regular expressions, URLs
—mdl-code-commentCodevar(—mdl-color-muted)Comments
—mdl-code-numberCode#0550aeNumbers, booleans, null and other constants
—mdl-code-nameCode#8250dfFunction and macro names
—mdl-code-typeCode#953800Types, classes, namespaces, HTML tags
—mdl-code-propertyCode#0550aeProperties, keys and attributes
—mdl-code-metaCode#6639baAnnotations, decorators, preprocessor lines
—mdl-code-insertedCode#116329Added lines (diff)
—mdl-code-deletedCode#82071eRemoved lines (diff)
—mdl-table-font-sizeTables0.95emTable text
—mdl-table-borderTables1px solid var(—mdl-color-border)Cell borders
—mdl-table-cell-paddingTables0.35em 0.6emCell padding
—mdl-table-header-bgTablestransparentHeader row background
—mdl-table-stripe-bgTablestransparentEven-row background
—mdl-running-fontRunningvar(—mdl-font-body)Header/footer family
—mdl-running-font-sizeRunning9ptHeader/footer size
—mdl-running-colorRunningvar(—mdl-color-muted)Header/footer colour
—mdl-toc-leaderTOC”.”Leader character ("" = none)
—mdl-toc-indentTOC1.2emIndent per level
—mdl-toc-title-sizeTOCvar(—mdl-h2-size)TOC title size
—mdl-draft-marker-colorDraft#9aa0a6Page-break and directive pill colour (draft only)
—mdl-page-widthLayout210mmPage width (from the profile)yes
—mdl-page-heightLayout297mmPage height (from the profile)yes
—mdl-margin-topLayout25mmTop margin (from the profile)yes
—mdl-margin-rightLayout25mmRight margin (from the profile)yes
—mdl-margin-bottomLayout25mmBottom margin (from the profile)yes
—mdl-margin-leftLayout25mmLeft margin (from the profile)yes
—mdl-content-widthLayout160mmContent-area width (from the profile)yes
—mdl-content-heightLayout247mmContent-area height (from the profile)yes
SelectorModesMeaning
html.mdl-mode-draft / html.mdl-mode-pagedraft, pageCurrent preview mode
.mdl-documentdraft, pageRoot <article> of rendered content
.mdl-pagepageOne page (alias class added to .pagedjs_page)
.mdl-page—firstpagePhysical page 1
.mdl-page—no-header, .mdl-page—no-footerpageHeader/footer hidden on that page
[data-mdl-page]pageDisplayed page number on .mdl-page
.mdl-page-header, .mdl-page-footerpageRunning header/footer containers
.mdl-slot, .mdl-slot—left, .mdl-slot—center, .mdl-slot—rightpageHeader/footer slots
.mdl-pagebreak, .mdl-pagebreak-labeldraft, pagePage-break marker (label visible in draft only)
.mdl-directive, .mdl-directive—header, —footer, —hide, —pagenumber, .mdl-directive-pilldraft, pageDirective markers (pill visible in draft only)
.mdl-toc, .mdl-toc-title, .mdl-toc-list, .mdl-toc-item, .mdl-toc-item—level-1 … —level-6, .mdl-toc-link, .mdl-toc-text, .mdl-toc-leader, .mdl-toc-pagedraft, pageTable of contents
.mdl-img, .mdl-img[data-align], .mdl-img-block, .mdl-img-missingdraft, pageImages
.mdl-math, .katex, .katex-displaydraft, pageMath
.mdl-keep, .mdl-keep—heading, .mdl-force-breakpageKeep-together wrappers (themes may add break-* rules to them)
section.footnotes, sup.footnote-ref, a.footnote-backrefdraft, pageFootnotes (from markdown-it-footnote)
ul.contains-task-list, li.task-list-item, input.task-list-item-checkboxdraft, pageTask lists
.mdl-tok-keyword, .mdl-tok-string, .mdl-tok-comment, .mdl-tok-number, .mdl-tok-name, .mdl-tok-type, .mdl-tok-property, .mdl-tok-meta, .mdl-tok-inserted, .mdl-tok-deleted, .mdl-tok-heading, .mdl-tok-strong, .mdl-tok-emphasisdraft, pageHighlighted tokens inside fenced code with a known language
h1–h6, p, a, ul, ol, blockquote, pre > code, code, table, thead, th, td, hr, imgdraft, pageStandard elements inside .mdl-document

Themes may also use paged-media CSS: break-before, break-after, break-inside, orphans, widows, @page :first and @page margin boxes.

<div class="pagedjs_page mdl-page mdl-page--first" data-mdl-page="1">
…
<div class="pagedjs_pagebox">
<div class="pagedjs_area">
<article class="mdl-document">…your content…</article>
</div>
<div class="mdl-page-header">
<div class="mdl-slot mdl-slot--left">…</div>
<div class="mdl-slot mdl-slot--center">…</div>
<div class="mdl-slot mdl-slot--right">…</div>
</div>
<div class="mdl-page-footer">…same three slots…</div>
</div>
</div>
<nav class="mdl-toc">
<div class="mdl-toc-title" role="heading" aria-level="2">Contents</div>
<ol class="mdl-toc-list">
<li class="mdl-toc-item mdl-toc-item--level-2">
<a class="mdl-toc-link" href="#results">
<span class="mdl-toc-text">Results</span>
<span class="mdl-toc-leader" aria-hidden="true"></span>
<span class="mdl-toc-page">7</span>
</a>
</li>
</ol>
</nav>
  • In a file theme, embed fonts and images as data: URLs.
  • A URL theme caches only its own text; fonts it loads from elsewhere need a network.
Download the starter stylesheet