Page breaks in Markdown

Start a chapter, an appendix or an answer sheet on a new page, and keep things that belong together on the same one. This guide covers page breaks, with examples you can load into the converter and download as a PDF.

Markdown
Preview

Starting a new page

Markdown was designed for the web, where pages scroll forever, so it has no syntax for a page break. But Markdown lets you mix in HTML, and md2pdf.me's styles recognize one line of it as a page break:

<div class="page-break"></div>

Put it on a line of its own, with a blank line before and after, and everything after it starts at the top of a new page:

This is the end of the introduction.

<div class="page-break"></div>

## Chapter one

This chapter starts on a new page.

The line is invisible in the PDF; it only marks where the page ends. You can copy it from this page whenever you need it. The same line works in the command-line version of md2pdf, so documents converted either way break in the same places.

When to use a page break

Most documents don't need any: md2pdf.me already avoids awkward breaks, as the next section explains, and a document with too many forced breaks ends up with half-empty pages. Page breaks earn their place when a new page means something to the reader:

# Annual report 2026

Prepared for the board of trustees, March 2027

<div class="page-break"></div>

## Summary

It was a year of steady growth...

Breaks md2pdf.me handles for you

Before you add breaks by hand, it helps to know what the styles already do, because most bad page breaks never happen:

Because of these rules, a page sometimes ends a little early, leaving a gap at the bottom. That's the price of keeping a table row or a code block in one piece, and it's usually the better trade.

Keeping things together

Sometimes several blocks belong together: a short introduction and the list after it, a photo and its caption, or a question and its multiple-choice answers. To keep a group on one page, wrap it in a div that asks the browser not to break inside it. Leave a blank line after the opening tag and before the closing one, so the Markdown inside is still formatted:

<div style="break-inside: avoid">

**Question 4.** Which planet has the most moons?

- A. Jupiter
- B. Saturn
- C. Uranus
- D. Neptune

</div>

If the group doesn't fit in the space left on the page, the whole group moves to the next one. Use this for small groups only: wrapping a large part of a document leaves big gaps, and anything taller than a page is split anyway.

Page size, margins and numbers

Where pages break also depends on how much fits on each one. Choose Letter, A4 or Legal from the menu next to Download PDF; Letter is usual in the US and Canada, and A4 almost everywhere else. Legal is longer than Letter, so more fits on each page. The margins are set by the style, from Résumé's narrow margins to the wide ones of Classic and Academic, and by the Spacing menu, so switching either can move every break in the document. Page size and margins has the details.

StylePage numbers
Classic, WorksheetCentered at the bottom, from page two
AcademicCentered at the bottom of every page
ModernBottom right, from page two
ReportPage 3 of 12 at the bottom right, and the title at the top of every page after the first
Résumé, GitHubNone
GothicCentered at the bottom between dashes, from page two
SandwakeFolio 02 at the bottom right, and the title at the top left, from page two
ElvishRoman numerals centered at the bottom of every page, and the title at the top of every page after the first
CyberpunkPG 02 / 12 at the bottom right of every page, and the title at the top of every page after the first
NewspaperAt the top left, and the title at the top center, from page two
FiendishPage 3 of 12 at the bottom right and an Initial here line at the bottom left of every page, and the title at the top of every page after the first

The browser's own print settings matter too. Leave the scale at 100% (or Default) in the print dialog: shrinking the page fits more on it, but makes the text smaller than the style intends.

Seeing where pages end

md2pdf.me's preview shows your document at the real width of the page, so line lengths, tables and code look as they will in the PDF. In Chrome and Edge, turn on Pages above the preview to see it page by page, with each page's running header and page number. The pages end as the PDF's will, give or take a line or two, and the Preview label counts them. In other browsers the preview is one long sheet. There, to see exactly where each page ends, click Download PDF: the print dialog's preview shows every page, and you can close it, adjust the Markdown and try again before saving.

With Pages off, the Preview label estimates the page count as you type. When a document nearly fills its last page, it shows a range, such as 2–3 pages, because the preview can't tell exactly where a table, code block or heading will break. It doesn't estimate a count for a document that sets its own page size or margins, or for one in a style that prints in columns, such as Newspaper; Pages counts those too.

Work from the top down. Moving one break changes everything after it, so fix the first awkward page, check again, then move on to the next.

Common mistakes

Other topics

Back to the Markdown guide