- From: Stuart Ballard <sballard@netreach.com>
- Date: Fri, 14 Mar 2003 17:26:51 -0500
- To: "www-style@w3.org" <www-style@w3.org>
This message may be off-topic, but whether it is or not depends on what the answer to the question is. If the answer is "you can already do it", then it's off-topic because it's a "howto" question. If the answer is "you can't do it" then it's on-topic because it's a suggestion of something to add to CSS... How's that for an existential quandry? ;) Anyway, the question is this (using a generic unversioned kind of HTML for my examples) When I write something like this: <table style="background-color: red"> <tr> <td> My Cell </td> </tr> </table> then, per the default styling rules in just about every browser (and as far as I can tell the CSS2 spec backs this up, referring to things like Minimum Content Widths etc), the red background (and hence the table) is only the size it needs to be to fit the width of the text "My cell", plus applicable margins, padding and border. On the other hand, if I write something like this: <div style="background-color: red"> My Div </div> then, per the default styling rules (and again the spec seems to back this up), the red background is the full width of the containing block (which if I'm not already inside something else, means the full width of the browser window). I don't object to this default behavior, but the problem is that as far as I can tell there's NO WAY to style a div to behave like the table cell does by default. Which forces me to use horribly un-semantic tables for simple blocks that don't need any tabular behavior except for the ability to calculate their width based on their content. "width: auto" is apparently equivalent to the initial value and computes to (effectively) 100%. "margin-right: auto" apparently (by the algorithm described in CSS2 10.3.3) gets treated as if it were zero if width is auto. "width: 0" causes the content to be compressed to its minimum possible width, which isn't necessarily the same as it's preferred size (in my example, it would cause a linebreak to be inserted between "My" and "Div"). "min-width: 0" has no effect because the computed value isn't constrained by the minimum width. My question is therefore, is there any way to get the behavior I want based on current CSS specs, and if not, is there any plan to provide this behavior in future versions of CSS? Thanks, Stuart. -- Stuart Ballard, Programmer NetReach - Internet Solutions (215) 283-2300, ext. 126 http://www.netreach.com/
Received on Friday, 14 March 2003 17:26:53 UTC