Soulcatcher
New member
Ok, i tried to do very simple 3-column website design using only divs and css. Here is the code:
--------------------------------
<!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 id="Head1" runat="server">
<title>The Beer House</title>
<style type="text/css" media="screen">
#header {background-color:red; min-height:50px; _height:50px;}
#footer {background-color:yellow; min-height:50px; _height:50px;}
#outer {background-color:green;}
#inner {background-color:blue;margin-right:200px;}
#left{background-color:blue; width:200px; float:left;}
#right{background-color:green; width:200px; float:right;}
#center{background-color:white; min-height:800px; _height:800px; margin-left:200px;}
p{text-align:center; margin:0px 0px 0px 0px}
.text{margin-top:60px; text-align:center}
</style>
</head>
<body>
<div id="header">
<div class="text">This is header</div><br/></div>
<div id="outer">
<div id="right"><div class="text">Right column</div></div>
<div id="inner">
<div id="left"><div class="text">Left column</div></div>
<div id="center"><div class="text">Center column<br />This is center column</div></div>
</div>
</div>
<div id="footer"><div class="text">This is footer</div></div>
</body>
</html>
----------------------------------------
As you can see, each column-div and footer/header-div has a div with some text. Each such div has class "text"
In stylesheet section i define this "text" class to have 60px of margin-top.
Question - why it results in those gaps between left, right, center cloumns and footer/header? These text divs are _inside_ other divs - so margin-top should just put some space between text div and its parent, there shouldnt be any gap between parent div and neighbouring div...
Of course, if i remove margin-top:60px from the text class in stylesheet everything is fine. But this means that i cant use, say, <p> or any other tags that set margins
--------------------------------
<!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 id="Head1" runat="server">
<title>The Beer House</title>
<style type="text/css" media="screen">
#header {background-color:red; min-height:50px; _height:50px;}
#footer {background-color:yellow; min-height:50px; _height:50px;}
#outer {background-color:green;}
#inner {background-color:blue;margin-right:200px;}
#left{background-color:blue; width:200px; float:left;}
#right{background-color:green; width:200px; float:right;}
#center{background-color:white; min-height:800px; _height:800px; margin-left:200px;}
p{text-align:center; margin:0px 0px 0px 0px}
.text{margin-top:60px; text-align:center}
</style>
</head>
<body>
<div id="header">
<div class="text">This is header</div><br/></div>
<div id="outer">
<div id="right"><div class="text">Right column</div></div>
<div id="inner">
<div id="left"><div class="text">Left column</div></div>
<div id="center"><div class="text">Center column<br />This is center column</div></div>
</div>
</div>
<div id="footer"><div class="text">This is footer</div></div>
</body>
</html>
----------------------------------------
As you can see, each column-div and footer/header-div has a div with some text. Each such div has class "text"
In stylesheet section i define this "text" class to have 60px of margin-top.
Question - why it results in those gaps between left, right, center cloumns and footer/header? These text divs are _inside_ other divs - so margin-top should just put some space between text div and its parent, there shouldnt be any gap between parent div and neighbouring div...
Of course, if i remove margin-top:60px from the text class in stylesheet everything is fine. But this means that i cant use, say, <p> or any other tags that set margins
Last edited: