Re: What should happen with auto margins?

Tom Gilder wrote:
> If I have an element set to a width wider than the viewport and
> margin-left/right set to auto, how should the element display?

Unfortunately, the CSS specification has some wiggle-room here that 
makes all of the renderings involved "valid".  See 
http://www.w3.org/TR/CSS21/visudet.html#min-max-widths -- the part you 
want is the paragraph right after the numbered list that starts "The 
user agent may define a non-negative minimum value for the 'min-width' 
property, which may vary from element to element and even depend on 
other properties."  (Translation: "As long as the actual width is at 
least the specified width, the rendering is compliant no matter what").

So if in this case IE and Opera make up a min-width for the containing 
block of your element they can indeed satisfy the width constraint 
equation with 0 margins and be technically compliant.  Mozilla basically 
ignores that paragraph and treats min-width as 0 if min-width is not 
specified.  So that rendering is also compliant.

Try putting a border on the containing block of your element to see 
whether IE and Opera are indeed just increasing the CB width; I bet they 
are.  (Note that IE will even do this if you set a specified width on 
the CB and will be completely compliant as it does it.)

Received on Friday, 28 February 2003 14:18:03 UTC