I want to style the anchor links in my gridview header with css. My style for the classes th works but the style for th a does not apply to it. It is overwritten by the containing divs a style. Also if I do th a or th a:hover without a preceding class it does not effect the hyperlinks in my th. I have tested this in both IE and Firefox. This is the gridview portion of my css:
.gridview
{
border-color: #9BBE00;
border-width: thin;
border-style: solid;
width: 700px;
}
.gridview th
{
background-color: #F4A80A;
color: White;
font-weight: bold;
}
.gridview th a
{
font-weight: bold;
color:Red;
}
.gridview th a:hover
{
font-weight: bold;
color:Red;
}
.gridview td
{
text-align:center;
}
This is probably a specificity issue. CSS rules are weighted not only by their source and order, but according to a formula:
Therefore you might have something like this:
overriding your style:
You can solve this by either making your style more specific:
or using the hackier
!importantapproach:To be technically correct, I should mention that this is not really straight addition of points if any position reaches 10. For example, if for some strange reason you had a selector with 12 classes, the specificity weight might be:
That is, don’t carry the one. The above is less specific than:
Finally, I assume you realize your
:hoverstyle is the same as your plain link style.