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:
image

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

Proposed solution

Just same as the title.

Current workaround (optional)

None

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-fold-indicator.is-collapsed ~ .cm-widgetBuffer:last-of-type { 
    margin-bottom: 24px !important; 
}

RESULT:

Screen Shot 2023-01-29 at 2.12.34 PM

4 Likes

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…