Misleading CSS link declarations Feb24 '05

When declaring your link styles in CSS, it’s often misleading what order they should go, in the code.

General CSS theory states that your CSS link declarations should follow this order:

link, visited, hover, active

However, it’s natural tendency (at least for me) to put the hover pseudo–class BEFORE visited, or SECOND in line.

The reason being... When you physically SEE a link in the browser, the first thing you see is it’s link pseudo–class.

Then... you hover over the link, where you see it’s hover pseudo–class.

THEN... you click on the link, where you see it’s active pseudo–class.

Finally, when you return to the original page the link was on, you see the visited pseudo–class of the link.

So, the physical order seems to be: link, hover, active, visited.

However, this is not the case in CSS – for you shall be in for some small surprises if you interchange the order of these declarations.

Mentally designing

It all comes down to "mentally designing," meaning you have to picture your layout and styles in your head FIRST, and then add them to your document. And when I picture it, I picture it in the order it happens. It’s just natural tendency.

visited:hover

And I haven’t even mentioned visited:hover, which is how your link appears

  1. AFTER it has been visited, and
  2. AS it is being hovered over

Where do pseudo–pseudo classes go, in the order?

Categories: CSS

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Popular Pages

  1. Fast rounded corners in Photoshop (7423 recent visits)
  2. PHP – passing variables across pages (2558 recent visits)
  3. JavaScript set selected on load (2413 recent visits)
  4. Removing all child nodes from an element (1828 recent visits)
  5. Firefox 3 smart address bar: wildcard search (1755 recent visits)
  6. iPod songs out of order? (1314 recent visits)
  7. Britney - Everytime piano tab (1137 recent visits)
  8. MySQL LEFT JOIN syntax (884 recent visits)
  9. Firefox 3 smart address bar: wildcard search (722 recent visits)
  10. Date difference in MySQL (651 recent visits)

Similar Entries

Stats

3 unique visits since July 2008

Syndicate

Advertisements