Heading spacing settings in Style Settings

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I want to reduce the space between headings and subsequent text in reading mode. I use the Minimal theme, and when I open the appropriate Style Settings and enter a new setting (say, 1em instead of the default 2em), nothing changes in reading mode. Am I missing something? Thank you.

D

Things I have tried

I believe Minimal’s Heading spacing option only adjusts this:

--heading-spacing defines the spacing above a heading when it follows a paragraph (defaults to 2.5x paragraph spacing).

For directly under the headings, is seems you need work with the heading margin-bottom and paragraph top margin. Without using negative values (which you can do but probably shouldn’t), you could give this a try:

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

.markdown-rendered p {
    margin-block-start: 0px;
}

Before:
Screenshot 2023-10-11 112312

After:

Screenshot 2023-10-11 112348

I haven’t checked every scenario with this, but you can always adjust it (or not use it) if you see any weirdness in other places. :smiley:

1 Like

Thank you so much. Exactly the effect I want. One question: Do I use this as a CSS snippet? Or do I go into the theme CSS and edit that?

Unless you are making your own theme, you’ll always want to use a snippet. If you alter the theme CSS file itself, any time there’s an update (in the past few days Minimal has had a few), your changes will be overwritten.

https://help.obsidian.md/Extending+Obsidian/CSS+snippets

The .css file(s) be named anything, and you can put multiple snippets in one file. I tend to group similar snippets into one file, but it’s all up to you.

That’s what I thought, but I was trying not to overestimate my scant knowledge. Thank you again.

D

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