问题
I am generating a html file with many different links and they (by default) all show up the regular blue color. Is there anyway i can make certain links different colors. note that this html is getting pushed into outlook as an email so i can't have separate css files.
回答1:
You can put your css in the <head/> of the <html>. Style your links with the color(s) you want. If you need more than one type of link, use classes. e.g.
a { color: #abcde1}
a.visited, a.hover {color: #1abcde;}
a.special {color:#123456;}
回答2:
use a css style for the anchor inline:
<a href="foo" style="color:orange"....
回答3:
There are a couple different ways. CSS can appear in your head tag, so it doesn't have to be a separate style sheet.
One is to use the style attribute:
<a style="color:blue;">...</a>
Another is to use css classes:
<style>
.navLink { color: blue; }
</style>
<a class="navLink">...</a>
There are lots of options. See http://www.echoecho.com/csslinks.htm
回答4:
You can use classes for your styles:
your CSS file:
.redlinks a
{
color: #FF0000;
}
.greenlinks a
{
color: #00FF00;
}
your HTML file:
<div class="redlinks"><a href="#">my link</a></div>
回答5:
you could use internal style sheet or inline styles assuming the email client doesn't ignore them. of course by messing with link colours you run the risk of users not realising that you have links at all, so be careful.
回答6:
This is example use of different colours for links:
<style type="text/css">
a.yellowLink { color:#ff0; }
a.greenLink { color:#0f0; }
a.redBlueLink { color:#f00; }
a.redBlueLink:hover { color:#00f; }
</style>
<a href="http://www.google.com/" class="yellowLink">I’m yellow</a>
<a href="http://www.google.com/" class="greenLink">I’m green</a>
<a href="http://www.google.com/" class="redBlueLink">I’m red and blue on hover</a>
来源:https://stackoverflow.com/questions/1743355/how-can-i-make-different-html-links-different-colors