Snowman Snowman - 1 year ago 38
CSS Question

How to avoid the borders/margins that arise from the body tag?

I'm new to CSS. I've got a deceptively simple problem. This is a fiddle of a simple page.

The objective is to show a fixed 900px white

centered against a coral background.

I've tried to achieve this using two
s maked

However, the whole page still seems to have a white background, which seems to be connected to the
tag. (Please use the fullscreen mode to see it).

If I give the
the background color of the
, again, the color appears on the top and bottom of the page too, which is undesired. (Please uncomment the CSS of body to see this.)

I've tried using the article tag; using negative margins; and changing dimesions of the body tag. Nothing seems to work.

In simple terms, a want a 'columned' look: coral-white-coral; instead of the 'boxed' look I currently have.

Please help.

Answer Source

Just add a style for the body in your CSS and set the margin to 0px, like so:

body {
    margin: 0px;