Jump to content

Pseudo classes


pmdesign

Recommended Posts

Hi,All you know what is a pseudo class:<style type="text/css">a:link {color: #FF0000}a:visited {color: #00FF00}a:hover {color: #FF00FF}a:active {color: #0000FF}</style>But can i use it for my own class like this:<style type="text/css">.myclass{bgcolor: #FF0000}.myclass:link {color: #FF0000}.myclass:visited {color: #00FF00}.myclass:hover {color: #FF00FF}.myclass:active {color: #0000FF}</style>or if it's not right is there any possibility to use a pseudo class for non standart classes?

Link to comment
Share on other sites

It is possible only if the class refers to a link. Or should I say "if you are aiming for maximum compatability". Firefox and Opera understand :hover (and other pseudo classes on that matter) everwhere in a document. IE6 however only understands it when it's on a link. Otherwise, it doesn't do anything about it.

Link to comment
Share on other sites

It is possible only if the class refers to a link. Or should I say "if you are aiming for maximum compatability". Firefox and Opera understand :hover (and other pseudo classes on that matter) everwhere in a document. IE6 however only understands it when it's on a link. Otherwise, it doesn't do anything about it.

Yes.
.myclass:link

and

a.myclass:link

are both valid and are both working properly in all browsers. I'm not sure for :link though. I would reccomend that you don't use it. Typing only

a.myclass

or

.mylass

Works the same way and I'm completely sure there aren't problems with it.What aspnetguy is suggesting means a link(<a>) inside any element with a class .myclass. It's not euivalent to the ones above, but it's still a good trick to know.

Link to comment
Share on other sites

Yes.
.myclass:link

and

a.myclass:link

are both valid and are both working properly in all browsers. I'm not sure for :link though. I would reccomend that you don't use it. Typing only

a.myclass

or

.mylass

Works the same way and I'm completely sure there aren't problems with it.What aspnetguy is suggesting means a link(<a>) inside any element with a class .myclass. It's not euivalent to the ones above, but it's still a good trick to know.

good to know thanks
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...