Connecting Tech Pros Worldwide Forums | Help | Site Map

css hover inside html tags

Newbie
 
Join Date: Dec 2008
Posts: 6
#1: Jan 2 '09
Hi, i have a little problem. I can't make it work:
Expand|Select|Wrap|Line Numbers
  1. <a href="blabla.php" style="hover:color:red;">blablabla</a>
How to type this hover property inside html tag correctly?
Yes I know how it works in stylesheets but in this case I must use it without stylesheets.

Thanks in advance.

numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,572
#2: Jan 2 '09

re: css hover inside html tags


Quote:

Originally Posted by rotorio View Post

Hi, i have a little problem. I can't make it work:

Expand|Select|Wrap|Line Numbers
  1. <a href="blabla.php" style="hover:color:red;">blablabla</a>
How to type this hover property inside html tag correctly?
Yes I know how it works in stylesheets but in this case I must use it without stylesheets.

Thanks in advance.

I am not sure if you can actually do it inline like that, but you could do one of two things:

1. Add your style definition in the head element of the html document.
2. Use the "onmouseover" attribute to set the color.

If someone knows if it can be done inline, great, personally, I never put style inline, it does not belong there.

If you can change the HTML file, why can't you specify an external style sheet and do it there? Just wondering.

Regards,

Jeff
Newbie
 
Join Date: Dec 2008
Posts: 6
#3: Jan 2 '09

re: css hover inside html tags


It works with all the other css styles. I just need it:)

An example of random css styles inside html tag, try it. It works.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <p style="color: red; font-weight: bold; margin-left: 50px;">Some words</p>
  4. </body>
  5. </html>
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,572
#4: Jan 2 '09

re: css hover inside html tags


Quote:

Originally Posted by rotorio View Post

It works with all the other css styles. I just need it:)

An example of random css styles inside html tag, try it. It works.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <p style="color: red; font-weight: bold; margin-left: 50px;">Some words</p>
  4. </body>
  5. </html>

I know how to do style's inside of the HTML element, they are called inline styles. But, since the hover is typically a class of the element itself (I think class is the right term), I don't see how you could define it inline.

Again, is there any issue with defining it within the head element above? That would be the place to define a hover if you ask me.

Regards,

Jeff
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,660
#5: Jan 2 '09

re: css hover inside html tags


Quote:

Originally Posted by numberwhun View Post

But, since the hover is typically a class of the element itself (I think class is the right term)

note: it's called pseudo-class.
Reply