Web design and digital-business ideas grounded in real tasks.

CSS widows and orphans help control paragraphs across printed pages

A print designer comparing two print preview pages with different paragraph breaks on a monitor.
AI-generated photographic illustration; not documentary photography.

A web article can read comfortably on screen and produce awkward pages when printed. A paragraph may begin with one lonely line at the bottom of a page, or end with a single line at the top of the next. CSS provides controls for these breaks, although the result still needs checking.

MDN defines orphans as the minimum number of lines kept at the bottom of a fragment before a break. Widows sets the corresponding minimum at the top of the next fragment. The fragments may be pages or columns.

Start with a small print rule

@media print {
  article p {
    orphans: 3;
    widows: 3;
  }
}

This illustrative rule asks for at least three paragraph lines on each side of a break where the layout can satisfy it. It does not prevent every paragraph from splitting, keep every heading with the next paragraph or guarantee the same pagination in every browser.

Inspect the output you will distribute

MDN marks these properties as having limited availability, so check the browser or PDF renderer used in your workflow. A declaration appearing in the stylesheet is not proof that the renderer applied it.

Create a test article with short and long paragraphs, a heading near a page boundary and an image. Print to PDF at the intended paper size and margins. Inspect the end of each page and the beginning of the next. Change the font size or margins once to see whether the improvement survives ordinary variation.

Keep the controls separate

If a heading is stranded, investigate break control around that heading rather than increasing the paragraph line count indefinitely. If an image consumes most of a page, consider its print dimensions. Several layout constraints may compete for the same remaining space.

Record the browser, paper size and export settings alongside the test PDF. That makes the result reproducible when another person produces the final copy. Good print styling is a combination of sensible rules and inspecting actual pages, not a promise made by one CSS declaration.