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.
Download PDF opens your browser's print dialog. Choose Save as PDF as the destination.
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:
- A title page. Put the title, author and date on their own, then a break, so the document proper starts on page two.
- Chapters and major sections. Starting each on a new page makes a long document easier to find your way around in print.
- Appendices and reference material. Long tables, raw data or terms and conditions can follow the main text on pages of their own.
- Answers and handouts. A quiz with the answers on a separate page, or a worksheet that will be printed and handed out page by page.
- Notes at the end. A break at the very end of the document puts the footnotes on a page of their own, like the notes section of a book.
# 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:
- Headings stay with their text. A heading is never left alone at the bottom of a page; it moves to the next page with the paragraph it introduces.
- Blocks aren't split. Code blocks, quotes, images, diagrams and equations move to the next page whole rather than being cut in two. Only something taller than a whole page is split.
- Table rows stay whole. A long table breaks between rows, and in Chrome and Edge its header row repeats at the top of the next page.
- No stranded lines. A paragraph won't leave a single line at the bottom of one page or the top of the next.
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.
| Style | Page numbers |
|---|---|
| Classic, Worksheet | Centered at the bottom, from page two |
| Academic | Centered at the bottom of every page |
| Modern | Bottom right, from page two |
| Report | Page 3 of 12 at the bottom right, and the title at the top of every page after the first |
| Résumé, GitHub | None |
| Gothic | Centered at the bottom between dashes, from page two |
| Sandwake | Folio 02 at the bottom right, and the title at the top left, from page two |
| Elvish | Roman numerals centered at the bottom of every page, and the title at the top of every page after the first |
| Cyberpunk | PG 02 / 12 at the bottom right of every page, and the title at the top of every page after the first |
| Newspaper | At the top left, and the title at the top center, from page two |
| Fiendish | Page 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
- Using
---as a page break. Three dashes draw a horizontal rule (or, in Classic, a small ornament). Some slide tools treat them as a break, but in a PDF they don't start a new page. - LaTeX commands.
\newpage,\pagebreakand\clearpageare LaTeX, not Markdown, and show up as text. - No blank line after the break. A line typed directly after the
<div>is treated as part of the HTML, so a heading there shows up as plain text with its##still visible. Leave a blank line after the break. - Two breaks in a row. Each one ends a page, so two together leave a blank page between them. A break at the very end of a document doesn't add an empty page, though.
Other topics
- Tables: rows, columns and alignment
- Math and LaTeX: formulas and equations
- Code blocks: code with syntax highlighting
- Footnotes: numbered notes and references
- Task lists: checklists with tick boxes