Jump to content

col width in css


Recommended Posts

A working table which maintains a semblance of formatting as window width is changed from 50% to 100% of the usual landscape monitor is at


The code fragment that makes this work is


<col width="110px"/>
<col width="150px"/>
<col /> <!-- This column absorbs width change -->
<col width="40px"/>
<tr class="red">
<td>Alpha-male egoism, <i>machismo</i></td>
<td>Self propagating.</td>
The validator says <col width=...> is obsolete and airily adds, 'use CSS', without further suggestions. I can't find anything in CSS that does this without style statements in each table box, which seems exceedingly inelegant. What am I missing?
Link to comment
Share on other sites

You can give a class name to the <col> elements, but I'm not sure how well CSS is supported on them.


You can also give a class name to each cell of a column:

  <th class="instinct">Instinct</th>
  <th class="synonyms">Synonyms</th>
  <th class="utility">Utility</th>
  <th class="chap">Chap</th>

Then use CSS to give the widths:

.instinct {
  width: 110px;

.synonyms {
  width: 150px;

.chap {
  width: 40px;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...