Add spacing before heading when sections are collapsed

Use case or problem

Currently, obsidian won’t respect the line breaks between sections after collapsed, if we got a doc like this:

After collapsing the “part2” section under “chapter2”, we will lost all line breaks above “chapter3”:

Proposed solution

Just same as the title.

Current workaround (optional)


1 Like

This is a CSS/theme issue, unfortunately. Some folks like it the way it is. If you want more padding above headings, you should use a theme that has that, or add a custom snippet for it.

1 Like

This will add space beneath each collapsed heading - :ringer_planet:

/* add space beneath folded headers - reader view, edit view */
.is-collapsed > :is(h1, h2, h3, h4, h5, h6),
.HyperMD-header > ~ .cm-widgetBuffer:last-of-type { 
    margin-bottom: 24px !important; 


Screen Shot 2023-01-29 at 2.12.34 PM


FYI this has been asked before. If you didn’t find anything when you searched, it might have been due to wording — the term in the app is “folded” (“collapsed” is a reasonable word, it just isn’t used in the app or help docs).

1 Like

How can I take this code and use it in my existing theme? Please provide detailed steps to use…

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