Is it possible to insert a form into an html table?

Several forms in one table, these forms are for different row lengths, however this does not work:

<table> <form> <tr> <td> </td> <td> </td> </tr> </form> <form> <tr> <td> </td> <td> </td> </tr> </form> </table> 

I believe that the table has a certain structure, and this cannot be intertwined with other structures, but is there an order in this?

Thanks.

+6
source share
6 answers

Not. According to this document: http://www.w3.org/TR/html401/struct/tables.html#h-11.2.1 a table can contain only the following:

 TABLE -- (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)> 

But you can use something like this

 <div class=table> <form> <div class=cell>...</div> <div class=cell>...</div> </form> </div> 

with styles:

 div.table { display:table; } div.table > form { display:table-row; } div.table > form > div.cell { display:table-cell; } 
+5
source

No, you cannot do this. I think you want this method to have both forms aligned in the table, right?

If you are allowed javascript on the page, you can add various text fields, etc. inside the <td> elements and attach onchange event onchange to these fields to fill in the corresponding (hidden) fields in your actual forms.

+2
source

This will be a problem in all HTML ... including both XHTML and HTML5.

XHTML table dtd ..

<!ELEMENT table (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>

+1
source

Not between <tr> tags. They should work outside of <table> or inside of <td> , though.

0
source

There is no real need to have two forms in one table if you want to place them on several rows. The larger the table, the longer it takes to load and display the browser. Instead, give each form its own table and place the table tags in the form tags, for example:

 <form method="GET" action="foo.sh"> <table> </table> </form> 
0
source

Yes! No problem with HTML5. Now table tags are just a shorthand for table style rules.

0
source

Source: https://habr.com/ru/post/887577/


All Articles