CSS Link Specificity - How to Put Your Links in Order

Love Hate is how I taught myself to remember theuse the above CSS, all of it will work Except the
order. The acronym for the order (LVHA) just wasn'tactive rules. Those will not show. Why? As I said
terribly easy to remember on its own. It didn't spellearlier, visited and link do not have to be in a specific
anything, or really give a sensical meaning to me. Butorder (though ideally they should be in the LVHA
Love Hate works. So what is LVHA?1. a:linkorder to keep consistency), but the active has to
2. a:visitedcome after the hover. Due to the active being placed
3. a:hoverbefore the hover, that part breaks. Simply swapping
4. a:activeLVHA is the order you should designatethe places of the active and hover (within the CSS)
your link rules in the CSS so they work together. Thewill fix the order of the cascade and allow it to all
way that it is designed to work in CSS, each selectorwork.Correct Ordera:link { background-color:white;
has a specificity. So, just like anything else in thecolor: blue }
cascade, if there are two selectors that are botha:hover { background-color: black; color: white;}
applied to one element, the one with the highera:active { background-color: blue; color: white;}
specificity is applied. Put them in the wrong order,a:visited {background-color:white; color:green;}In
and you could end up with a page that isn't showingCSS2 we were able to combine our pseudo-classes,
your style rules as you intended them.The only twoso that we could customize it further. An example
that you can change the order on are the a:link andbeing that you could have a regular hover for a link,
a:visited (primarily because a link is only either or,but make it different for a visited link:a:visited:hover
never both). Now, keep in mind that you can change{background-color: green; color: black;}Overall, as long
a multidute of things with links, but always keep inas you remember Love Hate, specificity for making
mind that specificity. To give an example of alinks isn't terribly complicated.Nicole Hernandez is a
potential problem, look at the following CSS:Problemweb developer with a specialty in web standards and
Ordera:link { background-color:white; color: blue }accessibility. She is the owner of Website Style and
a:active { background-color: blue; color: white;}publishes technical articles on her blog called Beyond
a:hover { background-color: black; color: white;}Caffeine.
a:visited {background-color:white; color:green;}If you