Back to Programming Articles

[TIP] Indent Table Elements
by mashby 10 Sep 2002

Table problems are one of the most common problems that people run into when editing their templates. Forget to close a tag and your entire site can become crippled. To help fix this problem before it starts, I recommend that you indent each element when using tables. By simply adding a tab, or a few spaces to your code, you can make it easier to see if there's a problem with your code.

Compare the following two code samples and you'll see what I mean:

Code:
<!-- without indents -->
<table><tr>
<td>hello world</td></tr>
</table>
<!-- /without indents -->
Code:
<!-- with indents -->
<table>
	<tr>
		<td>hello world</td>
	</tr>
</table>
<!-- /with indents -->
Which is easier to read? When I try and help someone with their code, one of the first things I do is reformat their code with indents. If there's a problem with a missing tag, you can be sure that I can find it in a jiffy with this method.

You'd be surprised at what a difference something as simple as this can make.

vblts.ru supports vBulletin®, 2022-2024