Different color for certain type of tags?

Hi,

I would like to change the appearence of a certein typ of tags: all (and only) tags with numbers (i. e. “#Author/Book/125”) in it should appear in (for exemple) red color.

I do not know, if it is possible via custom-css (or otherwise). If so, could someone please help me?

Thanks in advance!

Hi,
try this:

Thank you for replying!

  1. For some reason I cant find the plugin via obsidian

  2. It seems, automation in “colorful Tag” is not possible, i.e. format all tags that contain numbers.

  3. The plugin “Colored Tags” sadly does not what I want, also.

I could be mistaken but I think that’s not possible with CSS (or at least you would have to specify each and every tag you wanted it to apply to).

Thank you for replying!
Too bad…

It’s possible to do this to some extent with CSS, but it requiring the use of partial matching against the related HTML components.

For example, the tag #Author/Book/125 in live-preview has a span class of cm-tag-AuthorBook125, but in reading mode it’s a div class of tag-AuthorBook/125.

The HTML of this tag in the various modes are:

<!-- live-preview -->
<div class="cm-active cm-line">
  <span class="cm-formatting cm-formatting-hashtag cm-hashtag cm-hashtag-begin cm-meta cm-tag-AuthorBook125">#</span>
  <span class="cm-hashtag cm-hashtag-end cm-meta cm-tag-AuthorBook125">Author/Book/125</span>
</div>
<!-- reading -->
<div class="tag-AuthorBook/125 el-p" data-tag-name="p">
  <p>
    <a href="#Author/Book/125" class="tag" target="_blank" rel="noopener">#Author/Book/125</a>
  </p>
</div>

And you should be able to do stuff like:

[class*="Author"] {
  background: blue;
}

Which would match against any class containing Author somewhere. Selectors exists to match against start, end, white space separated stuff, and many more. See the link below for a full list of the various attribute selectors.

Do also note, that you might need to qualify the selector with more stuff to make it kick into action, as there might be other stuff dictating how to present a tag.

To match “tags with numbers”, tho…that’s at least 125 matches going by the example. Altho depending on the expected structure maybe you just need 10 matches (1 for each digit) surrounded by asterisks.

Or if the numbers are always nested as in the original example, and there is a limited set of tags that have numbers nested under them (as looks likely), and they only have numbers nested under them, I guess you could match against those tags each followed by a slash and an asterisk.