Previous Message
Next Message

Re: [css-d] Netscape inline style

Sent by Eric A. Meyer on 30 September 2002 16:04


At 21:25 -0400 9/29/02, Adam Wodon wrote:

>Am I correct that floated divs NEED widths?

    According to the CSS specification, yes, that's correct.

>What are the repurcussions of not having it.

    According to the specification, an 'auto' width on a floated, 
non-replaced element (like a 'div') is computed as '0' 
(http://www.w3.org/TR/CSS2/visudet.html#q8).  So leaving out the 
'width' on a floated 'div' should force it to have no width.  The 
content would spill out of such an element, at least in browsers that 
allow content to spill out, and probably be wrapped at one word per 
line.  This last part isn't defined so it's hard to say if that's 
what should really happen.
    Obviously, not every browser follows this defined behavior, so in 
practical terms, leaving off the 'width' means that the rendering of 
the float will unpredictably vary by browser.

>I had the same issue with a floated img - and I took
>the width out and everything still looked fine in IE5/6 and NN6.

    That's because an image is a replaced element, and the 
specification says that if you don't give a floated replaced element 
a 'width', the intrinsic width of the content is used 
(http://www.w3.org/TR/CSS2/visudet.html#q9).

--
Eric A. Meyer (http://www.meyerweb.com/eric/), List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff (http://www.mako4css.com/)
Previous Message
Next Message

Message thread:

Possibly related: