CSS to target specific sections in preview mode

Recent changes in Obsidian have made CSS targeting a specific section unreliable (.markdown-preview-section). In my use case, I was hiding the first section, which is my custom frontmatter (I do not use Obsidian’s new built-in frontmatter formatting because there are links and tags in my frontmatter).

Now, there is no CSS to target the first section because Obsidian removes sections from preview mode that aren’t in the viewport.

My only idea would be to output a section number as html attribute -> section-number="1".

Another option could be to output some number of characters from the section content.

1 Like