How to use HTML and CSS for printing

Genre HTMLPDFWhat to look for
Business CorrespondenceHTMLPDF Why not write business letters in HTML? They can easily be converted to PDF and attached in email. This is a minimalist example to showcase how simple it can be. Click on the HTML link and use View/Source in your browser to see!
Textbook HTMLPDFSidenotes are often placed in the outside margin of textbooks, and in the PDF version of document they alternate between left and right side. Figures and tables float to the top and bottom of pages, and wide content extend into margins.
Dictionary HTMLPDFDictionaries often use multi-column layout to save space, and running headers indicate keyword entries on that page. Notice how each letter is marked on a tab on right pages. The fonts used in the PDF version are Satyr and Faunus, made by Monokrom. has a scanned copy of the printed edition from 1910.
Scientific JournalHTML PDFThe USENIX conference Proceedings has a two-column layout with figures floating to the top and bottom. In the HTML source of this sample document, references are inline but appear at the end by way of JavaScript.
Treatise HTMLPDFThomas Malthus published his essay on Principles of Population in 1798. At the time, the descending "s" was in fashion and this reconstruction uses the 'text-replace' property to recreate the original printed book ( has a scanned copy). Also, the document uses ligatures and the Table of Contents is generated with a script.
Business CorrespondenceHTMLPDF This business letter uses several font families, and even a script to find the current date. The footer at the bottom of the page floats there by itself.
Textbook HTMLPDFThis book, Cascading Style Sheets – Designing for the Web, was the first printed book written in HTML and CSS. The sample document contains the frontmatter and first chapter.
Fiction HTMLPDFProject Gutenberg has published Oliver Twist and many other classic titles in HTML. By adding a small style sheet, a PDF file can be created. A small script automatically generates the Table of Contents.
Poetry HTMLPDFThis document reconstructs the first edition of Henrik Ibsen's poetry collection, first published in 1871. His typographers in Copenhagen didn't have all the Norwegian letters in they typecases, so they improvised. The modern-day equivalent is to modify font files, and to hand-code other errors they made. The poems are in Norwegian, but a section in English describes the process.

All PDF documents above are generated with Prince. To make these documents on your own computer, download and install Prince, then run it with command-line aguments. For example:

  prince --javascript -o letter.pdf