Page Breaks after Headings in PDF Export

Hi all,

What I’m trying to do

So I’ve been looking everywhere for a solution to this: When I export my notes as PDF it puts page breaks wherever, even right after headings, which is really annoying.

How can I prohibit page breaks after headings in PDF export?

Things I have tried

I’ve tried various CSS snippets similar to the one below.

@media print {
    h6 {
        page-break-after: avoid;
        break-after: avoid;

I have tried various combinations of page-break-after and just break-after and different types of selecting the tags, none of which did work.

Also, for some reason when verifying the selectors by using color: chocolate; !important, the headings didn’t get colored, but using page-break-before: always did. Maybe that has something to do with it?

Thanks in advance for any help :blush:

Steps to reproduce

  1. Create a note where a (h2) heading is at the end of a page when exported.
  2. Add the following snippet:
h2 {
  break-after: avoid

Expected result

I expected the pdf export not to place a page break between the h2 and the text below it.

Actual result

The snippet has no effect.


  • Operating system: Linux (PopOS 22.04)
Debug info:

Obsidian version: v1.1.16
Installer version: v1.1.15
Operating system: #202302091138~1675975749~22.04~f771a7f SMP PREEMPT_DYNAMIC Thu F 6.1.11-76060111-generic
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 1
Restricted mode: off
Plugins installed: 0
Plugins enabled: 0


@PaulMndn Is your snippet still not working in 1.1.16?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.