Typesetting sample · Article
Why documents meant to be printed, shared or read slowly still need a page — and how CSS can describe one.
A web page has no fixed shape. It pours itself into whatever window it is given, and the reader decides where every line ends. That freedom is exactly right for a news feed and exactly wrong for a contract, a report, a recipe card or a book. Those documents are read as pages: they are numbered, cited, annotated in the margin and handed to someone else, who expects to find the same paragraph in the same place.
A typesetting engine gives the page back. It takes the same HTML a browser would render, but lays it out on sheets of a fixed size, with margins, running heads and folios, and with rules about where a page may break.The relevant standards are CSS Paged Media, CSS Generated Content for Paged Media and CSS Multi-column Layout.
Once the page has a size, many small decisions follow. A heading should never be stranded at the foot of a column. A table should not split across two pages unless it must. A footnote belongs on the page where it is called, not in a list at the end. Cross-references such as “see page 12” must be counted after the layout is finished, because nobody knows the page numbers before then.
The style sheet becomes a set of rules for the whole document, not a description of one screen.
All of this can be written in ordinary CSS. The column count, the hyphenation, the drop cap that opens this article and the running head at the top of the page are declarations in the style sheet, applied the same way every time the document is typeset.Change the manuscript and typeset it again: the rules stay where they are.
Because the content and the layout are kept apart, one manuscript can become several documents. The same text can be set as an A4 report, a pocket paperback or a page-by-page reader on a phone. Japanese text can run vertically with ruby, and English text can be set in two justified columns, as here.
Where the manuscript comes from does not matter. It can be written by hand, exported from another program, taken from a web article, or drafted by an AI. The engine only needs HTML and CSS, and it gives back pages.
A table of contents is the clearest example. Its page numbers are not typed by hand: each entry points to a heading, and the engine fills in the number once the heading has found its page. The same mechanism gives running heads that change with each section, PDF bookmarks built from the headings, and figure references that stay correct after every edit.
None of this needs a special file format. The document stays an ordinary web page that a browser can still display, and the page layout is one more style sheet applied on top.