Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I create hard margins through an entire HTML/CSS layout that don't impact the background or current container?

My attempt:
Example page:

Scenario: I am currently working through a CSS/HTML project and have to recreate an example web-page using flexbox.

Problem: I seem to be unable to mimic the margin/indenting that the example page is using on either side of the page.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here
When I attempt to copy this in various ways, I end up indenting the entire header block, and I’m left with whatever colour the body is behind.

>Solution :

Margin is an attribute that defines the outside range of the box you are working in. It will increase the whitespace outside of the box.

What you want is increase the whitespace inside of the box. This spacing is called padding.

body {
  padding:5px 10px 5px 10px;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading