How did I not know about the col tag???

So whilst developing away the other day I came across the <col> tag! ( Hopefully I am not alone in never having used this before.)
After a quick google I soon established that the col tag could be used to control the widths and alignments of columns in a table removing the need to constantly define td widths and alignments individually.

Simply insert a col tag above your table for every column in the table. eg.

<col width=”300″ />
<col width=”100″ />
<col width=”300″ />

<table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<th>Column width 300px</th>
<th>Column width 100px</th>
<th>Column width 300px</th>
</tr>
</tbody>
</table>

As simple as that! Find out more about the <col> tag at http://www.w3schools.com/TAGS/tag_col.asp

Comments

Be the first to write a comment about How did I not know about the col tag???…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>