JohnMax
JohnMax

Reputation: 269

unable to change link color in IE8

I have apply a classname "bSelect" to a Link element, it could apply background image but not converting the link into white?

.bSelect {background:url('../../img_assets/bs1.png') 0 0 no-repeat;background-position:center;color:#fff;}

Upvotes: 0

Views: 890

Answers (1)

Danny Tuppeny
Danny Tuppeny

Reputation: 42333

The most specific rule will always apply, so if you have the following somewhere:

a.bSelect { color: red; }

Then it will always take presidence over a less-specific rule, like:

.bSelect { color: white; }

Adding "!important" to the end of the rule forces it to be applied (though again, if you have multiple "!important"s, the most specific wins again).

It's usually a good idea to try and avoid "!important" and instead figure out why the rule isn't being applied. There ae built-in tools in most browsers to help you trace which CSS styles are being applied. However, "!important" works and is often easier than trying to rewrite CSS rules to make them work.

Upvotes: 1

Related Questions