Yamcha Posted April 20, 2011 Share Posted April 20, 2011 Hi Guys,Anyone know how I can remove spacing in div tags? I'm going to be using two different backgrounds, which is why I went with a div tag, the problem is there is spacing on all four sides..Appreciate your help, Thanks! I'm a noob so still learningPreview <html> <head> <style type="text/css"> #bgtop {background-image:url(top_bg.jpg); background-repeat:repeat-x; height:396px;} </style> </head> <body> <div id="bgtop"> </div> </body></html> Link to comment Share on other sites More sharing options...
jeffman Posted April 20, 2011 Share Posted April 20, 2011 All browsers have a default margin around the body. Other elements have unpredictable margins and padding. Experienced developers reset these values (and others, too) with the following CSS. Note that * is the universal selector. A ruleset for * applies to every element in the document. (Those rules can be overwritten by other rules, of course): * { padding: 0; margin: 0;} Make that the first ruleset in your stylesheet. Link to comment Share on other sites More sharing options...
Yamcha Posted April 20, 2011 Author Share Posted April 20, 2011 Thanks a lot, it worked! But I've run into another problem, the second background that supposed to be under the first is not showing up, I'm not sure if I'm doing anything wrong or if i'm missing something, the second background has to repeat both ways..Example <html> <head> <style type="text/css"> #bgtop {background-image:url(top_bg.jpg); background-repeat:repeat-x; height:396px;} #bgbottom {background-image:url(bottom_bg.jpg); background-repeat:repeat-x repeat-y; height:auto;} body {margin:0px; height: auto;} </style> </head> <body> <div id="bgtop"> </div> <div id="bgbottom"> </div> </body> </html> Link to comment Share on other sites More sharing options...
jeffman Posted April 20, 2011 Share Posted April 20, 2011 #bgbottom has no background because it has no height. You can define a height for it with a height rule. It will also gain height if you add any content to it. You can see this for yourself just by typing a few text characters. Link to comment Share on other sites More sharing options...
Yamcha Posted April 20, 2011 Author Share Posted April 20, 2011 Thanks again for your help it worked, really appreciate it, I'll try and mess around with it myself before I keep asking questions Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.