Checking the syntax of the html table

It should be easy.

I have a table like:

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

      

My firefox 3 checker says this is acceptable code. It just seems wrong to me, are there any possible problems leaving the table rows uneven? It works in IE7 as well.

0


a source to share


5 answers


You must use the "rowspan" or "colspan" attributes



<table>
  <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td colspan="3"></td>
  </tr>
</table>

      

+1


a source


If you want to use uneven row / column counts, you need to <<remove> use rowspan and / or colspan attributes to indicate this. eg:

<table>
<tr><td></td><td></td><td></td></tr>
<tr><td colspan="3"></td></tr>
</table>

      



As the guffa explained to me, kolspan is technically not needed, but he is never afraid to be explicit about your intentions.

+1


a source


Table rows do not have to have the same number of cells. The number of columns in the table is determined from the row with the most cells.

Your second row of the table will only have three cells that are blank (this is not the same as blank cells).

+1


a source


Well, there are no syntax errors in there, and I really don't understand why you should be skeptical about a table like this if you use an attribute colspan

on a td element:

<table>
<tr>
<td></td><td></td><td></td><td></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
</table>

      

Hope it helped.

0


a source


This code is good from a structural point of view. This is valid XHTML. Compare this:

<orders>
   <order id='2009/1'>
     <item id='1'/><item id='2'><item id='3'/>
   </order>
   <order id='2009/2'>
     <item id='33'/>
   </order>
</orders>

      

This may sound strange, so the suggestion to use colspan. This way you can get a single TD to fill the row, not the TD width above it.

0


a source







All Articles