<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
</tr>
</table>
Don’t be frightened to use line feeds (carriage returns) in your scripts. They separate different sections of your script and make it more readable and understandable. White space costs nothing and is worth a great deal. Also, don’t be worried if some of the lines of script appear a little short at the moment. That’s fine because it is far better to have short structured lines rather than long lines that are not structured and are difficult to understand.
It is a good general rule with tables that if your script is UN-structured and chigger-piggeldy then your tables will almost certainly be the same, whereas if your script is structured, neat and understandable then your tables are likely to ‘work’ correctly in all cases.
If there is a lesson that you should learn from this tutorial it is that rows should be separately sectioned within your table script and to demonstrate this we will now create another simple table, this time with three rows down and three cells across.
the table …
Cell 1 | Cell 2 | Cell 3 |
Cell 1 | Cell 2 | Cell 3 |
Cell 1 | Cell 2 | Cell 3 |
the script …
<table> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr> </table> |
If you study the table script above you will see that it has been created in five distinct sections. These are the table start, the three distinct table rows and the table finish. This is the magic formula for writing successful cross-browser tables that work correctly under all circumstances and if your table scripts look like the one above then you are well on your way to creating successful cross-browser tables.