How to add paddings in my body text?

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 would kike to add a 5px top and bottom padding to my body text

Things I have tried

In my obsidian.css file, I have tried codes such as :

.cm-s-obsidian {
padding-top: 5px;
padding-bottom: 5px
}

or

.cm-s-obsidian {
padding: 5px 0 5px 0;
}

Both above codes don’t work.
Yet below code works :

.cm-s-obsidian {
font-size: 18px;
			}

Does anyone understand why or how I could make it ?
Thank you

I think you may be looking for .cm-line in the editor (source mode and Live Preview). Have a look here to see if it seems similar: Can't get custom CSS to work - #15 by adrienneteicher

Live Preview with the adjustment:

Adjusting .cm-line will affect spacing in lists, code blocks, and callouts as well, so you may want to exclude those.

Adding a part to take care of Reading view (the top section), you could try something like this to see if it works:

.markdown-preview-view br {
    content: '';
    display: block;
    margin-block: 5px;
}

.markdown-source-view .cm-line:not(.HyperMD-list-line, .HyperMD-codeblock, .HyperMD-callout) {
    padding-block: 5px;
}

Live Preview before:

Screenshot 2024-01-20 at 9.21.10

Live Preview after:

Screenshot 2024-01-20 at 9.20.49

Great, it works and helped me a lot.
Thank you so much :slight_smile:

1 Like

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