Using Hyperlinks and CSS in Your Website

A class is the blueprint from which individual objectsrules in the CSS so they work together. The way
are created. In Java, a class is used to show a set ofthat it is designed to work in CSS, each selector has
like items.specificity. So just like anything else in the cascade, if
Here is an example of a hyper link going to a sitethere are two selectors that are both applied to one
using a class: Elite Web Strategies a:link { color:element, the one with the higher specificity is applied.
#000000; background-color: #ffffff } a:visited { color:If you put them in the wrong order, you could end
#0000ff; background-color: #ffffff } a:hover { color:up with a page that isn't showing your style rules as
#0000ff; background-color: #ffffff } a:active { color:you intended them.
#ff0000; background-color: #ffffff } So what is eachThe only two that you can change the order on are
part used for?the a:link and a:visited (primarily because a link is only
* "a:link" will specify what the hyperlink looks like oneither or, never both). You can change many things
the page. * "a:visited" will specify what the hyperlinkwith links, but always keep in mind that specificity so
looks like once it has been visited (clicked on). *that they show properly on your page.
"a:hover" shows what the hyperlink will look like whenHere is an example of a potential problem and how it
hovered and * "a:active" specifies what the active linkis corrected.
will look like.Problem Ordera:link { color: #000000;
In the above example you'll also notice both color andbackground-color: #ffffff } a:visited { color: #0000ff;
background colors are designated. Color indicates thebackground-color: #ffffff } a:active { color: #ff0000;
actual color of the font, followed by the hex codebackground-color: #ffffff } a:hover { color: #0000ff;
for the color you want. The background color is thebackground-color: #ffffff }
color behind the text itself, followed by the hex codeIf you use the above CSS, all of it will work except
for that color.the active rules. Those will not show. This is because
It's important that these hyperlinks are written in thethe active has to come after the hover to follow the
proper order which is why they are put in a classLVHA format. If the active is placed before the
such as above.hover, it breaks that part of the class.
CSS Link Specificity - How to Put Your Links in OrderSimply swapping the places of the active and hover
There is an acronym to help you remember thewill fix the order of the cascade and allow it to all
proper order to place your links in. You might think ofwork.
something to help you remember it easier but someCorrect Ordera:link { color: #000000;
people simply remember LVHA. This simple acronym,background-color: #ffffff } a:visited { color: #0000ff;
LVHA will help you get your hyperlinks in the rightbackground-color: #ffffff } a:hover { color: #0000ff;
order every time.background-color: #ffffff } a:active { color: #ff0000;
LVHA stands for:background-color: #ffffff }
1. a:link 2. a:visited 3. a:hover 4. a:activeFollowing the LVHA rules will help you keep your CSS
LVHA is the order you should designate your linkhyperlinks in the right order to comply with W3C.