You can use CSS class or id identifiers to change colors. An id would be used if that particular <a> tag is unique (i.e. you will not be using that color scheme elsewhere on the site). Class identifiers are used for repeating elements.
Let's test this.
First, in your HTML, add the following:
HTML Code:
<a href="#">Today's Headlines</a>
<a href="#" id="good">Good News</a>
<a href="#" class="goodnews">Steve Wins $1,000,000 Lottery</a>
<a href="#" class="goodnews">New School Opens in Timbuktu</a>
<a href="#" id="bad">Bad News</a>
<a href="#" id="badnews">Fire Breaks Out in Enchanted Forest</a>
<a href="#" id="badnews">Child Loses his Bike, Mother Says</a>
Notice the various class= and id= declerations.
Now to the CSS, let's add the following
Code:
a {
display:block;
padding:5px 10px;
}
a#good {
background:#50E923;
font-weight:bold;
color:white;
}
a#bad {
background:#ee0000;
font-weight:bold;
color:white;
}
a.goodnews {
color:#50E923;
}
a.badnews {
color:#ee0000;
}
You should see the relationship between the various CSS declerations and the anchors we used.
a is the default setting for all anchors. Unless these specific settings are redecleared in class/id style tags, they will still apply.
a#good refers to id="good".
a.goodnews refers to class="goodnews".
Hopefully that's clear. Let me know if there are any questions.
Bookmarks