The odd bit

Once is an accident, twice is a coincidence, three times is an enemy action.

The odd bit - Once is an accident, twice is a coincidence, three times is an enemy action.

CSS: Love Hate

The slightly odd title is there for a reason. This post exists for a reason. I’ll explain both…

I’ve always struggled to remember the order in which hyperlink styles should be defined in a stylesheet. Hyperlink styles? Order? I’m talking about these (in alphabetical order):

  • :active
  • :hover
  • :link
  • :visited

They should be specified in the right order or things won’t work the way you’d expect them to. Here they are again but this time in the correct order:

  • :link
  • :visited
  • :hover
  • :active

I could go into details why this is the right order but I won’t :-) That’s not the purpose of this post.

The good news is that there’s a mnemonic to remember the order: LoVe HAte. For those not paying attention: mind the casing of the mnemonic!

So that’s the title of this post. But why? To keep me from googling each time I forget the order :P

Category: Uncategorized
Tag:
  • Lars Gunther says:

    A quick note. Don’t forget keyboard users.

    LoVe Focus HAte…

    8 March 2012 at 14:28
  • Christopher Schramm says:

    I’m fairly sure, :link and :visited are interchangeable. So, you could use e. g. VaLid or VioLent instead of LoVe. ;)

    8 March 2012 at 14:33

Your email address will not be published. Required fields are marked *

*