Here is a simplified example to what I had before with markup and style.
I have asked a similar question before but haven't received an answer I fully understand.
You may give a simple example to better explain why I must use clear:both
to make padding-top
work.
I do want to really understand float
and clear
.
So my question is:
I still can't understand why I must use clear:both
in the #message
declaration to make this declaration work
#message p
{
padding-top: 30px;
}
<!DOCTYPE>
<html>
<head>
<title>testing</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
body
{
text-align: center;
width: 768px;
}
#register
{
float: left;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
color: #690;
background: #BDDB62;
}
#message
{
clear: both;
text-align: center;
background: #92B91C;
}
#message p
{
padding-top: 30px;
}
</style>
</head>
<body>
<div id="register">
<p style="float:left">We float left</p>
</div>
<div id="message">
<p>Paragraph after floated element</p>
</div>
</body>
</html>