View Full Version : XHTML Srict <td width="xx"> Work Around

01-09-2003, 03:45 AM
As stated in my previous post, I'm currently messing with the "company webpage." The coding is attrocious, and as I'm going through and cleaning things up I figured I might as well make it XHTML complient while I"m at it. This way the site is has solid content and a solid structure.

Ideally, I'm a control freak, and I'd love to be able to have the code pristine XHTML Strict. As it stands now, it's XHTML Transitional.

The problem that I've run into is with tables. I know that CSS is the way to go but I don't want to get too involved in absolute positioning and the such right now. Yet to keep the site coherant across varying screen resolutions and to help to browser to efficiently lay out elements to the screen I'm assinging width attributes to all the tables cells. .... NOT XHTML STRICT COMPLIENT!

As the page is broken up among 3 tables, I've done not necessarily extensive but still a fair quantity of colspan and rowspan to avoid nesting, and the cells are of variying width, a CSS class attribute would seem rather absurd.

Would anyone have any ideas of other work arounds?

01-09-2003, 10:43 AM
how about

<td style="width:50px">


Alex Vincent
01-12-2003, 06:55 AM
That might work... bear in mind the style attribute itself is frowned upon. (The reason is you'd have to repeat that for every td in that column, I think, and style is meant to be a local override of normal styling.) Using a CSS stylesheet and a class attribute would be better.

01-12-2003, 11:50 PM
frowned upon?
it works dont it? and perfectly valid ;)

01-13-2003, 12:21 AM
Originally posted by cg9com
frowned upon?
it works dont it? and perfectly valid ;)

Not in XHTML 1.1, nor do I think 1.0 Strict.

01-13-2003, 01:52 AM
I think the point about replication is the more pertinent - having to copy that attribute to each cell would be tedious. I suggested it because I inferred you'd already dismissed the class attribute for a different reason, but OTBE it would be best.

You could always have a default, and a set of choices [and percentages are generally better]:

td { width:50%; }
td.twenty { width:20%; }
td.hundred{ width:100%; }

But personally I avoid defining the width of cells at all, as much as possible ... because global container-element definitions are harder to encapsulate against in DHTML.

01-13-2003, 06:05 AM
Originally posted by jkd
Not in XHTML 1.1, nor do I think 1.0 Strict.


it says its valid, and i used style 10 times ...