Guide

How to Insert Page Breaks in Markdown to PDF

Updated July 15, 2026

Because Markdown is designed for scrolling web screens, it has no native concept of print page divisions. When compiling documents like resumes, documentation packs, or eBooks, content splits arbitrarily, leaving headings stranded at the bottom of a sheet. Knowing how to leverage markdown to pdf page break css rules and inline tags lets you create professional, structured documents.

Depending on whether your document processor uses an HTML-based compiler or a LaTeX engine (like Pandoc), you can use HTML tags, CSS styling blocks, or LaTeX commands to force clean separations.

Method 1: Using Inline HTML and CSS (Easiest)

Most modern Markdown-to-PDF compilers convert your plain text into HTML before printing it to PDF via a browser engine. Because HTML is supported natively inside Markdown files, you can insert an inline div tag with CSS properties to force a page break.

Simply paste this block wherever you want a fresh page to begin:

<div style="page-break-before: always; break-before: page;"></div>

Why we use both properties:

  • page-break-before: always; is the classic property supported by older WebKit compilers (like wkhtmltopdf).
  • break-before: page; is the modern CSS standard supported by Chromium, Puppeteer, and Paged.js.

Example in a Markdown Document:

# Chapter 1: Introduction

This is the end of the first chapter. All introductory summaries are complete.

<div style="page-break-before: always; break-before: page;"></div>

# Chapter 2: Setup and Installation

Here is the start of the next section, which will always render on page 2.

Method 2: Global Page-Break Rules in CSS Stylesheets

If you want page breaks to occur automatically (for instance, starting every Level 2 heading on a new page) without copying and pasting HTML tags throughout your notes, write global CSS rules inside your theme stylesheet:

@media print {
  /* Force page breaks before major headers */
  h2 {
    break-before: page;
  }

  /* Prevent headings from being left alone at the bottom of a page */
  h1, h2, h3 {
    break-after: avoid;
  }

  /* Prevent code blocks and tables from breaking in half */
  pre, table, img, blockquote {
    break-inside: avoid;
  }
}

By applying break-after: avoid to header elements, you guarantee that a title remains attached to its following paragraph, automatically shifting to the next page if space is restricted.

Method 3: LaTeX Commands (For Pandoc Engine)

If you compile your files using Pandoc with a PDF engine like pdfLaTeX, your compiler skips HTML/CSS parsing entirely. You must use LaTeX commands directly:

To force a page break in a Pandoc CLI pipeline, insert this command into your document:

This is the end of the section.

\newpage

This starts on a new page in the LaTeX template.

You can also use \clearpage, which behaves similarly but forces all pending tables and images to render on the current page before starting the new one.

Bottom Line

Using inline HTML tags is the most direct solution for one-off documents. For larger technical reports or books, writing global CSS stylesheet rules using Paged Media standards saves time and ensures consistent padding. For a deeper analysis of how print engines handle spacing across different toolchains, read our guide on controlling page breaks in exports.

If you are tired of running command-line test builds just to verify where pages divide, try our browser-based online editor. It displays a live, paginated WYSIWYG preview that matches your downloaded PDF exactly, making spacing adjustments instant and easy.

Written by Markdown to PDF Editorial Team

Our team specializes in document design, web standards, and developer utilities. This guide was researched and vetted against current browser printing standards and Paged.js specifications. Learn more on our About page.

Try it yourself — free, no signup

Convert your Markdown to a polished PDF right in your browser.

Open the editor