Is it valid HTML to insert a hidden input between table rows?
Background: I am writing a Java app which auto generates a HTML table. As well 开发者_如何学Cas adding table rows, this app may insert hidden inputs. However, at present it simply inserts them into the table at the next opportunity, for example:
<table>
<tr> ... </tr>
<input type="hidden" />
<tr> ... </tr>
</table>
So, my question: Is it valid HTML to insert a hidden input between rows like this, or is this likely to cause problems?
It's not valid.
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
No, it's not.
You should use the W3C validator and check by yourself your webpages : http://validator.w3.org/.
It's not valid.
From http://validator.w3.org/
Line 9, Column 27: document type does not allow element "input" here
It's not valid, after closing </tr>
tag it can have only <tr>
or </tbody>
or </table>
. If you test it with w3c validator It will fail.
精彩评论