Page 1 of 1

Inline CSS, hover property -- possible?

Posted: Tue Nov 01, 2005 7:01 am
by Chris Corbyn
Hey,

Anyone happen to know if I you can do this inline?

Code: Select all

<style type="text/css" media="screen">
a.foo { color: red; text-decoration: none; }
a.foo:hover { color: green; }
</style>

<a class="foo" href="somewhere_nice">Never call a link "Click Me!"</a>
Something like this but with that hover property also:

Code: Select all

<a style="color: red; text-decoration: none;" href="somewhere_nice">Never call a link "Click Me!"</a>

Thanks :)

Posted: Tue Nov 01, 2005 8:14 am
by feyd
use onmouseover ? :)

Posted: Tue Nov 01, 2005 8:22 am
by Chris Corbyn
feyd wrote:use onmouseover ? :)
Hmmm... I was hoping it would work with just CSS and no JS but it's only visuals so.... bah... OK :)

Thanks :D

Posted: Tue Nov 01, 2005 2:17 pm
by pickle
I've never been able to find a way to do it. While it will probably break validation, you should be able to put the <style></style> tags within the body of the page, so just before that link, declare the hover property (I'm assuming that there is some reason why you can't put the declaration in the head of the page).

Posted: Tue Nov 01, 2005 3:17 pm
by Chris Corbyn
pickle wrote:I've never been able to find a way to do it. While it will probably break validation, you should be able to put the <style></style> tags within the body of the page, so just before that link, declare the hover property (I'm assuming that there is some reason why you can't put the declaration in the head of the page).
It was dynamic content and simply applying the attributes inline was easier/quicker. I could have done it with <style> tags and CSS classes I guess :)

Note: I'm pretty sure there's nothing stopping you adding <style> tags inside the <body></body> in terms of SGML validation.