Reputation: 2960
Can there be a table inside a tag?For example:
<a href="javascript:void(0)" style="display:block">
<table>
<tr>
<td></td>
</tr>
</table>
</a>
I tried the previous code. It's working fine in Google Chrome, but it's not working in Firefox.
Upvotes: 7
Views: 11348
Reputation: 21
You may use a <BUTTON>
tag and embed the table inside it. To remove button borders set:
style='border:none; margin:0; padding:0; outline:none;
For example:
<BUTTON type="button" onclick="" style="border:none; margin:0; padding:0;"><table>...</table></BUTTON>
Upvotes: 2
Reputation: 39466
Why can't you just add an onclick to <table>
?
<table onclick="window.location='page.html'">
<tbody valign="top">
<tr>
<td>content</td>
</tr>
</tbody>
</table>
Upvotes: 2
Reputation: 944064
The draft specification allows it so long as you could put a table where you put the anchor (it has a transparent content model)…
<div><a …><table>…</table></a></div> <!-- Allowed -->
<span><a …><table>…</table></a></span> <!-- Not allowed -->
…but HTML 4 does not (so you may have browser support problems).
Upvotes: 10
Reputation: 1039190
Yes, it's valid HTML5 but invalid HTML 4.01. The following snippet passes HTML5 validation:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
<a href="#">
<table></table>
</a>
</body>
</html>
As far as whether you should do it, that's another question. You probably shouldn't.
Upvotes: 2