- This topic is empty.
-
AuthorPosts
-
July 5, 2011 at 3:35 pm #33383
poochiepiano
MemberOkay, I’ve tried searching for this and I apologize if this has already been answered, but here’s my question:
When I create a div say, like this:
It should just be a blue bar across the page, right? the thing is, I get white space around it. It doesn’t extend all the way to the edges. It has like a 10px space on top and a 15 px space on either side. I thought that all the padding/margin/border and stuff should automatically be 0 so I don’t have to worry about it. Is there something I need to put in to get it to go all the way?
I can provide a screenshot if necessary…
July 5, 2011 at 3:42 pm #82880Rob MacKay
ParticipantDefault browser behavior probably – look up CSS resets :D
html, body {
margin:0;
padding:0;
}
July 5, 2011 at 3:50 pm #82882WouterJ
MemberA browser put some standard margins and paddings on elements. You must reset them, look for the code on the post above.
Better is to reset youre hole CSS and then build op youre own styles. A good css reset is: http://meyerweb.com/eric/tools/css/reset/
You use inline style (height, style, width attributes). This isn’t a very good way to make you’re CSS. Beter is working with a stylesheet (.css file). And load this file in youre page with de link tag in the head.
July 5, 2011 at 5:04 pm #82892poochiepiano
MemberRobski, are you setting that as a style in a stylesheet?
wouterJ: I usually use style sheets but I figured this was the easiest way to show what was going on.
Okay, so I read a little bit into CSS resets… and I just want to make sure I’m understanding it correctly. I might already have CSS frameworks in place which have predefined rules that I may or may not know about? And resetting that just takes it all out so the only rules that exist are the ones that I write?
July 5, 2011 at 10:38 pm #82911poochiepiano
MemberIt worked! Thanks so much guys it’s been bothering me for a while.
July 6, 2011 at 2:49 pm #82961Rob MacKay
ParticipantYes what they said :)
Sorry I didn’t have much time to reply.
July 19, 2011 at 1:44 pm #83645poochiepiano
MemberHey, so I was looking at a few other forum posts, and people seemed to be really bothered by doing a
html, body{margin:0px; padding:0px;}
I don’t see the problem since this seems to work great. Just wondering why they dislike it so much.
July 19, 2011 at 2:12 pm #83649wolfcry911
ParticipantIts perfectly acceptable – except that you don’t need the unit type with a zero value
html, body { margin: 0; padding: 0; }
Setting specific elements’ margin and padding to zero is different than a generic reset, which is what some people are bothered with (me, for example).
July 19, 2011 at 6:51 pm #83662poochiepiano
MemberOh, what other stuff does a CSS reset affect?
May 23, 2013 at 8:09 am #136179Shweta
MemberIt really worked well, i was having the same problem in all my websites. Thank you so much.
-
AuthorPosts
- The topic ‘Div doesn’t reach edge of browser page’ is closed to new replies.