What is the optimal method of site layout with tensile elements (header, footer and any others), in which these elements closely adjoin the browser window?

I will give a specific example. On the site template below the cap and footer with a fill; There should be no space between their extensible edges and the browser.

Template

And here is my site header: as you can see, I have fields between the edges of the header and the browser window, although the margin header is 0 on all sides.

enter image description here

I messed it up like this:

 header{ position: realtive; min-width: 1000px; height: 70px; background-color: #3CBAC8; margin: 0; } 

I looked at other sites in my browser - there are no fields.

I heard about such a layout method as pseudo-spacers, which is used for sites that are stretchable across the width of the window, but I ask for a solution with a minimum of tags and classes.

  • html, body {padding: 0; margin: 0}? - bemulima
  • Download and connect the style reset file normalize.css necolas.imtqy.com/normalize.css - Alex
  • you for * {margin: 0; padding: 0;} do it, and lay out the code, neither clearly nor see what you have done - user33274
  • I apologize, it all worked with body {margin: margin}. I will answer my own question; edit if something is inaccurate said. - Bokov Gleb
  • Opera 38.0.2220.31, Chrome 51.0.2704.103 m, FireFox 47.0, IE11, Edge - default css for body {margin: 8px;}; - soledar10

2 answers 2

Apparently, <body> , unlike other objects, such as <header> or simply <div> , have non-zero margins by default, at least on top and on both sides. The solution to the problem is obvious:

 body{ margin: 0; } 
  • one
    W3C cry for you (for you). - uorypm
  • uorypm is the coolest thing that body {margin: 0:} is written everywhere - user33274
  • @LenovoID is written this way due to the fact that the W3C recommended defaulting the BODY to 8 pixels (s). Although I do not argue, many people simply copy-paste without understanding what they are doing. It is sad. Even the vehicle itself did not understand why this is so - apparently - although they dropped the link to useful material. - uorypm
  • Nowadays, flat-design is very popular, an example of which I cited in my question, and there the fields of the body are rarely made, if at all. - Bokov Gleb
  • @Gurebu Bokofu, there are default spaces. I do not propose to leave them. Just want to show that you do not quite understand why they are there. - uorypm
 html, body { height: 100%; margin: 0; padding: 0; } 

It’s better to connect the godlike.css style reset file