You never answered my question on whether you want this to apply globally or just to some of the headers, but here is another thread which allows you to use just markdown for your headers and then align them using CSS:
Bonus tip: How to add a custom CSS snippet
- Goto Settings > Appearance and scroll down to “CSS snippets” section, and hit the folder icon on the far right. This opens up a file explorer window, in the folder
vault/.obsidian/snippets
, which is were you want to save your css snippet - In this new window create a file, like
myCss.css
, where you copy the CSS into. Make sure this actually is a text file, and that the name ends in.css
- Back in Obsidian, you should now see your
myCss
in the list of CSS snippets. If not, hit the refresh button - Final step is to click the enable button to the right of your file, and now your new CSS should be in effect
- If you later on make changes in the CSS snippet file, the effect should be immediate. If not, try disabling and re-enabling the snippet, or in some strange cases, you would need to reload Obsidian. In 99% of the cases, the changes are immediate, though.