Open marginpadding.html and boxes.css from beginnersite and save a copy in intermediatesite.  Try marginpadding.html in a browser to remind yourself what it looks like.  If you do not have that file just create a div and style it as described in the next paragraph (any variation of those styles will do).

You have a div which has width, height, borders, padding and margins partly from the external style sheet and partly from embedded styles.

In the embedded style sheet in marginspadding.html change the left and right margins to this:


Save and try.  The browser knows the width of the page.  It also knows the width of the block element.  It automatically allocates the margin equally and centres the div in the window.  Unfortunately it doesn't work with height and top and bottom margins so you can only centre things horizontally this way.