Search code examples
csshtmlwidth

Why dont my Divs span 100% of the width?


I have a really dumb question to ask.

I am trying to make a div span 100% of the width of a webpage, but it doesn't reach. I want it to be dynamic (not specify the width in px) and I definitely don't want it to make a horizontal scroll bar appear.

I'm trying to make something similar to Stack Overflow's 100% page width 'alerts' which tell you when you've earned a new badge.

Screenshot of my site: Screenshot of my site. Note how the pink banner and green banner leave gaps where the sky blue background is shown.

Code for the pink banner div

<div width='100%' style="padding:0px; background-color:FF0099; background-image:url('pics/pink_bg.png'); ">
  &nbsp;
</div>

Solution

  • your html body tag might have padding or margin css. you should set those to zero(0). I hope it will help.