Don’t overlook the specificity rule in CSS. Try to make the global site styles as unspecific as possible. Then it makes it easier to override those stiles in specific situation. Try to use classes as selectors instead of ID’s because ID’s are more specific than classes since ID’s have to be unique on a page and classes don’t.
If for some reason the !important;
doesn’t work, you’re probably dealing with another !important;
value inside one of the stylesheets linked or embedded in the generated page. The !important;
value should only be used for troubleshooting and not be left in the stylesheet. Unfortunately many plugins have their stylesheets filled with !important;
‘s to override the themes’ stylesheet.
I can only recommend you look at the source code of the generated page and find all the styles linked to or embedded in it. Find all the !important; instances and check whether removing them solves the problem. The Developers toolbar for Firefox can be a great tool to do this with.
@ivovic: You are right, there are some things you can’t do with CSS. But this problem is not one of these things. It is very simple to have 4 links with images in them on the same page and style each of them individually with a different style, color or thickness of border or no border at all. It’s just a matter of being specific. In any case asking the W3C to change the (X)HTML to solve a CSS problem doesn’t make sense.
@spscheele: have you tried adding the #content in front of your selector? this makes it more specific. (just like jonimueller did with the class selector sociable
) If the XHTML code you’re trying to target looks like this:
<body>
<div id="content">
<p>text... <a href="#" class="link"><img src="image.jpg" /></a></p>
</div>
</body>
You can specify the CSS for the image like this:
body div#content p a.link img {
border: none;
text-decoration: none;
}
Chances are that there aren’t any other CSS rules as specific as that in any of the stylesheets of any plugin. But only do this as a quick fix. try to find the conflicting CSS and either get rid of it or make it more or less specific to target what it was written for.
@jonimueller: .sociable img { border: 0; } is targeted at the images while the border is styled by the link. The border, technically speaking, isn’t around the image, it’s around the link.
@all: Patrick Griffiths explains the whole CSS specificity deal on his HTML Dog website. Here’s the direct link: https://www.htmldog.com/guides/cssadvanced/specificity/.
The HTML Dog website is a great resource when you want to learn how to design websites the “right” way instead of the “looks alright” way. He offers free (X)HTML and CSS tutorials online on 3 different levels and explains it really well. If you know what he explains in those tutorials, this will all seem like kid stuff.