Calling a CSS class from a template

What I’m trying to do

Hello, I have a beginner question about using CSS in templates. I want to use a CSS class in a template. Unfortunately it does not work at all. The CSS-snippet (red-yellow-h1.css) is in the folder .obsidian/snippets. It is recognized by Obsidian and is activated. After inserting the template into a new note, the current date is displayed as H1 heading, but not in the desired formatting.

Things I have tried

The CSS snippet is:

.markdown-preview-view.red-yellow-h1 {
h1 {
color: red;
background-color: yellow;
}
}

The Template is:


cssclass: red-yellow-h1

Heute: {{date: YYYY-MM-DD dd}}

What am I doing wrong? Thanks for your help.

.red-yellow-h1 h1{
  color: red;
  background-color: yellow;
}

:blush:

1 Like

Great, now it works. Thanks for your help

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