Reputation: 5198
Foremost there are a lot of posts relating to background-color
. I have read several and have tried various solutions posted there from setting background-size
to making overflow hidden. Nothing seems to work....
How can I get background-color
to cover the whole section?
I have a very simple M.W.E. below:
<body>
<section>
TEST!
</section>
</body>
body {
background-color: coral;
}
section {
background-color: blue;
width: 100%;
}
Upvotes: 1
Views: 3692
Reputation: 72
I would recommend reading about "reseting css", zeroing margin and padding of body, html, p and etc. It can solve your problem. reset-css
Upvotes: 0
Reputation: 8284
The full width of the page?
You can reset or eradicate with:
*, html, body {
padding: 0px;
margin: 0px;
}
Upvotes: 0
Reputation: 67778
There is a default margin on the body
element, so you should always add this rule:
body, html {
margin: 0;
}
Here it is applied to your example: https://jsfiddle.net/93669xwh/
Upvotes: 1
Reputation: 8412
You need to use margin:auto
on body tag
snippet below
body {
background-color: coral;
margin:auto;
}
section {
background-color: blue;
width: 100%;
}
<body>
<section>
TEST!
</section>
</body>
Upvotes: 1