Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table Tag Inside Anchor Tag

Tags:

html

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.

like image 426
Soarabh Avatar asked May 16 '11 06:05

Soarabh


People also ask

What can go inside an anchor tag?

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.

Can you put a table inside ap 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.

Can you put a div inside an anchor tag?

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.

How do you add an anchor to a table tag?

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...


1 Answers

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).

like image 172
Quentin Avatar answered Sep 27 '22 23:09

Quentin