Return to Snippet

Revision: 18803
at October 8, 2009 15:34 by adamcoulombe


Initial Code
#mySelfClearingDiv { /* put your regular css styles in here */ }

/*paste this stuff just below it to make it self-clearing */
#mySelfClearingDiv:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
#mySelfClearingDiv { display: inline-block; _height: 1%; }
#mySelfClearingDiv { display: block; }

Initial URL

                                

Initial Description
Usually when designing a site using floating elements in HTML/CSS, you need to an extra html element with the css style {clear:both;}. This method lets you apply styles to the container of the floating elements so that you don't have the headache of using a clearing div. This is cross-browser and IE6 friendly!

Initial Title
Make an HTML Container Clear Floating Child Elements Using Only CSS

Initial Tags

                                

Initial Language
CSS