The best element for clearing floats in CSS?
If you really want to clear them, then some element best describes the semantics of the content you want to float to clear.
If you want the block to expand to contain all of its floating content, adding an extra element (of any type) is the dirtiest option. There are a whole bunch of better ways to achieve this effect . I usually prefer overflow: hidden
container installation , but the best option is slightly different from context.
If you really want to use an actual (empty) element, it is better to use a div or as a span - they have no additional semantics.
source to share
I have the following context:
<div id="sidebarWrap">
<div id="sidebarHandle">
<a href="#"></a>
</div>
<div id="sidebar">
<h2>Category</h2>
</div>
<p class="clear"></p>
</div>
Where #sidebarWrap is absolutely positioned in the upper right corner of the parent, and #sidebarHandle and #sidebar float to be next to each other. p.clear clears floated.
In this case, what would be the best solution?
source to share