Geekblok

B10m, BOK, Joffie - old geeks on a blog

Entries Comments



html: colgroup and col

3 June, 2008 (21:35) | html, technical | By: Joffie

Last week I had to design a table where I’d liked to specify the with of a table. I used to do this by giving a class to the columns of the table like:

<table>
<tr>

<td class=”col1″>some data</td>

<td class=”col2″>some more data</td>

</tr>

</table>

And then to specify the layout of the td classes col1 and col2 from a stylesheet.

This week I discovered that there is better way to accomplish the same, using colgroup and col. Never knew that there was already a way to do this the “right way”. So my next tables will look like:

<table>
<colgroup>

<col class=”col1″>

<col class=”col2″>

</colgroup>

<tr>

<td>some data</td>

<td>some more data</td>

</tr>

</table>

It might not look too different in this small example, but I sure I will find some use for it.

Comments

Comment from B10m
Time: June 3, 2008, 9:47 pm

Interesting. I never used that before either.

Write a comment





Preview: