Forum Moderators: not2easy

Message Too Old, No Replies

A:Hover

         

adamnichols45

9:39 pm on Apr 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My code is as follows

<tr><td><a href="aa.php" class="">
<div class="tsblue">aaaa</div>
<div class="black2">aaaa</div>
<div class="purple">aaaaa</div></a>
</td></tr>

But the a:hover is not making the above text hover red when i hover over the link.

any suggestions?

encyclo

12:44 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first big problem is that your markup is invalid - you cannot place a
div
within an anchor as an anchor is an inline element. The HTML validator [validator.w3.org] will help you out here.

You could try using a

span
instead, or rework your markup completely. It appears you are building some sort of list, so an unordered list (
<ul></ul>
) may be the best choice.

For the precise hover code can you post a short and relevant snippet of your CSS?

adamnichols45

9:37 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A:Hover {
color: #CC3300;
}

Im not building a list just want a block of text with a different class on each line. But at the same time i want all 3 lines assigned to the same link.

Its the first time i have used <div>

thanks

4hero

9:50 am on Apr 12, 2006 (gmt 0)

10+ Year Member



Hi,

I would avoid using div's to apply classes to text and links, span's are highly recommended ;)

Try this:

<tr><td><a href="aa.php" class="">
<span class="tsblue">aaaa</span>
<span class="black2">aaaa</span>
<span class="purple">aaaaa</span></a>
</td></tr>

with this styling:

.tsblue {color:#4594DD; display:block;}
.black2 {color:#000; display:block;}
.purple {color:#503EAB; display:block;}

good luck!

adamnichols45

10:59 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That last example still does not work.

I have tryed the <span> but the hover does not work

Hester

2:18 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In Opera it makes the underlines red on hover. This shows the reason why it doesn't work. The hovers are being ignored because the text is inside spans. So you would have to write the hover like this:

span:Hover { 
color: #CC3300;
}

Which of course doesn't work in IE6.

What you should do is get rid of the spans and add the classes to them instead. (Yes, I know, that's duplicating them.) Then apply the hover. Eg:

<tr><td> 
<a href="aa.php" class="tsblue">aaaa</a>
<a href="aa.php" class="black2">aaaa</a>
<a href="aa.php" class="purple">aaaaa</a>

You can always make them 'display:block' to fall onto new lines.