Forum Moderators: not2easy

Message Too Old, No Replies

div pushed down by paragraph returns

         

newdude

10:27 pm on Oct 29, 2008 (gmt 0)

10+ Year Member



how come the middle div gets pushed down if i add a paragraph return in the content of the middle div when i preview it in a browser? when i put an image in that div it doesn't happen. thanks.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#container {
background-position: center top;
margin: 0px;
padding: 0px;
}
body {
background-color: #0BA40B;
margin: 0px;
padding: 0px;
text-align: center;
}
#header {
background-image: url(../green/pics/banner.jpg);
background-repeat: no-repeat;
height: 145px;
width: 1000px;
background-position: center top;
}
#middle {
background-image: url(../green/pics/middle.jpg);
width: 1000px;
background-repeat: repeat-y;
padding: 0px;
margin: 0px;
}
#bottom {
background-image: url(../green/pics/bottom.jpg);
background-repeat: no-repeat;
width: 1000px;
height: 25px;
}
-->
</style>
</head>

<body>
<div align="center" id="container">
<div id="header">Content for id "header" Goes Here</div>

<div id="middle">
<p>hhhhh </p>
<p>adf</p>
<p>asdf</p>
</div>
</div>
</body>
</html>

swa66

10:42 pm on Oct 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



paragraphs by default have padding or margins from the default browser style (I always for get which they get).

Try adding


p {
padding:0;
margin:0;
}

or even:


* {
padding:0;
margin:0;
}

In the latter case: take care it also removed the padding or margin (depending on which browser you're using) from <ul> and <li> making you need to add it back to make lists look right. But the good news is that most of your other removal of padding and margin won't be needed anymore either.