Hey Joao,
I didn't test on Safari 3.2.3 (and my version of opera is newer as well), but 
in general I'd agree with your results.  That said, Safari 5.0.4 (I believe 
correctly) returns 98px for margin-left on my test case 
http://jsfiddle.net/RVpPx/4/.  This fiddle only tests margin-left, but same 
story basically.

Sorry I never really explained my reasoning.  To some degree, you are correct 
that I expect a value other than 0px (and why I believe Safari 5 and IE9 are 
correct) because the content is centered, but the reason I went to the docs is 
because the content is centered horizontally when I change the value of the 
margins.  Because a change in the margins is responsible for the centering, I 
am led to believe that the centering is achieved through the margins.  This is 
not possible if the margins are 0px wide.  I know this because I can set my 
margins to 0px wide and I do not get the same horizontally centered results.

Secondly, the css specification in section 
10.3.3<http://www.w3.org/TR/CSS21/visudet.html#blockwidth> says that it is the 
margin left and right values that are responsible for this horizontal centering 
and they are real calculated values:

A. 10.3.3 states that block-level, non-replaced elements are subject to the 
following layout constraint: 'margin-left' + 'border-left-width' + 
'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 
'margin-right' = width of containing block.
B. 10.3.3 also states that if both margin-left and margin-right are auto, their 
used values are equal, centering the block
C. By A&B, the used value for a block-level, non-replaced element with 
style="width: 200px; height: 100px; margin: 50px auto; border: 2px solid 
black;" and found inside a containing block with a width of 400px should be 
98px.  (400 = 2*margin + 2 + 0 + 200 + 0 + 2)
D. getComputedStyle returns what css 2.1 would consider used styles (a point 
very helpfully clarified in the bottom of the mdn docs for the 
method<https://developer.mozilla.org/en/DOM:window.getComputedStyle>)
E. By C and D, getComputedStyle should return 98px

Hope this helps to clarify,
Joel

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to