HTML:
Some content
CSS:
body {
margin: 0 auto;
width: 470px;
back
When the element has no specified background the body background will cover the page. If the html element does have a background specified on it, the body background will behave like any other element.
From the W3:
For HTML documents, however, we recommend that authors specify the background for the BODY element rather than the HTML element. For documents whose root element is an HTML "HTML" element or an XHTML "html" element that has computed values of 'transparent' for 'background-color' and 'none' for 'background-image', user agents must instead use the computed value of the background properties from that element's first HTML "BODY" element or XHTML "body" element child when painting backgrounds for the canvas
So essentially your code is fine and the content is centered, but the background you specified on the body is being applied to the as well. You can see the difference when you give the
element a white background:
jsFiddle example