user2892875
user2892875

Reputation: 89

CSS width:100% not full screen

Alright so I am trying to create a top bar of my webpage like the one at the top of this page and what my code looks like is this:

<body>
<div id="header">
</div>
<body>

and the css is

#header{
width:100%;
}

and when I look at in a browser it doesn't completely touch the sides, It's about 10px away. How do I fix the gap?

Upvotes: 1

Views: 2692

Answers (2)

jmore009
jmore009

Reputation: 12933

you need to clear the default margin/padding that the browser sets on the body. Use:

body{
   margin: 0;
   padding: 0;
}

Working Fiddle

Upvotes: 3

jingyinggong
jingyinggong

Reputation: 646

css should have this!

body {
  margin: 0;
}
#header {
  width: 100%;
}

because default the body has some margin on it! you should remove them so the header can fill the body full!

Upvotes: 0

Related Questions