Extra padding on headers (H1, H2, etc) (insider build 1.3.7)

SUMMARY: Extra padding now appearing at the top of the headers (H1, H2, etc) in insider build 1.3.7. I rolled back my version of Obsidian and the discrepancy went away. Just posting this as a bug in case it wasn’t intentional.

DESCRIPTION: If you have text or an image above a header, there is now a larger amount of space. Spacing below the header is still minimized. My personal preference is to have minimal spacing on top and bottom, like before. I can add a return if I need more spacing. Less spacing is nice for image alignment before a header, such as an image representing a line-break.

WORKAROUNDS: I’d be open to editing this padding myself in a CSS snippet, just not sure how to do that. Anyone know? I tried opening the console (CTRL + SHIFT + I) to find the name but no luck.

1 Like

Yes, caused by these new CSS vars

--p-spacing: 1rem;
--heading-spacing: calc(var(--p-spacing) * 2.5);

This helped me correct the spacing:

.markdown-rendered p:first-of-type {
  margin-top: 0;
}

body {
  --heading-spacing: 0;
}
1 Like

Thank you!

Just testing, your CSS doesn’t seem to be working for me.

Do I need to replace p:first-of-type with something else?

EDIT: Got it, this worked.

body {
  --p-spacing: 0;
}

Thanks again! :smiley:

There’s still something borked with the CSS in the 1.3.x releases. Even in the Sandbox vault, the <p> and <li> spacing is not right…

This is what I’m using now in custom.css

/* remove extra top margin at beginning of preview */
.markdown-rendered div.mod-header + div > * {
  margin-top: 0px;
}

.markdown-rendered div:has( > :is(p,pre,table,ul,ol)) + div > :is(h1,h2,h3,h4,h5,h6) {
  margin-top: 0px;
}
1 Like

Is there anyway to restore this to the previous layout/behaviour? lol :sweat_smile: :sob:

Thanks a lot for your snippets, they’re a huge relief lol. Kept trying to instinctly remove a ‘space’ manually that was in fact header padding lol

Yeah, it’s not perfect. The spacing is still a little weird sometimes, hopefully it will “tighten up” a little in future versions!

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