Hide # in tag using css or javascript

@Moonbase59 can you help me out with this?

REASON for wanting this: the # in front of a tag distracts me and hinders me in speedreading. Especially if there are multiple tags on a line.

Things I have tried

I have tried hiding the # character in a tag by css, but that’s not working. I hoped using .tag::first-letter: {display:none;} would work. It doesn’t, because CSS doesn’t seem to see # as a letter, somehow.

I also read on several CSS websites that this cannot be done unless you wrap that # in a span or something. Then you could set display to none. But that would mean a ridiculous amount of typing, every time I use a tag. Using some text expander would likely cause all my headings that also start with # to go haywire. Don’t need that.

What I’m trying to do

All the websites advise to use some Javascript to hide that first letter. So I found a really simple looking piece of javascript, but I cannot test it as I have no idea how to use javascript in Obsidian. I also don’t know if I would have to use that bit of javascript every time I use a tag. That would be as inconvenient as wrapping a span around the # every time.

The javascript that should do the trick: but ONLY in preview mode or at least that is what I think, because removing it entirely would kind of destroy the idea of having a tag altogether as Obsidian (I think, again) wouldn’t recognize it as a tag anymore. Just speculations though. I have no clue really.

const text = '#sometag'
const editedText = text.slice(1) //'sometag'

So what do you guys and gals who know javascript think?

  1. Can this be done, hiding the # in a tag? Either CSS or javascript?
  2. Can it be done using the above piece of javascript?
  3. if yes, how do I implement that?
  4. If no, is there an alternative to achieve this?


I tried the same, the “#” is very irritating in the context, but I failed. It would be very nice to hide that character, there is no real need for it.

There might be a solution in this thread:

1 Like

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