Changing Monospace Font, Size, etc. in Source Mode

Hey!

I want to figure out how to change all instances of Monospace font in my vault using a .css snippet. I have a specific font I want to use but it’s significantly larger than the body/editor fonts I’m using so I’m trying to make it fit better. Thus far the .css snippet I’m using is as follows:

“.cm-s-obsidian .HyperMD-codeblock,
.cm-s-obsidian span.cm-inline-code,
.markdown-preview-view code,
.cm-hmd-frontmatter {
font-size: 10px;
letter-spacing: 1.75px;
}”

I was trying to cover all bases.

This changes the frontmatter/yaml/properties and codeblocks like dataview inquiries, BUT whenever I make a table, the Monoscpace remains unchanged. Is there a better way to change not just code but ALL instances of the Monospace font?

Thank you for your time and help.

I see the size and letter-spacing, but where are you setting the custom font-family itself that you want? In Obsidian’s Settings > Appearance > Monospace font section?

And just to double-check, you mean the font you see when editing the table in Source mode here, right?

You can try adding in .cm-s-obsidian .HyperMD-table-row to what you have already:

.cm-s-obsidian .HyperMD-codeblock,
.cm-s-obsidian span.cm-inline-code,
.markdown-preview-view code,
.cm-hmd-frontmatter,
.cm-s-obsidian .HyperMD-table-row {
    font-size: 10px;
    letter-spacing: 1.75px;
}

Bonus tip: when pasting code into the forum, it’s best to use code blocks for readability, ease of copying, and so on. e.g., typing:

```css
.theme-light {
    --inline-title-color: salmon;
}
```

displays as:

.theme-light {
    --inline-title-color: salmon;
}

Hey!!

That fixed it! And thank you for the codeblock tip! I was trying to use single backticks but that seemed to just mesh everything into a very weirdly spaced block; I’ll remember triple ticks going forward.

To answer the other questions, yes and yes! I did mean the tables in Source mode (default editing view) and I am using the default Settings > Appearance > Monospace font adjustments available directly in Obsidian’s UI; it seemed the safest route, plus if it works, don’t fix it? I was struggling with the size already.

Thank you so much for your help!

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