# Header spacing

**URL:** <https://forum.obsidian.md/t/header-spacing/66096>\
**Category:** Devs: Theme Design & Custom CSS\
**Tags:** custom-css\
**Created:** [August 31, 2023, 1:56am UTC](https://forum.obsidian.md/t/header-spacing/66096 "2023-08-31T01:56:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![faultycar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/f05b48/32.png) [@faultycar](https://forum.obsidian.md/u/faultycar)\
**Post date:** [August 31, 2023, 1:56am UTC](https://forum.obsidian.md/t/header-spacing/66096/1 "2023-08-31T01:56:12Z")

</div>

Trying to learn the details of obsidian and could use some help.

### What I’m trying to do

The picture is an embed ![[note/#]] and I would like to reduce the amount of space between the “v1” and the text.

 ![image](https://forum.obsidian.md/uploads/default/original/3X/b/8/b8ca07eac3662ba8fc4694c83151473e61d8f26c.png)

### Things I have tried

I’ve tried custom script from [Huge spacing between headers and text](https://forum.obsidian.md/t/huge-spacing-between-headers-and-text/41749) but with no success.

Thank you!

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [August 31, 2023, 6:23am UTC](https://forum.obsidian.md/t/header-spacing/66096/2 "2023-08-31T06:23:43Z")

</div>

These posts might help you figure things out:

[https://forum.obsidian.md/t/getting-comfortable-with-obsidian-css](https://forum.obsidian.md/t/getting-comfortable-with-obsidian-css)

[https://forum.obsidian.md/t/meta-post-common-css-hacks](https://forum.obsidian.md/t/meta-post-common-css-hacks)

If you don’t get an answer here, there are some extremely kind wizards in the #appearance channel of Obsidian’s Discord server who essentially produce snippets on request.

---

<div class="post-metadata">

**Author:** ![ariehen](https://forum.obsidian.md/user_avatar/forum.obsidian.md/ariehen/32/46932_2.png) [@ariehen](https://forum.obsidian.md/u/ariehen)\
**Post date:** [August 31, 2023, 6:28am UTC](https://forum.obsidian.md/t/header-spacing/66096/3 "2023-08-31T06:28:13Z")

</div>

Would you like to reduce that spacing in all the instances of a `# heading` before a block/paragraph? Or only those within ![[embeds]]?

Also, all headings or only `# h1`s?

CSS is usually very nit-picky. 👨🏽‍⚖️

_EDIT:_ updated to cover all ![[embedded]] headings.

```css
.markdown-rendered :is(h1, h2, h3, h4, h5, h6) {
    margin-block-end: 0.2em; /* default is 1em */    
}

```

---

<div class="post-metadata">

**Author:** ![faultycar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/f05b48/32.png) [@faultycar](https://forum.obsidian.md/u/faultycar)\
**Post date:** [September 2, 2023, 12:32pm UTC](https://forum.obsidian.md/t/header-spacing/66096/4 "2023-09-02T12:32:03Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![faultycar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/f05b48/32.png) [@faultycar](https://forum.obsidian.md/u/faultycar)\
**Post date:** [September 2, 2023, 12:35pm UTC](https://forum.obsidian.md/t/header-spacing/66096/5 "2023-09-02T12:35:50Z")

</div>

> [@ariehen](#):
>
> ```auto
> .markdown-rendered :is(h1, h2, h3, h4, h5, h6) {
> margin-block-end: 0.2em; /* default is 1em */    
> }
> 
> ```

I must be doing something wrong on my end, the change is not taking. If i understand correctly, I create a .css file, with the code you provided, in css snippets?

Thank you for the help!  
Erik

---

<div class="post-metadata">

**Author:** ![ariehen](https://forum.obsidian.md/user_avatar/forum.obsidian.md/ariehen/32/46932_2.png) [@ariehen](https://forum.obsidian.md/u/ariehen)\
**Post date:** [September 2, 2023, 2:43pm UTC](https://forum.obsidian.md/t/header-spacing/66096/6 "2023-09-02T14:43:30Z")

</div>

Yeah, the steps are linked below. The `.css` file can be named anything. Be sure to use a proper code editor to make it (Notepad++, Sublime Text, VSCode, etc).

> **[CSS snippets - Obsidian Help](https://help.obsidian.md/Extending+Obsidian/CSS+snippets)**
>
> Learn how to modify aspects of the Obsidian appearance without needing to Build a theme. CSS is a language to describe how to present a HTML document. By adding CSS snippets, you can redefine parts o…

Keep in mind, this CSS only covers headings in ![[embeds]], not headings in regular text.

* * *

For regular text, you could give these custom properties a try:

> [@Need help with the distance between the headers and text using minimal theme](https://forum.obsidian.md/t/need-help-with-the-distance-between-the-headers-and-text-using-minimal-theme/65920/2):
>
> If you are using Obsidian v1.3.7+, there are some new theme variables to play with having to do with spacing. They work as is with Minimal. You’ll see a change of --p-spacing in both editing and reading modes, and --heading-spacing only in reading mode. /\* default vaules \*/ /\*body { --p-spacing: 1rem; --heading-spacing: calc(var(--p-spacing) \* 2.5); }\*/ body { --p-spacing: 1rem; --heading-spacing: calc(var(--p-spacing) \* 1); } You could give those a try (adjusting the values …

---

<div class="post-metadata">

**Author:** ![faultycar](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/f05b48/32.png) [@faultycar](https://forum.obsidian.md/u/faultycar)\
**Post date:** [September 3, 2023, 6:31pm UTC](https://forum.obsidian.md/t/header-spacing/66096/7 "2023-09-03T18:31:20Z")

</div>

This is great! Thank you for the help and for your time.

Erik

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [December 2, 2023, 6:31pm UTC](https://forum.obsidian.md/t/header-spacing/66096/8 "2023-12-02T18:31:53Z")

</div>

Closed on December 2, 2023, 6:31pm UTC

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