Forum Moderators: not2easy
How do I avoid this?
I have an example of what I'm doing, but what I'm doing is much more complex than this.
#mainnav {float:left; height: 400px;}
img {float:left}
p {clear:both}
#footer{clear:both}<div id="mainnav"> <p>vbnvbnvnb</p> <p>vnbvbnvbnvbn</p> <p>vbnvbnvbnvbn</p> <p>vbnvbnvbnvbn</p> </div>
<img src="img/imageplaceholder.gif" width="172" height="138" />
<h1>dgdfgggddf</h1> //*This will float beside the img*//
<p>dgdfgggddf</p> <p>dgdfgggddf</p> <p>dgdfgggddf</p> //*This will clear the img and begin new blocks just underneath it*//
<div id="footer"> <p>yyuiyuiyui</p> <p>yuiyuiyuiyui</p> <p>yuiyuiyuiyui</p> <p>yuiyuiyuiyui</p> </div>
TIA
Javashackgirl
Here it is in w3-speak:
The 'clear' property does not consider floats inside the element itself or in other block formatting contexts.
So if the clear element and the floated element are in different block formatting contexts, the float will not affect the clear.
As for what a block formatting context IS, the w3 says...
Floats, absolutely positioned elements, inline-blocks, table-cells, and elements with 'overflow' other than 'visible' establish new block formatting contexts.
So there you go. Put the element with a clear property into it's own block formatting context (a div should do it; you may need to float it, or give it display:inline-block (which doesnt' validate, but oh-well), or change it's overflow value) and it will only clear floats within it's own context.