W3C home > Mailing lists > Public > www-style@w3.org > February 2003

Re: What should happen with auto margins?

From: Lasse Reichstein Nielsen <lrn@daimi.au.dk>
Date: Fri, 28 Feb 2003 19:28:34 +0100
Message-ID: <7429227486.20030228192834@daimi.au.dk>
To: www-style@w3.org



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

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:20 GMT