I have this specific tag around 8 or 10 times in my code I want to edit the colour of the word in between the colour white but the double class system is not working for me the tag already has a nave-link class and then I added the navi class to edit it,I do not know to solve this problem one approach is to style those a million times manually I am pasting the code of index.html and style.css
PS: I almost forgot to mention I am using bootstrap for my project so this is the code in between the nav ie navigation bar
this is the html code
<li class="nav-item">
<a class="nav-link navi" href="index.html">
Home
</a>
</li>
and this is the css code
.navi
{
color:#fdfefe;
}
When using multiple classes the later ones override the earlier ones.
.first {
color:red;
}
.second {
color:green;
}
<p class="first second">yo</p>
This will result in a green text
I'd like to have separate colors for fa-search and text with this html using css?
<div class="logos1"><i class="fa fa-search"><span class="padding">logos</span></i></div>
Not sure if I understand your request - the title of your post indicates that you want the same colors for the icon and text - but the question requests different colors.
Fa icons are colored via the color css property so you can set a given color for them. Note that the FA icons are added as ::before pseudo elements - so can be styled directly or via inherited colors.
Also - although you can have content within the i that houses the icon - it is more common to treat that as a separate element and close the <i> before adding the other content in the span.
EDIT: in response to the comment - I have altered the code so that the a has the logos class - so that you can directly target this and not other a elements.
a.logos1 {
text-decoration: none;
color: blue;
}
a .fa {
color: red;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
<a href="http://4309.co.uk/logos/" class="logos1">
<i class="fa fa-search"></i>
<span class="padding">logos</span>
</a>
<a href="link">
<i class="icon is-ac-coloured fab fa-facebook-square fa-2x"></i>
</a>
a:has(> img), a:has(> i) {
text-decoration: none;
}
Why can I still see the underline on the image?
I'd like it to be removed if an anchor link wraps an image or an italic tag.
:has() is a CSS4 selector its a working draft: https://drafts.csswg.org/selectors-4/#relational, looking at https://caniuse.com/#search=%3Ahas there isnt great browser support. So that might be the reason you are seeing nothing its simply not being parsed.
Going to have to write this using JavaScript or alternatively attach a class to your anchors that are warping images and icons.
.remove-text-decoration {
text-decoration: none;
}
I've noticed that even at the same font size, there is not a standard width. How can I use these in front of a list of items so the words don't appear jagged?
Screenshot of issue:
This is the code:
<ul id="myTab">
<li class="active"><i class="icon-tasks"></i> Proposal</li>
<li><i class="icon-film"></i> Videos</li>
<li><i class="icon-paper-clip"></i> Assets</li>
<li><i class="icon-credit-card"></i> Payment</li>
<li><i class="icon-calendar empty"></i> History</li>
</ul>
Since 3.1.1, you could use the icon-fixed-width class instead of having to edit the CSS.
http://fortawesome.github.io/Font-Awesome/3.2.1/examples/#navigation
Since 4.0, you should use fa-fw:
4.x https://fontawesome.com/v4.7.0/examples/#fixed-width
5.x https://fontawesome.com/how-to-use/on-the-web/styling/fixed-width-icons
Thanks #kalessin for pointing out.
Are you sure that you haven't got another style defined that is doing this?
This is how your HTML looks placed into a file on a site I have using Font Awesome:
Notice how the icons and the text line up. This is your original image with lines added:
It looks like you have a style defined somewhere that is removing the Font Awesome styling.
You could also try adding in the original Font Awesome style (coming from font-awesome.css) to see if that solves it temporarily:
li [class^="icon-"], .nav li [class^="icon-"],
li [class*=" icon-"], .nav li [class*=" icon-"] {
display: inline-block;
width: 1.25em;
text-align: center;
}
For Fontawesome version above 4.X, use fa-fw class in the <i> tag.
Ref:- https://fontawesome.com/how-to-use/on-the-web/styling/fixed-width-icons
Its simple and easy to scale glyph or any icon using this css
> .fa { transform: scale(1.5,1); }
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?
<i class="icon-cog"></i> Edit profile
This worked for me:
.icon-cog {
color: black;
}
For versions of Font Awesome above 4.7.0, it looks this:
.fa-cog {
color: black;
}
HTML:
<i class="icon-cog blackiconcolor">
css :
.blackiconcolor {color:black;}
you can also add extra class to the button icon...
You can specify the color in the style attribute:
<i class="icon-cog" style="color:black"></i> Edit profile
Try this:
<i class="icon-cog text-red">
<i class="icon-cog text-blue">
<i class="icon-cog text-yellow">
To change the font awesome icons color for your entire project use this in your css
.fa {
color : red;
}
If you don't want to alter the CSS file, this is what works for me. In HTML, add style with color:
<i class="fa fa-cog" style="color:#fff;"></i>
Is there any possible way to change the color of a font-awesome icon to
black?
Yes, there is. See the snipped bellow
<!-- Assuming that you don't have, this needs to be in your HTML file (usually the header) -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Here is what you need to use -->
Edit Profile
Font awesome is supposed to be font not image, right?
Yes, it is a font. Therefore, you are able to scale it to any size without losing quality.
To hit only cog-icons in that kind of button, you can give the button a class, and set the color for the icon only when inside the button.
HTML:
<a class="my-nice-button" href="/users/edit">
<i class="icon-cog"></i>
Edit profile
</a>
CSS:
.my-nice-button>i { color: black; }
This will make any icon that is a direct descendant of your button black.
With reference to #ClarkeyBoy answer, below code works fine, if using latest version of Font-Awesome icons or if you using fa classes
.fa.icon-white {
color: white;
}
And, then add icon-white to existing class
For me the only thing that worked is inline css + overriding
<i class="fas fa-ellipsis-v fa-2x" style="color:red !important"></i>
just give and text style whatever you want like :D
HTML:
<a href="javascript:;" class="fa fa-trash" style="color:#d9534f;">
<span style="color:black;">Text Name</span>
</a>
.fa-search{
color:#fff;
}
you write that code in css and it would change the color to white or any color you want, you specify it
You can change the Font Awesome's icon color with the bootstrap class
use
text-color
example
text-white
Sometimes changing the colour in the external css file doesn't work. You can add inline css property in the icon tag and that will work.
For example
<i class="fa-solid fa-keyboard" style="color: grey;"></i>
just give it the style whatever you want like
style="color: white;font-size: 20px;"
You can change the color of a fontawesome icon by changing its foreground color using the css color property. The following are examples:
<i class="fa fa-cog" style="color:white">
This supports svgs also
<style>
.fa-cog{
color:white;
}
</style>
<style>
.parent svg, .parent i{
color:white
}
</style>
<div class="parent">
<i class="fa fa-cog" style="color:white">
</div>
Write this code in the same line, this change the icon color:
<li class="fa fa-id-card-o" style="color:white" aria-hidden="true">
Use color property to change the color of your target element as follow :
.icon-cog { // selector of your element
color: black;
}
Or in the newest version of font-awesome , you can choose among filled or not filled icons
If you want to change the color of a specific icon, you can use something like this:
.fa-stop {
color:red;
}
It might a little bit tricky to change the color of font-awesome icons. The simpler method is to add your own class name inside the font-awesome defined classes like this:
.
And target your custom_defined__class_name in your CSS to change the color to whatever you like.
Open the svg file in vs code or something
change the line
path fill="gray" to what ever color you want! in my case i change it to gray!
I added a style, then color of your choice and make sure to make it bold
HTML:
<i class="icon-cog blackiconcolor">
css :
.blackiconcolor {color:black;}
Using class will give you a free binding property which you can apply on any tag you require.