Re: What should happen with auto margins?

> 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?

It is a block level, non-replaced element, so the relevant part of the
specification is: 
<URL:http://www.w3.org/TR/REC-CSS2/visudet.html#q6>

Width is specified, margin-left/right is auto, padding and border
default to zero width. The margins must the be given equal sizes.
If the width is wider than the containing block, and
margin-left+width+margin-right equals the size of the containing 
block, then the margins must be equal and negative.

> For a quick example, see http://tom.me.uk/2003/2/css-margin-auto.html.

> Currently both IE6 and Opera 7 don't allow the element to go off to
> the left, but Mozilla does. In my opinion the former option is a lot
> more sensible, but does it violate the specification?

I think it does.

> In both cases the margins seem to get the same value (as the specs
> demand): just with Op7 and IE6 that value is zero.

That is not sufficient to satisfy the constraint, margins and width
must sum to the width of the containing block.

This is CSS2. The only difference in CSS2.1 is the addition of the
sentence: "This horizontally centers the element with respect to the
edges of the containing block.", and only Mozilla satisfies this.

/L
-- 
Lasse Reichstein Nielsen - lrn@daimi.au.dk
'Faith without judgement merely degrades the spirit divine.'
DHTML art: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>

Received on Friday, 28 February 2003 13:24:50 UTC