Users' questions

Why does body have 8px margin?

Why does body have 8px margin?

The body element generally has an 8px margin by default in some browsers so you need to control it in your own stylesheet instead and set it to what you want. Historically some browsers used padding and some used margin and some applied them to the html element instead of body.

Why does body have margin CSS?

The CSS margin properties are used to create space around elements, outside of any defined borders. With CSS, you have full control over the margins. There are properties for setting the margin for each side of an element (top, right, bottom, and left).

How do you get rid of body margins?

All you need to do is give your HEADER tag a 1px border, aswell as setting the BODY MARGIN to zero, as shown below. You may also need to change the MARGIN to zero for any H1, H2, etc. elements you have within your HEADER div. This will get rid of any extra space which may show around the text.

What is upper margin?

The margin-top CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.

What is setting an 8px margin on my page?

Have you never noticed the default margins on a p tag or an h1 tag or the default bullet on a list. These are all set in the UA stylesheet, The body element generally has an 8px margin by default in some browsers so you need to control it in your own stylesheet instead and set it to what you want.

Do you need to set margin on body element?

(The margin of the body element is meaningless; it’d represent a space outside the browser window!) As an aside, you don’t need to set any CSS properties on the html element. body already contains everything that you’d want to set properties on. Probably you are having a difficulty because margin and padding are two different things.

How to set the margin for a < P >?

Set the margin for a element to 35 pixels for top and bottom, and to 70 pixels for right and left: margin: 35px 70px; Example. Set the margin for a element to 35 pixels for top, 70 pixels for right and left, and to 50 pixels for bottom:

How many pixels does the bottom of a CSS document have?

The top and bottom will have an internal margin of 16 pixels. The left and right margins will have a inner margin of 8 pixels. It is the same with the margin property, for the outer spacing.

https://www.youtube.com/watch?v=FI9hOMOMd3s