Webmasters Heaven, Free submission, Free Promotion, Free Tools
Backword Forward Home add this page to favoirates send this page to a friend print this page icons articles Webmaster Tools Web Site Submit
sitemap
Free Icons Free Articels Free Tools Website submission

Articles Category  ]

Google
 
Advertising
Affiliates
Blogs
CGI
CSS
DHTML
Domain Names
ECommerce
Email
HTML
Internet
Javascript
Link Popularity
Marketing
MLM
Newsletters
Promotion
RSS
Search Engines
Site Security
Traffic Analysis
Web Hosting
Web Design
Webmasters


articles -> css
Article Title Author
Tables vs CSS - Which is better? Mike
CSS; Weight loss for your code Sasch Mayer
HasLayout concept explained - Learn how to exploit IE's layout" Lighezan Alexandru
How to make backgrounds for myspace? Brett Hull
Creating Pretty Buttons Scott Alexander
Fluidity and Text Sizing Nicole Hernandez
What is CSS? Devendra Jaiswal
Your New Website is Inside Drew Stauffer
Equal Heights Three Column Layout With CSS Rizky
CSS Design for change Dean Cruddace
How To Style Your Text With CSS  Hilco van der Meer
Cascading Stylesheets Advantages: 5 Reasons To Use CSS Hilco van der Meer
Creating Tableless Sites - Why and Some Basics Nicole Hernandez
CSS Cursors - How To Use Them Nicole Hernandez
How to create a Myspace layout? Anthony Stillmann
CSS Link Specificity Nicole Hernandez
The Concept Behind CSS Jose Valdez
The 30 minute CSS tutorial. Shabda Raaj
CSS or Tables? Shabda Raaj
Using CSS with Tables Stephen Cope
Cross Browser Compatibility Warren Baker
The Power of CSS Cliff Ritter
Cascading Stylesheets: 5 Reasons To Use CSS Hilco van der Meer
CSS Browser Detection - The complete guide Afonso Ferreira Gomes
CSS in Flash the return of crisp and legible fonts David Collado
Font Organizers Review, Part I David D. Deprice
7 Reasons Why Using CSS is a Must Michael Turner
SEO Benefits Of CSS Steve Chittenden
Starting Cascading Style Sheets stephen cope
Teach yourself CSS the easy way Erich Bihlman
CSS Print Media Tutorial Karl Regis
Using CCS to Eliminate Tables Sanjay Johari
CSS - Maximum benefits Zoran Makrevski
CSS: The Basics - ID's and Classes ... Correct Eric McArdle
CSS: The Basics - ID's and Classes Eric McArdle
Introduction To Cascading Style Sheets Mitchell Harper

CSS Link Specificity   by Nicole Hernandez


Love Hate is how I taught myself to remember the order. The acronym for the order (LVHA) just wasn't terribly easy to remember on its own. It didn't spell anything, or really give a sensical meaning to me. But Love Hate works. So what is LVHA?

1. a:link
2. a:visited
3. a:hover
4. a:active

LVHA is the order you should designate your link rules in the CSS so they work together. The way that it is designed to work in CSS, each selector has a specificity. So, just like anything else in the cascade, if there are two selectors that are both applied to one element, the one with the higher specificity is applied. Put them in the wrong order, and you could end up with a page that isn't showing your style rules as you intended them.

The only two that you can change the order on are the a:link and a:visited (primarily because a link is only either or, never both). Now, keep in mind that you can change a multidute of things with links, but always keep in mind that specificity. To give an example of a potential problem, look at the following CSS:

Problem Order

a:link { background-color:white; color: blue }
a:active { background-color: blue; color: white;}
a:hover { background-color: black; color: white;}
a:visited {background-color:white; color:green;}

If you use the above CSS, all of it will work Except the active rules. Those will not show. Why? As I said earlier, visited and link do not have to be in a specific order (though ideally they should be in the LVHA order to keep consistency), but the active has to come after the hover. Due to the active being placed before the hover, that part breaks. Simply swapping the places of the active and hover (within the CSS) will fix the order of the cascade and allow it to all work.

Correct Order

a:link { background-color:white; color: blue }
a:hover { background-color: black; color: white;}
a:active { background-color: blue; color: white;}
a:visited {background-color:white; color:green;}

In CSS2 we were able to combine our pseudo-classes, so that we could customize it further. An example being that you could have a regular hover for a link, but make it different for a visited link:

a:visited:hover {background-color: green; color: black;}

Overall, as long as you remember Love Hate, specificity for making links isn't terribly complicated.

About the Author

Nicole Hernandez is a web developer with a specialty in web standards and accessibility. She is the owner of Website Style and publishes technical articles on her blog called Beyond Caffeine.


[Advertisement ]