Link to home
Start Free TrialLog in
Avatar of aratani
aratani

asked on

Anchor within anchors

I was wondering if this is possible,

<a href='page1.html'> Page 1
   <table><tr><td><a href='page2.html'> Page 2 </a></td></tr></table>
</a>

I need this to work since I have this menu system built using CSS. However, when I hover over the second page the status bar still says page1.html. If I click the second link then it gives me page2.html in IE, but page1.html in Netscape?

I have to keep this structure. Any suggestions on how to make this work (preferably without using any javascript). If I get a good quick answer, I'll increase the points for the person.

Thanks

AJ
Avatar of Daydreams
Daydreams

Hi aratani,

You need to close the anchor tags properly:

<a href="page1.html"> Page 1</a>
   <table><tr><td><a href="page2.html"> Page 2 </a></td></tr></table>
No that is not possible.
you cannot have a block elemtnt like a table, inside an inline element like an anchor.

Basically - No you cant.
I am guessing you want a hover effect when you hover over the table?
Using CSS, this can be done:

table:hover
{
CODE HERE
}
Sorry I just realise how much that didn't make sense.

No You cannot have your code structured like that.
A table is a BLOCK level element.
Which cannot reside inside an INLINE element.
An Anchor is an INLINE element.

Your code is invalid HTML, and will produce unsavoury results in most browsers.
Avatar of aratani

ASKER

Well, the menu system right now works perfectly. Actually, the table within the anchor do show up as a table in all the browsers I've tested. :). But, I can't get the link in Page2 to connect. It still thinks we are in the anchor for Page1. I was just wondering if there was a way to get the link in Page2 to work.

AJ
>It still thinks we are in the anchor for Page1.

It is because you closed the a tag after the table. As Neester said, it is invalid code.
Avatar of aratani

ASKER

Okay, I get that. But, now I have a newer problem and I don't know if I can ask that up here. But, to make my menu's work, I have used the hover element. However, the hover doesn't work for IE (for anything except the anchor tag). Is there someone who can give me a way to make the hover work for IE.

For example,

<span class='menu'><a href='page1.html'> Page 1 </a>
   <table><tr><td><a href='page2.html'> Page 2 </a></td></tr></table>
</span>

The style sheet is,

span.menu:hover {

 
}

This works for Mozilla and Netscape, but not for IE.

Can someone tell me how to make it work for IE? I will reward them with points.

Thanks

AJ
Hi aratani,

You can't put a block level element like a table inside a span tag. I don't see the necessity of the table, but you could put the links in td's if you like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
a.menu:hover {background-color:#ff0000; }  /*for example*/
</style>
</head>
<body>
<table><tr><td>
<a class="menu" href="page1.html"> Page 1 </a></td>
<td><a class="menu" href="page2.html"> Page 2 </a></td>
</tr>
</table>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of neester
neester
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial