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
- AFTER it has been visited, and
- AS it is being hovered over
Where do pseudo–pseudo classes go, in the order?
Categories: CSS ![]()
Add Feedback (view all)
Leave feedback
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
Similar Entries
- Swap banner image with CSS and PHP (797 recent visits)
- CSS class, or HTML tag? (15 recent visits)
- CSS font-size dialogue! (123 recent visits)
- CSS print style sheet (12 recent visits)
- CSS adjacent sibling selectors and IE 6 (404 recent visits)
- CSS "classitis" for a printing issue (3 recent visits)
Stats
13 unique visits since August 2008
Recent Referrers (click)
- http://matthom.com/archive/200
- http://matthom.com/blog/view/s
- http://matthom.com/archive/200
- link declarations css
- hover
- css link declarations order
- css link declarations
- link declarations css
- link declarations in css
- hover
- http://matthom.com/archive/200
- http://matthom.com/blog/view/s
- http://matthom.com/archive/200
- link declarations css