Inline CSS, hover property -- possible?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Inline CSS, hover property -- possible?

Post 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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use onmouseover ? :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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).
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Post Reply