Help - Search - Members - Calendar
Full Version: <a> in a <table>
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
Nigel
I've been using off-line validating with HTML-Kit. I get the warning "<a> isn't allowed in <table> elements". I get that with HTML 4.01 transitional and also with HTML 4.01 strict.

I have found no indication elsewhere that such <a>s are not allowed or are deprecated, and they work perfectly well in IE6 & IE7. Can someone throw light on whether that validation warning is warranted or not?
Darin McGrew
The only things that can go inside a TABLE directly are CAPTION, COL and COLGROUP, THEAD, TFOOT, TBODY, and TR.

The A element must go inside a TD or TH element, which goes inside a TR element (or possibly the CAPTION element).
pauls
Simlar query, have placed <a> into <tr>&<td>, however this has severly altered the appearance of the table i.e cells have stretched accross the page.

This is what i have in place at the moment

<tr>
<td>About Us<a href="C:\html\Aboutus.html"></a></td>
</tr>

Anyone any idea's of how to prevent this?
pandy
I think you mean <a href="C:\html\Aboutus.html"><About Us/a></a>. wink.gif

Must be something else. Can you post a link to the page?
factor
QUOTE(pandy @ Dec 13 2006, 08:31 AM) *

I think you mean <a href="C:\html\Aboutus.html"><About Us/a></a>. wink.gif

Must be something else. Can you post a link to the page?


Syntactically <a href="C:\html\Aboutus.html">About Us</a> would be correct. Other than that as Darin mentioned you can't place a link directly under a <table> tag, you must follow the correct markup hierarchy.

If you could give us the link to the page I'm sure we can help you with sorting this out.
Nigel
QUOTE(Darin McGrew @ Dec 13 2006, 11:51 AM) *

The only things that can go inside a TABLE directly are CAPTION, COL and COLGROUP, THEAD, TFOOT, TBODY, and TR.

The A element must go inside a TD or TH element, which goes inside a TR element (or possibly the CAPTION element).

Thanks, Darin, that explains it.

However, at http://www.htmlhelp.com/reference/html40/special/a.html we read that the A element can go in "Block-level elements", which include TABLEs. So I'm just wondering whether that entry on the Reference page could be made clearer. I was using only <A NAME=...>s, which I had thought might have been innocuous, but they are not.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.