KBD

Keith Devens .com

Friday, December 5, 2008 Flag waving
"Let me get this straight. He met with terrorists? Oh, that's good." – John Edwards (on finding out John Kerry's own diary testified to him meeting with North Vietnamese terrorists in Paris)
← Wealth distributionGenerators →

Daily link icon Sunday, May 5, 2002

CSS can't replace tables

Well, I just had my suspicions confirmed tonight after talking with two nice folks on #mozillazine. To put it real succinctly, you can't specify the height of a floated block with percentages if you don't specify the height of the containing block in absolute units, because the spec says that "If the height of the containing block is not specified explicitly (i.e., it depends on content height), the value is interpreted like 'auto'."

So =height:auto=, =height:inherit=, and =height:nn%= all mean the same damn thing if you don't specify the height of the containing block explicitly.

It's very unfortunate, because this one thing makes it impossible to simulate many table-based layouts in CSS. The two people I was speaking with both agreed that this is a bug in the spec, and we hope it'll be fixed in CSS3.

At least now I have a definite answer, that it's truly impossible to do the design I wanted to do without tables.


P.S. To show you what you wind up with (what I was trying to do is obvious), check out my final attempt to do a CSS-based layout without tables.

P.P.S. To show you that I'm right, check this out. This is the exact same code as the previous example, but with an absolute height (of 3 inches) set for the div containing the section between the header and footer.

P.P.P.S. Hey, check this out: It actually looks like they fixed it in the CSS3 box model working draft. They made percentage values relative to the computed height of the containing block, which is exactly what it should have been in the first place. From the spec:

A <percentage> is relative to the computed value of the width or height of the containing block, but if that value is 'auto' the computed value for the percentage is also 'auto'.

I'm still not sure I like percentage values collapsing into "auto" again if the containing block's height is "auto", but at least they corrected the part of the spec that I'm taking issue with right now Smiley

Yeah, I'm a moron, at 5:30am or whenever I read this I thought this meant that they had fixed it. In fact, this is the same behavior as before, since percentages mean "auto" if the containing block's height isn't specified absolutely. Boo.

← Wealth distributionGenerators →

Comments XML gif

84.59.73.208 wrote:

Hello, did you found a solution for this? I'm running into the same problem Smiley frowning

∴ 84.59.73.208 | 10-Aug-2005 5:46pm est | #8092

Keith (http://keithdevens.com/) wrote:

No, there is no solution.

Keith | 10-Aug-2005 5:47pm est | http://keithdevens.com/ | #8093

84.59.69.83 (http://www.3dcrew.com/) wrote:

thank you for the answer keith, seems like i need to use the wonderful modern tables again Smiley winking

∴ 84.59.69.83 | 11-Aug-2005 12:56pm est | http://www.3dcrew.com/ | #8098

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

Girls, please don't get breast implants

I have 34 A breast but at 22 years​old they seem to be growing again​which ...

76.64.120.153: Dec 3, 10:00am

Perl 6 1.0 in March?

Doh, my mistake. I'm aware of the​relation between Parrot and Rakudo​but I'...

Keith: Dec 2, 1:03am

Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Generated in about 0.273s.

(Used 8 db queries)

mobile phone