Prevent valign='middle' from being overridden by stylesheet declaration?
I have a table like this:
<table>
<tr><td valign='middle'><a href='#'>Lin开发者_如何学Ck</a></td><td><img src='img.png'></td></tr>
</table>
And a stylesheet like this:
a {
vertical-align: baseline;
}
td a {
vertical-align: default;
}
I'm trying to get my link to be veritcally aligned, but because of my initial vertical-align: baseline
declaration (which I cannot change) the valign
attribute is ignored. I'd like to fix this in the stylesheet under the td a
selector. How can I fix this?
(I am testing this in Chrome 12)
Remove valign="middle"
and then in the stylesheet do:
td a {
vertical-align: middle;
}
Since you were asking how to "erase" the declaration. You can't erase it but you can override it:
a {
vertical-align: middle;
}
would replace the previous declaration in your stylesheet.
Odd issue you’re having, as according to Sitepoint, the default value for vertical-align
is baseline
, so your rule a { vertical-align: baseline }
shouldn’t have any effect. Is there any other CSS applied to the link?
In modern browsers (like Chrome 12), you could try:
td[valign="middle"] {
vertical-align: middle;
}
精彩评论