Changing colour in Markdown <mark> tag

Issue

I currently discovered the markdown element, which lets me mark some text

<mark>Marked text</mark>

This results in this very nice looking pdf-text:

enter image description here

But how do I change the colour from it’s default yellow to another colour?

Solution

i would suggest something like this (using inline css). Note that i used !important because in some browsers it may be necessary to force the process.

<mark style="background: #00ced1!important">Marked text</mark>

alternatively, something like this (using external css).

mark {background: red!important}
<mark>Marked text</mark>

in this case the property is applied to all the mark tags in the webpage.
While this method works and is absolutely legitimate, it would be better, and more conventional, to use a css property like this:

<p>this is a pretty paragraph with some <span style="background: blue">marked text</span></p>

hope this helped 🙂

Answered By – Giuppox

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published