Paged Media CSS

From XPUB & Lens-Based wiki


Cascading Style Sheets

    background-color: pink;
    color: green;
    margin: 100px;

CSS1, CSS2.1, CSS3

Screenshot from 2023-10-03 15-11-04.png

Screenshot of one of the slides from Julie Blanc, as part of her presentation during the Paged.js workshop in October 2022.

CSS Paged Media module

Paged media have many special requirements for the display of document content, which have evolved over the long history of printed books. Running headers and footers function as aids to navigation. Notes may appear at the bottom of the page, as footnotes. The properties of pages themselves may change based on their content or position in the document. Leaders visually connect related content. Cross-references may require generated text. Some paged media formats such as PDF use bookmarks for navigation.

This module defines new properties and values, so that authors may bring these techniques to paged media. (published version) (current draft)

Not [yet] supported atm

Modern browsers (no support yet)

Most of the Paged Media properties are not supported by modern (aka up-to-date) browsers unfortunately, as the W3C CSS Paged Media module is still in a "working draft" mode.

You can check if a CSS property is supported by a specific browser at:

It's good to say that you can still get pretty far with the properties that are supported atm. It really depends on what you want to make in the end.

Paged.js and Weasyprint (already support)

If you nevertheless do want to use these properties, you can use Paged.js, a Javascript library also known as a polyfill, that aims to fill the gaps between the working draft document and modern browsers. The project comes with extended documentation:

Or you can use Weasyprint, who also supports most of the CSS Paged Media properties described on this page. In the Weasyprint documentation here you can read which properties are supported and which ones not.

page rules

  • @page
    • size
    • margin
    • bleed (not [yet] supported atm)
    • marks (not [yet] supported atm)
    size: A4 portrait;
    margin: 20mm 30mm;
    bleed: 3mm;
    marks: crop;

page selectors

  • @page :left, @page :right
  • @page :first
  • @page :blank
  • @page :nth(1) (not [yet] supported atm)
  • @page: groupname + @page groupname (not [yet] supported atm)
@page :first{
    background-color: MediumPurple;
@page :left{
    background-color: pink;
@page :right{
    background-color: yellow;

@page margin at-rules

  • @top-left{} (not [yet] supported atm)
  • @left-bottom{} (not [yet] supported atm)
  • @bottom-center{} (not [yet] supported atm)
  • etc.
        background-color: aqua;
        content: "This is a small note in the bottom margin."


@page margin at-rules boxes, image from Paged.js.

page breaks

  • break-before
  • break-after
h1 {
    break-after: always;

running headers and footers

  • content(), string() - named strings (not [yet] supported atm)
  • running(), element() - running elements (not [yet] supported atm)
        background-color: lavendar;
        content: string(myTitle);
    string-set: myTitle content(text);

page counters

  • counter() (not [yet] supported atm)
        content: counter(page);


  • target-counter() (not [yet] supported atm)
  • target-text() (not [yet] supported atm)
<h1 id="maintitle">Protocols for an Active Archive (shownotes week 3)</h1>

<p>Some text that refer to the <a class="link" href="#maintitle">title</a>.</p>
.link::after {
  content: " (which is: " target-text(attr(href url)) ")";
} + +

See also