sodcalculator

10 Tech How-To

Obsidian CSS Snippets: How to Use Them

Guide 10-59850 · Updated · Step by step

To use CSS snippets in Obsidian, place a .css file in your vault’s .obsidian/snippets folder, then enable it in Settings → Appearance → CSS snippets. This lets you customize the look of your notes without installing a full community theme.

What Are CSS Snippets?

CSS snippets are small text files that contain custom styling rules for the Obsidian interface. They work exactly like the stylesheets used on websites, but they apply only to your local Obsidian app. You can change fonts, colors, spacing, hide elements, or restructure the layout to suit your workflow. Snippets are a middle ground between using a pre-made theme and writing your own full theme from scratch—they let you override specific parts of the interface while keeping the rest of the default look.

How to Create and Enable a Snippet

  1. Open Obsidian and go to Settings (gear icon in the bottom left).
  2. Scroll down to Appearance.
  3. At the bottom of the Appearance tab, find the CSS snippets section.
  4. Click the folder icon to open your vault’s snippet folder (it’s .obsidian/snippets). If the folder doesn’t exist, you can create it manually.
  5. Create a new text file, for example my-styles.css, and open it in any text editor.
  6. Write your CSS rules, save the file, then return to Obsidian.
  7. Click the refresh icon (circular arrow) next to CSS snippets, and your new snippet should appear in the list.
  8. Toggle the switch next to the snippet’s name to enable it. The changes apply immediately.

Anatomy of a Useful Snippet

A basic snippet looks like this:

/* Change the background color of the editor */
.markdown-source-view {
  background-color: #fdf6e3;
}

/* Make headings orange */
.markdown-preview-view h1,
.markdown-preview-view h2,
.markdown-preview-view h3 {
  color: #e67e22;
}

Obsidian uses a mix of standard HTML elements (like h1, p, blockquote) and its own CSS classes (like .markdown-preview-view). To find the right class names, you can use the developer tools: press Ctrl+Shift+I (Windows/Linux) or Cmd+Opt+I (Mac) while Obsidian is open, then inspect the element you want to style. This is the most reliable way to target exactly what you need.

Where to Find Ready-Made Snippets

You don’t have to write everything from scratch. The Obsidian community has shared many snippets on forums and GitHub. A quick search for “Obsidian CSS snippets” will turn up collections that hide the title bar, change the font of code blocks, add a subtle border to images, or make the sidebar narrower. When you download a snippet, just place the .css file in your snippets folder and enable it. Always check that the snippet is compatible with your Obsidian version—older snippets may break after major updates.

Common Problems and Fixes

  • Changes don’t apply: Make sure the snippet is enabled (toggle is on) and that you’ve refreshed the list after editing the file. Also check that the CSS selector matches the element—use the developer tools to verify.
  • Snippet works in reading view but not in live preview: Live preview uses different classes than the classic editor. You may need to target both, for example .markdown-source-view and .markdown-preview-view.
  • Changes apply to all notes but you want only one folder: You can use CSS to target a specific folder by adding a class to the note’s frontmatter (e.g., cssclasses: my-folder-style) and then writing rules like .my-folder-style h1 { ... }.
  • Snippet conflicts with a theme: If you’re using a community theme, your snippet may be overridden. Use more specific selectors or add !important to your rules (but use it sparingly).

Comparing Snippets to Themes

Themes are complete stylesheets that change the entire look of Obsidian. Snippets are small, targeted overrides. Themes are great if you want a cohesive design without any effort, but they can be heavy and may not suit your specific taste. Snippets give you fine-grained control—you can mix a theme with a few snippets to adjust just the parts you don’t like. The downside is that snippets require some CSS knowledge, and maintaining many snippets can become messy. A good practice is to keep one snippet per purpose (e.g., fonts.css, headings.css) so you can disable them independently.

Frequently Asked Questions

Do CSS snippets affect performance?

Generally no, if they are small and well-written. However, overly complex selectors or animations can slow down the interface, especially on large vaults. Keep snippets simple and avoid applying styles to every element.

Can I use CSS snippets on mobile?

Yes, Obsidian mobile also supports CSS snippets. The process is the same: place the .css file in the vault’s .obsidian/snippets folder and enable it in Appearance settings. Note that some desktop-only features (like hover preview) won’t exist on mobile, so those selectors won’t do anything.

Why is my snippet not showing up in the list?

Make sure the file has a .css extension and is inside the correct folder (.obsidian/snippets). If you just created the folder manually, restart Obsidian or click the refresh icon. Also check that the file is not named with a leading dot (like .hidden.css)—that may cause it to be ignored.

How do I undo a snippet’s changes?

Simply toggle off the snippet in Settings → Appearance, or delete the file from the snippets folder. Your notes themselves are never modified—snippets only change the display.

Can snippets be shared with others?

Yes, you can share a .css file. The recipient just places it in their own snippets folder and enables it. If the snippet relies on a specific theme or plugin, mention that in the documentation.

Is there a way to preview a snippet before enabling it?

Obsidian doesn’t have a built-in preview for snippets, but you can enable it and immediately see the changes. If you don’t like it, toggle it off. For more complex testing, you can use the developer tools to edit CSS live and then copy the final rules into your snippet file.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →