Forum Moderators: not2easy

Message Too Old, No Replies

Need help putting a:hover within body section

hover

         

Carcajou

4:09 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



Hi there

I help run a charity website and its on the bt community server, meaning when we code the pages we don't have access to the header section of the HTML. We can put it in and they just strip it out.

I am trying to put in place a:hover commands that change the background and font colour when someone hovers on a link, but without being able to specify this in <style> in the header, whatever I try is not working

I can use text-decoration to alter the appearance of the link when not in use, but its a one-game hammer.

Any help greatly appreciated

Thanks

Carcajou

4:26 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



The specified DOCTYPE is XHTML transitional, and there seems to be some inbuilt editor within the site software as it auto-rearranges the order of some coding features upon saving the pages. It would thus seem to have an element of self-validation.

SuzyUK

4:38 pm on Jun 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Carcajou and Welcome to WebmasterWorld!

have you tried putting the style declaration inside the body element?

<body>
<style type="text/css" media="screen">
a {color: red;}
a:hover {color: #fff; background: #000;}
</style>
<p>this is a paragraph <a href="#">with a link</a></p>
</body>

it's considered good practice to put in the <head> but as far as I know it's not completely necessary and the above works in test too, unless the "self validation" strips that out too?

Carcajou

4:50 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



Thank you

That works - but in order to make it work I had to strip out the additional code I had inserted into the <a href...> tag to make the link black. For some reason the site allows me to choose the hover colours with your code (white on blue suits our colour scheme) but I need to specify the links appear black some way to remove the ugly blue/purple link effect. Tried your a {color:black;} and also tried a:link {color:black;} but neither seem to work

Carcajou

4:54 pm on Jun 5, 2009 (gmt 0)

10+ Year Member



Ah...a little odd but it just started working :) Possibly it was the absence of the a:visited that was upsetting it somehow. Put that in, as well as a:active and the links now appear in black as required.

Thank you very much !