Can I change the color of Font Awesome's icon color?

652,758

Solution 1

This worked for me:

.icon-cog {
  color: black;
}

For versions of Font Awesome above 4.7.0, it looks this:

.fa-cog {
  color: black;
}

Solution 2

HTML:

    <i class="icon-cog blackiconcolor">

css :

    .blackiconcolor {color:black;}

you can also add extra class to the button icon...

Solution 3

You can specify the color in the style attribute:

<a href="/users/edit"><i class="icon-cog" style="color:black"></i> Edit profile</a>

Solution 4

To change the font awesome icons color for your entire project use this in your css

.fa {
  color : red;
}

Solution 5

Try this:

<i class="icon-cog text-red">
<i class="icon-cog text-blue">
<i class="icon-cog text-yellow">
Share:
652,758
HUSTEN
Author by

HUSTEN

Updated on June 02, 2021

Comments

  • HUSTEN
    HUSTEN almost 3 years

    I have to wrap my icon within an <a> tag for some reason.
    Is there any possible way to change the color of a font-awesome icon to black?
    or is it impossible as long as it wrapped within an <a> tag? Font awesome is supposed to be font not image, right?

    enter image description here

    <a href="/users/edit"><i class="icon-cog"></i> Edit profile</a>
    
  • HUSTEN
    HUSTEN over 11 years
    @Evans Thanks but the problem is I sometime put <i class="icon-cog icon-white"> on the table cell which is black colored. Your css forced to change it into black also:(
  • Evan Hahn
    Evan Hahn over 11 years
    You can add the following: .icon-cog.icon-white { color: white; }
  • Adrian Schmidt
    Adrian Schmidt over 10 years
    -1 Firstly, this is wrong, because it will change the color of the text also, not just the color of the icon, as requested. Secondly, using inline css should not be promoted.
  • Adrian Schmidt
    Adrian Schmidt over 10 years
    -1 Font Awesome icons are text, hence the name. They should be colored using css like any other text, not using vendor-specific tricks. Also, since they are text, they are already black-and-white (or mono-color).
  • ameya rote
    ameya rote over 10 years
    @AdrianSchmidt Above stated answer is for converting an image to black, I didn't mean to change the font color with this, I hope you are getting me ..
  • Adrian Schmidt
    Adrian Schmidt over 10 years
    I understand. The answer is still incorrect in regard to the question though. Font Awesome icons are not images, they are text.
  • ClarkeyBoy
    ClarkeyBoy over 9 years
    Just came across this - I found that adding a class of 'fa' to all icons and then putting .fa {color: green;} did the trick. You can then do .fa.icon-white {color: white;} to get the same effect as you want above.
  • vamsikrishnamannem
    vamsikrishnamannem about 9 years
    Is it possible to change background-color
  • Evan Hahn
    Evan Hahn about 9 years
    @vamsikrishnamannem Yup. You can add background-color: #112233 to the CSS. Check out this code for an example.
  • dandrews
    dandrews about 8 years
    Where does the question say "just the color of the icon" and not the color of the text?
  • Adrian Schmidt
    Adrian Schmidt about 8 years
    I think that's rather obviously implied by the way the question is phrased. And it seems you would agree, since you updated your answer :)
  • eemrah
    eemrah about 6 years
    I wanna give a small hint for Bootstrap.<i> tag with using text-primary class, override the color of icon as blue. so its good to be aware of it.
  • DavidHyogo
    DavidHyogo over 5 years
    This is nice but changes all the icons in my project. I created classes like .fa-black {color: #000;}. I then added the fa-black classes to the icons where I wanted a different colour.
  • DavidHyogo
    DavidHyogo over 5 years
    This is a nice, neat solution. I prefer to name classes with an fa prefix like fa-black or fa-blue just to make it clear I'm applying them to font awesome icons.
  • colidyre
    colidyre over 4 years
    And where does text-red, text-blue or text-yellow come from?
  • Rahul Tathod
    Rahul Tathod about 4 years
    it come from bootstrap classes
  • stanlee
    stanlee over 3 years
    you can also use text-danger instead of text-red, text-warning instead of text-yellow, text-success instead of text-green etc. depends on what you want.
  • mr.loop
    mr.loop almost 3 years
    @AdrianSchmidt isn't the color style inside the i tag and text outside the i tag
  • Adrian Schmidt
    Adrian Schmidt almost 3 years
    @mr.loop Yes, the answer has been edited since I posted my comment.
  • mr.loop
    mr.loop almost 3 years
    @AdrianSchmidt ok. didn't noticed