-1

I have a div on a page with the background colour set to grey. How do I get rid of the white border around the div, so that the white edges are also grey in colour?

e.g. HTML:

<div id="top-div">
    <h1>Some Header</h1>
    <p>
        Some text.
    </p>
</div>

CSS:

#top-div {
    background-color: #808080;
}

Current graphical output:

enter image description here

Desired graphical output:

enter image description here

gornvix
  • 3,154
  • 6
  • 35
  • 74
  • 1
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. – Paulie_D Feb 28 '21 at 12:17
  • https://stackoverflow.com/questions/30208335/removing-body-margin-in-css – Paulie_D Feb 28 '21 at 12:18

1 Answers1

0

You should use some CSS Reset in your main css file. Something like this:

*, ::after, ::before {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

body {
    color: #333;
    font-family: "roboto","Helvetica Neue",Helvetica,Arial,sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
    display: block;
}

It's where you set some default css behaviours.

In your example, it's the body that has a default margin