i am using a definitive style for my tags. now there is one tag that i do not wish to appear that way. how do i do it?
A:
Give that one tag an ID, and then make a style for that specific ID. It will override the style you set for the "a" tags.
Richard Walters
2010-04-11 18:12:36
i have already tried that. does not help.
amit
2010-04-11 18:18:08
@amit please show some code.
Pekka
2010-04-11 18:31:09
A:
First, figure out the class or id of the element you want to change the style of using tools like firebug. Once you have found its class or id, search for it in the style sheet and modify the style as you like. If it still does not work, try appending the !important
to your style, for example:
.myelement
{
color: #ff0000 !important;
font-size: 14px !important;
}
The !important
will override any pre-defined styles.
Sarfraz
2010-04-11 18:25:00
If you are very specific in your rule (e.g. `a .myelement`) you won't even need `!important`. Avoid `!important` where you can, it makes maintenance of complex CSS style sheets a nightmare. Override styles by specificity instead.
Pekka
2010-04-11 18:32:34
!important does not work. i used it on font-weight and color CSS properties. no effect. as ~Pekka suggested I ended up using a specific attribution
amit
2010-04-11 19:20:42
@Pekka: agreed but without the questioner's code shown I could suggest only this.
Sarfraz
2010-04-11 20:42:10
A:
You can't always reliably "unstyle" an element. For some style properties setting the value to auto
, default
or none
will work:
<!doctype html>
<html lang="en">
<head>
<title>Test</title>
<style>
a { background: pink; }
a.normal { background: none; }
</style>
</head>
<body>
<p><a href="#">link1</a>
<p><a href="#" class="normal">link2</a>
<p><a href="#">link3</a>
</body>
</html>
But not for example color
. Replace background
in above example by color
. It won't work. You'll really need to force the color yourself, e.g. color: blue
.
BalusC
2010-04-11 19:10:40