markoto

Add your own CSS

The theme settings cover fonts, colors, page geometry, headers and footers. When you need something they don't offer, such as a page number that says "3 / 12", a colored line under every second-level heading or a two-column glossary, add your own CSS rules to the document.

Open the Theme tab and expand Custom CSS at the bottom. Type your rules, and the preview updates after a short pause. Your rules come after the theme settings, so they win when both style the same thing.

Custom CSS styles the document only: the live preview, printing (Cmd/Ctrl+P) and the PDF export. The editor and the rest of markoto stay as they are.

Try the theme settings first. They keep working when you switch presets, and the markoto assistant can change them for you. Reach for CSS when no setting does what you want.

Custom CSS is available on every self-hosted instance. On markoto.app it is not part of the free plan: it needs a paid plan once plans launch.

Where your CSS applies

Everything you write in the editor ends up inside one element, .paged-doc. Start your selectors with it so they only touch the document:

SelectorWhat it styles
.paged-docThe whole document body. Two- and three-column themes set column-count here.
.paged-doc h1 … h6Headings. Each one gets an id made from its text, so #introduction targets the heading "Introduction".
.paged-doc pParagraphs.
.paged-doc aLinks.
.paged-doc blockquoteQuotes (>).
.paged-doc tableTables, with th, td, thead and tbody tr inside.
.paged-doc preCode blocks. Inline code is .paged-doc :not(pre) > code. Each line is a .code-line with its number in data-line.
.paged-doc .code-blockA code block with a title (```ts title="app.ts"); the title bar is .code-title.
.paged-doc imgImages.
.paged-doc figureThe figure around an image; the caption is figcaption.
.paged-doc hrHorizontal rules (---).
.paged-doc li.task-list-itemItems of a task list (- [ ]).
.paged-doc .markdown-alertAlert boxes (> [!NOTE]). Each kind adds a class: .markdown-alert-note, -tip, -important, -warning, -caution.
.paged-doc .markdown-alert-titleThe title line of an alert.
.paged-doc .table-of-contentsThe table of contents from [[toc]].
.paged-doc .footnoteFootnotes, printed at the foot of the page.
.paged-doc .mermaidDiagrams. Style the drawing itself with .paged-doc .mermaid > svg.
.paged-doc .katexMath.
.paged-doc .page-breakA <!-- pagebreak --> marker.
.paged-doc .markoto-dropcapThe large first letter, when the theme has a drop cap.

Your own classes

To style one part of the document, give it a class in the Markdown and target that class. Put {.name} right after a heading, link, image or inline code, or on the line after a paragraph, list, quote or table:

## Method {.ruled}

- Term one
- Term two
{.two-columns}

Then .paged-doc .ruled and .paged-doc .two-columns style just those parts. See Markdown syntax for the attribute syntax.

The cover page

When the cover page is on, its parts have their own classes. The cover always spans the full page, also in multi-column themes.

SelectorWhat it styles
.paged-doc .markoto-coverThe whole cover page.
.paged-doc .markoto-cover-logoThe logo.
.paged-doc .markoto-cover-titleThe title.
.paged-doc .markoto-cover-subtitleThe subtitle.
.paged-doc .markoto-cover-metaThe block with authors and date.
.paged-doc .markoto-cover-authorOne author line.
.paged-doc .markoto-cover-dateThe date.
.paged-doc .markoto-title-blockThe title block on page 1 (layout Title block), instead of a cover page.
.paged-doc .markoto-cover-authorsThe row of authors in the title block; each is a .markoto-cover-author-card with .markoto-cover-author and .markoto-cover-affiliation.
.paged-doc .markoto-abstractThe abstract in the title block; its heading is .markoto-abstract-title.

Theme colors

The theme's colors are available as CSS variables. Use them instead of fixed colors, and your rules follow the theme when you change it:

VariableColor
--doc-brandBrand (accent) color
--doc-secondaryMuted color for hairlines, captions and borders
--doc-textBody text
--doc-bgPaper
--doc-heading-colorHeadings
--doc-accentSame as --doc-brand

The fonts are variables too, so a rule can follow the fonts you pick:

VariableFont
--doc-body-fontBody text
--doc-heading-fontHeadings
--doc-meta-fontHeader, footer and captions
--doc-mono-fontCode

For example border-bottom: 2px solid var(--doc-brand) or font-family: var(--doc-heading-font).

Document structure

markoto marks parts of the text so that CSS can find them, also after the text has been split into pages:

SelectorWhat it styles
.paged-doc .markoto-first-sectionThe first top-level heading of the text (not the first one on every page).
.paged-doc .markoto-section-headingEvery top-level heading (heading 1, or heading 2 if the text has no heading 1).
.paged-doc .markoto-referencesThe lists and paragraphs of the References section; its heading is .markoto-references-heading.
.paged-doc table > captionA table caption (Table: …).
.paged-doc p.markoto-labelledA paragraph that opens with a bold label: **Note.** …, **Pricing:** …. An alert whose first paragraph is one is .markoto-alert-labelled.
.paged-doc .markoto-endpointA line holding only POST /payments (a paragraph or an http code block); the method is .markoto-http-method, the path .markoto-http-path.
.paged-doc p.markoto-leadThe paragraph right under the cover or title block.
.paged-doc .markoto-openingThe first few words of that paragraph and of the first paragraph after every top-level heading, for small-capital openings.

h1:first-of-type does not work for "the first heading": every page starts its own copy of the document, so it matches the first heading on each page.

Pages, headers and footers

Pages are styled with @page:

RuleWhat it styles
@pageEvery page: size, margins, and the margin boxes.
@page :firstThe first page. :left and :right work for facing pages.
@page cover-pageThe cover page sheet.
@top-centerOne of six header and footer boxes inside @page: @top-left, @top-center, @top-right, @bottom-left, @bottom-center, @bottom-right. Fill one with content:, e.g. counter(page), counter(pages) or text in quotes.

Examples

Each example works on its own. Paste it into the Custom CSS section and change the values.

A colored line under every second-level heading:

.paged-doc h2 {
  padding-bottom: 0.2em;
  border-bottom: 2px solid var(--doc-brand);
}

Zebra stripes in one table (put {.striped} on the line after the table):

.paged-doc table.striped tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--doc-secondary) 12%, transparent);
}

A quieter look for notes, with the title in small capitals:

.paged-doc .markdown-alert-note {
  border-left: 3px solid var(--doc-brand);
  background: color-mix(in srgb, var(--doc-brand) 6%, transparent);
  border-radius: 0;
}
.paged-doc .markdown-alert-note .markdown-alert-title {
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

A two-column section (put {.two-columns} on the line after a list or quote):

.paged-doc .two-columns {
  column-count: 2;
  column-gap: 8mm;
}
.paged-doc blockquote.two-columns {
  border: none;
  padding: 0;
  font-style: normal;
}

Page number and page count in the footer:

@page {
  @bottom-center {
    content: counter(page) " / " counter(pages);
  }
}

No header or footer on the first page:

@page :first {
  @top-center { content: none; }
  @bottom-center { content: none; }
}

A cover title in capitals with wide spacing:

.paged-doc .markoto-cover-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

Rules that only apply to the PDF and printing:

@media print {
  .paged-doc a {
    color: var(--doc-text);
    text-decoration: none;
  }
}

The Custom CSS section in the Theme tab has some of these ready to insert.

What you can write

  • Ordinary style rules, with any selector inside .paged-doc.
  • @media, @supports, @page (with its margin boxes), @keyframes, @container, @layer and @font-feature-values.

What isn't allowed, and why

Your CSS also runs for everyone who opens or exports the document, so some things are turned off:

  • Loading from other websites. url() can only use images uploaded to this document or data:image/png, jpeg, gif or webp URLs. To use an image, drop it into the document first, then copy its /api/files/… address into url(). Images from other documents don't carry over, and SVG data URLs aren't allowed. A CSS variable inside url() or image-set() isn't allowed either, since its value can't be checked.
  • @import and @font-face. Pick fonts in the theme's font settings instead. @namespace, @property and @counter-style are refused too.
  • Script-like constructs such as expression(), behavior, -moz-binding and javascript: URLs.
  • More than 64 KB of CSS.

If a rule isn't allowed, the Custom CSS section lists it with its line and column, and your changes aren't applied until it's fixed. The rules that were already applied stay in place in the meantime.

Themes, presets and copies

  • Custom CSS is part of the theme. Saving the theme as a preset, or setting it as a workspace default, keeps the CSS with it.
  • Applying a built-in preset keeps your custom CSS. A few presets bring CSS of their own (arXiv preprint: the table rules, figure captions and reference list of the LaTeX template). It goes in front of yours, so your rules still win, and switching to another preset takes it out again as long as you haven't edited it. Applying a saved theme replaces your CSS with the saved theme's CSS, and new documents in a workspace start with the workspace default's CSS.
  • When you duplicate a document, image addresses in the CSS point at the copy's images.
  • Saving the document as Markdown keeps the CSS in the file; importing the file brings it back.
  • The markoto assistant can read and change your custom CSS too. Ask it for a look the theme settings can't make ("underline the section headings in our brand color") and it writes the CSS, following the same rules.

What's next