I have two divs, but there is space around them,. I have eliminated the space between them using overflow: none;
, but I do not know how to eleminate the extra space around them. How can I do that?
Asked
Active
Viewed 2,143 times
1

j08691
- 204,283
- 31
- 260
- 272

James Parsons
- 6,097
- 12
- 68
- 108
-
1`overflow: none` doesn't eliminate space... – Jon Egeland Mar 09 '15 at 18:54
-
2possible duplicate of [How to remove margin space around body or clear default css styles](http://stackoverflow.com/questions/9547291/how-to-remove-margin-space-around-body-or-clear-default-css-styles) – Jon Egeland Mar 09 '15 at 18:55
4 Answers
6
Your body's margin needs to be set to 0.
body{margin: 0;}
Additionally I highly recommend using a CSS reset at the top of your CSS as below to avoid other possible conflicts: JSFiddle
html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, menu, nav, section, time, mark, audio, video, details, summary {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
background: transparent;
}

Nima
- 2,100
- 2
- 23
- 32
1
The body element has a default margin of 8px. You need to set it to 0 in your css.
body
{
margin: 0;
}
As a default, your two div's are wrapped inside a BODY element, which is also wrapped in an HTML element. You don't see this in jsFiddle, because they are generated automatically for you when the you click run.
If you haven't already, I would suggest researching 'CSS Resets' (basically resetting all styling to base-line) and the 'Document Object Model' (DOM). This will help you understand inheritance, HTML structure.

Andrew Karstaedt
- 165
- 1
- 12