Reputation: 3186
I think I found some typos in code I'm supporting and posted it to a local site as a funny example of invalid code, and then someone said that sometimes this invalid usage is correct.
Why would someone might need this code?
<table>
<form>
<tr>
<td></td>
</tr>
</form>
<form>
<tr>
<td></td>
</tr>
</form>
</table>
When can it be better than the following?
<table>
<tr>
<td>
<form></form>
</td>
</tr>
<tr>
<td>
<form></form>
</td>
</tr>
</table>
Or this:
<form>
<table>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
<form>
<table>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
I played with JSFiddle and can't find HTML decision, so maybe that's a reason.
But I think that JavaScript or CSS way would be better.
Upvotes: 0
Views: 708
Reputation: 499062
This is a way to get the two form elements to align with each other using table-based UI alignment. It used to be quite common before CSS was widely supported in browsers.
Today one would do that in CSS with your preferred markup.
Upvotes: 6
Reputation: 943615
And then some person said me that sometimes this invalid usage is correct.
By definition, invalid code isn't correct.
Can you please explain me why someone might need this code?
With a single cell per row? There isn't even a half good reason. There shouldn't be a table there in the first place because it wouldn't be tabular data.
If there were multiple cells per row, then it would be nice to be able to have a form per row (for an "edit this entry" thing). It isn't necessary though, as you can give each input a unique name, and then determine which row to process based on which submit button was clicked (since only the clicked submit button will be successful and therefore have its name/value pair submitted to the server).
Upvotes: 6