Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Table Properties? 1

Status
Not open for further replies.

JavaStripped

Programmer
Dec 18, 2002
84
CA
Everything I can find online involving "CSS" and "tables" is about whether to use one or the other for page layout. I'm firmly on board with CSS in this debate. What I need to know is how to use CSS to style tabular data (that which we are supposed to use tables for). It seems to me that, as of IE5 anyway, almost none of the CSS table attributes are supported. In particular, what I need is a way to set the column width to the minimum necessary for the data (or even just to a fixed percentage, as long as it's with CSS). Given that the WIDTH attribute for TH & TD elements in HTML has been deprecated, I'd think that there would be a replacement for this in CSS, but so far I'm outta luck in my search. As of IE5, the only table attributes that seem to be supported are border-collapse and table-layout (not that I care about the lack of Netscape support; I'm designing these pages for an intranet that runs IE5 or newer, gradually upgrading to IE6 all around, exclusively).

Thanks in advance for any assistance,



JavaStripped
"I did *not* escape. They gave me a day pass."
 
CSS is not meant to be a complete replacement for HTML. Given that tables are explicitly designed for holding tabular data, scale back nicely for older browsers and will allow you to spend less time coding and more time doing something else, I say why not use a combination of both.

CSS can be used to augment the look and feel of tables quite easily, either by redefining the HTML tags or by assigning custom classes.
 
I realize that CSS is meant as a supplement to HTML rather than as a replacement, but it seems to me that CSS as it is currently implemented, combined with HTML's currently deprecated WIDTH attributes for the TD and TH elements, leaves a large hole in our table formatting. If we can't specify table cell widths without using a deprecated attribute, that says to me that either the browsers aren't implementing the new technologies quickly enough (very possible) or the W3C is pushing its recommendations through too quickly (not really possible in the computer industry as a whole, let alone an environment as plastic and mutable as the Internet). This thread is becoming a little more philosophical than I'd hoped, but philosophy is my primary intellectual activity outside of computers, so I shouldn't be surprised...

[yinyang]

JavaStripped
"I did *not* escape. They gave me a day pass."
 
"If we can't specify table cell widths without using a deprecated attribute" - Who says?
Code:
<html>
<head>
<style type=&quot;text/css&quot;>
<!--
.FirstColumn {
	background-color: #CCCCFF;
	width: 125px;
}
.SecondColumn {
	background-color: #CCFFCC;
	width: 250px;
}
.ThirdColumn {
	background-color: #FFCCCC;
	width: 75px;
}
-->
</style>
</head>
<body>
<table>
<tr>
<td class=&quot;FirstColumn&quot;>Some Data</td>
<td class=&quot;SecondColumn&quot;>A Longer Bit of Data Here</td>
<td class=&quot;ThirdColumn&quot;>Short</td>
</tr>
</table>
</body>
</html>

Seems to work alright in IE 5.5.
 
[blush]
Thanks, dwarfthrower. If I were a dwarf, I'd let you throw me; I'd even leave the question of &quot;where to?&quot; entirely up to you. I was so irritated by the pathetic number of specific table properties in CSS that I completely overlooked the basic box sizing properties. Thanks again.
[dazed] I guess I was up too late all weekend.


JavaStripped
&quot;I did *not* escape. They gave me a day pass.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top