Niveditha
Niveditha

Reputation: 115

Is there any way to get colored html entities...?

Here I want html entities in colors. As the default color is black, I want them to be in specific color without css styling. Is that possible....

    .error_number {
      color: #F00;
    }
<span class="error_number">&#10004;</span>

Thanks in advance..

Upvotes: 8

Views: 10425

Answers (4)

pukkaTaT
pukkaTaT

Reputation: 11

Only way is to use css "filter" property.

// this converts black to green
     filter: invert(26%) sepia(76%) saturate(1788%) hue-rotate(95deg) brightness(92%) contrast(101%);

Here's a codepen I found to calculate filter for target colour.

https://codepen.io/sosuke/pen/Pjoqqp

Upvotes: 1

Quentin
Quentin

Reputation: 943108

No. HTML entities represent characters. Characters (except for emoji) do not have inherent colour.

Upvotes: 16

Dingo
Dingo

Reputation: 94

Use the in-line style option:

<span class="error_number" style="color:f00;">&#10004;</span>

CSS can easily be implemented inline with the style element. Though, it isn't recommended for larger jobs.

Upvotes: 0

itzzkolt
itzzkolt

Reputation: 25

Try this: This should work.

<span style="color:F00;" class="error_number">&#10004;</span>

Since you don't want to change the color in the style tags.

Upvotes: 0

Related Questions