From Obsidian v1.3.7 on, there are two new custom properties that may or many not work for you. Adjusting --heading-spacing
will affect all heading levels (h1~h6).
note: changes to --heading-spacing
will only be visible in reading view or rendered contexts.
--p-spacing
defines the spacing between paragraphs (defaults to1rem
).--heading-spacing
defines the spacing above a heading when it follows a paragraph (defaults to 2.5x paragraph spacing).
body {
--p-spacing: 1rem;
--heading-spacing: calc(var(--p-spacing) * 2.5);
}
The above are the defaults, so you could try something like:
body {
--p-spacing: 1rem;
--heading-spacing: calc(var(--p-spacing) * 1.4);
}
Reading view with the default --heading-spacing: calc(var(--p-spacing) * 2.5
:
Reading view with --heading-spacing: calc(var(--p-spacing) * 1.4
:
If you only wanted to change the h1 headings for Reading view, you could try this:
.markdown-rendered div:has( > :is(p,pre,table,ul,ol)) + div > :is(h1) {
margin-top: 15px;
}