开发者

Inline CSS, for Href styling

开发者 https://www.devze.com 2023-03-28 10:12 出处:网络
I don\'t believe it\'s a typical thing to see, but I\'m curious if this i开发者_如何学运维s a possible inline scenario.

I don't believe it's a typical thing to see, but I'm curious if this i开发者_如何学运维s a possible inline scenario.

I have a table with several rows. Some of those rows may or may not have hrefs. Can I specify link styles inside the or tags? Rather than inside the href tags?

<table>
 <tr style="color:#000;">
   <td></td>   
   <td></td>
   <td></td>
   <td></td>
 </tr>
</table>

Here's how I want to affect links only:

.a { text-decoration:underline;color:#EEE; }

I already placed a style in the <tr> tag, which affects regular text. Can I specify link styles inside there too? Or is that a limit that can only be done from within stylesheets or inside the tag itself?


Link colors are not inherited from their parent elements. You'll need to specify the color for the links specifically.


Firstly, let's get some terminology clear so we're all on the same page.

Elements such as the anchor tag <a> can be styled using CSS. Attributes, such as href give certain meaning to the tag they belong too. You cannot style attributes alone.

In order to change the style of all anchor tags (all links) in your site you can simply do:

a{
 /* my styles here */
}

As @ceejayoz pointed out above, link colours are not inherited from their parent and so you either need to style them individually inline <a style="color:#eee"> (which I sugest you avoid doing), or you style them from a stylesheet/css code block.

0

精彩评论

暂无评论...
验证码 换一张
取 消