1 reply [Last post]
tepidarium
Offline
Regular
Last seen: 16 years 14 weeks ago
Joined: 2004-10-19
Posts: 41
Points: 0

Is there a way to style table in the following manner with CSS?

I want to define individual properties for each column of a table. i.e. Same bgcolor, padding, alignment. This, to me , seems problematic. It would be easier to style whole rows than whole columns because rows are contained in the same <tr> tag, while columns are not.
The only alternative I can think of (which I'd like tog et away from) is setting a unique class for each <td> cell that comprises the column.

Is there any other way to do this?

BTW (my table is for tabular data, not layout!) Laughing out loud

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 day 23 hours ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

Styling Tables effectively

Unless you want to set the column cells individually, I'd use a script to do the dirty work. See this table. The basic table was built with PHP/Mysql (this page is the static output), and is dynamic in the client by way of javascript. Click on a column header to see the column change color. Don't ask for help on the script Wink, where js is concerned, I'm a cut and paste kinda guy.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.