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.
As of HTML5 - which was released years ago - it is OK to wrap block-level elements inside of an Anchor tag. In fact, pretty much the only thing you can't put inside of an Anchor tag is another Anchor tag.
In answer to your actual question a paragraph cannot contain any other block elements, which includes tables. Also in addition to this the closing </p> tag is optional so the first closing tag that is subsequently found by the parser will deem to have closed the paragraph.
Nothing is wrong with placing a div inside a tag. In fact, you can place just about anything inside a tag as long as they are categorized as transparent , except that no descendant may be interactive content (eg: buttons or inputs) or an a element, and no descendant may have a specified tabindex attribute.
It's not possible to have anchor tag like you want so you can make click event and add aditional CSS for making it to look like anchor. Because you don't know where you are going (hover and see url, like in an anchor tag), you can't right click and copy url, you cant open in a new tab, etc...
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With