<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Developer&#8217;s Notebook: Forward-thinking CSS float-clearing</title>
	<atom:link href="http://www.pathf.com/blogs/2007/09/developers-note-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pathf.com/blogs/2007/09/developers-note-2/</link>
	<description>Running commentary about agile development, user experience design and Ajax.</description>
	<pubDate>Tue, 02 Dec 2008 00:59:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Pathfinder Development &#187; What does your CSS Swiss Army knife look like?</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-3415</link>
		<dc:creator>Pathfinder Development &#187; What does your CSS Swiss Army knife look like?</dc:creator>
		<pubDate>Mon, 22 Sep 2008 19:15:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-3415</guid>
		<description>[...] cross-browser float-clearing:: I posted about this topic a year ago, generating plenty of debate. Whether you're using my Orbitz-inspired grocery-list-of-selectors [...]</description>
		<content:encoded><![CDATA[<p>[...] cross-browser float-clearing:: I posted about this topic a year ago, generating plenty of debate. Whether you&#8217;re using my Orbitz-inspired grocery-list-of-selectors [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jethro</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-313</link>
		<dc:creator>jethro</dc:creator>
		<pubDate>Wed, 05 Mar 2008 22:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-313</guid>
		<description>&lt;p&gt;There just needs to be an extra property in CSS. &lt;/p&gt;

&lt;p&gt;Something like &lt;br /&gt;
clear-children: clear/none;&lt;/p&gt;

&lt;p&gt;In all honesty should be set to clear by default. There have been times when I didn't want to clearfix, but they're rare enough that it shouldn't be the norm. Although, float wasn't designed for what we're using it for. There really needs to be an alternative to float. I'm not terribly excited about the CSS3 Layout but it may be the way to go. &lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>There just needs to be an extra property in CSS. </p>
<p>Something like <br />
clear-children: clear/none;</p>
<p>In all honesty should be set to clear by default. There have been times when I didn&#8217;t want to clearfix, but they&#8217;re rare enough that it shouldn&#8217;t be the norm. Although, float wasn&#8217;t designed for what we&#8217;re using it for. There really needs to be an alternative to float. I&#8217;m not terribly excited about the CSS3 Layout but it may be the way to go. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: presell</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-312</link>
		<dc:creator>presell</dc:creator>
		<pubDate>Sun, 28 Oct 2007 20:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-312</guid>
		<description>&lt;p&gt;Thanks for this one ...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for this one &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Dillard</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-311</link>
		<dc:creator>Brian Dillard</dc:creator>
		<pubDate>Mon, 01 Oct 2007 20:47:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-311</guid>
		<description>&lt;p&gt;I deliberately stayed out of the comments fray on this one, but I'm grateful to my former colleage Gena for stepping in to explain more of the whys and wherefores behind this solution - something I should have done better in my original post.&lt;/p&gt;

&lt;p&gt;My problem with a lot of CSS how-tos is they assume a small pool of developers, a tightly controlled codebase, and a relatively static site. In the real world, many of us work on huge sites maintained by global development teams, which requires defensive coding techniques. These apps must be skinnable - the same markup powering multiple white-labelled instances, sometimes on a variety of platforms (mobile/browser/etc.). They also rely on templating systems that may compose any arbitrary set of modules into pages; the CSS mustn't break as a result of any specific configuration. &lt;/p&gt;

&lt;p&gt;The techniques that work for a mostly static, content-based site must be adapted for a complex webapp with multiple white-labelled instances. Thanks again to Gena for helping me illuminate why this particular solution worked well for one particular such app.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I deliberately stayed out of the comments fray on this one, but I&#8217;m grateful to my former colleage Gena for stepping in to explain more of the whys and wherefores behind this solution - something I should have done better in my original post.</p>
<p>My problem with a lot of CSS how-tos is they assume a small pool of developers, a tightly controlled codebase, and a relatively static site. In the real world, many of us work on huge sites maintained by global development teams, which requires defensive coding techniques. These apps must be skinnable - the same markup powering multiple white-labelled instances, sometimes on a variety of platforms (mobile/browser/etc.). They also rely on templating systems that may compose any arbitrary set of modules into pages; the CSS mustn&#8217;t break as a result of any specific configuration. </p>
<p>The techniques that work for a mostly static, content-based site must be adapted for a complex webapp with multiple white-labelled instances. Thanks again to Gena for helping me illuminate why this particular solution worked well for one particular such app.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gena Wilson</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-310</link>
		<dc:creator>Gena Wilson</dc:creator>
		<pubDate>Mon, 01 Oct 2007 17:07:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-310</guid>
		<description>&lt;p&gt;A couple clarifications on why this approach worked for us--&lt;/p&gt;

&lt;p&gt;We were building a site that needed to be as fully skinnable/customizable as possible without needing changes to markup (but was allowed unlimited CSS differences via independent stylesheets).  Needing to enclose floated elements vs. not wanting to do so was not a good enough reason for changing the markup.  And in the interest of code transparency it was important to not have something like "clearfix" ever overwritten to not enclose floats.  It would be like having a class of "pinkBorder" that's set to be green in some implementations -- uncool, especially in a multiple developer environment.&lt;/p&gt;

&lt;p&gt;We also knew that designers sometimes like to employ the technique where graphics or text extend out of their parent container (but semantically, still belong inside it).  (Like a "New/Improved" graphic overlapping the corner of an element.)  For those cases, we needed overflow: hidden not to cut off that escaping content, and overflow: auto not to force scrollbars on it (even though in many other circumstances either would be more elegant).  And don't even get me started on overflow: auto + a floated parent + Safari 2.&lt;/p&gt;

&lt;p&gt;Lastly, we wanted our CSS to validate, which prevented the use of proprietary IE properties like "zoom" or things like the underscore hack.&lt;/p&gt;

&lt;p&gt;We went with the above technique for those reasons; it's most flexible for what we needed.&lt;/p&gt;

&lt;p&gt;Finally, while this problem is often discussed in terms of float clearing, it may be useful to clarify that the code above causes parent elements to *enclose* their floated children.  If browsers and designs supported it, it could be just as effective, and probably more transparent, to select the first subsequent sibling of div.containerWithFloats and add the appropriate clear (left/both/right) rule.  (Because this technique describes how to make div.containerWithFloats, due to its float enclosing, have subsequent elements no longer need to clear it.) &lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>A couple clarifications on why this approach worked for us&#8211;</p>
<p>We were building a site that needed to be as fully skinnable/customizable as possible without needing changes to markup (but was allowed unlimited CSS differences via independent stylesheets).  Needing to enclose floated elements vs. not wanting to do so was not a good enough reason for changing the markup.  And in the interest of code transparency it was important to not have something like &#8220;clearfix&#8221; ever overwritten to not enclose floats.  It would be like having a class of &#8220;pinkBorder&#8221; that&#8217;s set to be green in some implementations &#8212; uncool, especially in a multiple developer environment.</p>
<p>We also knew that designers sometimes like to employ the technique where graphics or text extend out of their parent container (but semantically, still belong inside it).  (Like a &#8220;New/Improved&#8221; graphic overlapping the corner of an element.)  For those cases, we needed overflow: hidden not to cut off that escaping content, and overflow: auto not to force scrollbars on it (even though in many other circumstances either would be more elegant).  And don&#8217;t even get me started on overflow: auto + a floated parent + Safari 2.</p>
<p>Lastly, we wanted our CSS to validate, which prevented the use of proprietary IE properties like &#8220;zoom&#8221; or things like the underscore hack.</p>
<p>We went with the above technique for those reasons; it&#8217;s most flexible for what we needed.</p>
<p>Finally, while this problem is often discussed in terms of float clearing, it may be useful to clarify that the code above causes parent elements to *enclose* their floated children.  If browsers and designs supported it, it could be just as effective, and probably more transparent, to select the first subsequent sibling of div.containerWithFloats and add the appropriate clear (left/both/right) rule.  (Because this technique describes how to make div.containerWithFloats, due to its float enclosing, have subsequent elements no longer need to clear it.) </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aeonax</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-309</link>
		<dc:creator>Aeonax</dc:creator>
		<pubDate>Mon, 24 Sep 2007 09:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-309</guid>
		<description>&lt;p&gt;So... you've unlittered the markup and littered the css. Nice!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>So&#8230; you&#8217;ve unlittered the markup and littered the css. Nice!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Peter Nielsen</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-308</link>
		<dc:creator>Hans Peter Nielsen</dc:creator>
		<pubDate>Mon, 24 Sep 2007 08:09:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-308</guid>
		<description>&lt;p&gt;"If you've ever floated an image next to a block of text, then you've witnessed an instance where you did not have to clear your floats."&lt;/p&gt;

&lt;p&gt;If your text content is dynamic and/or the width of the text column is dynamic, you cannot be sure the text will extend the height of the image without clearing the image float.&lt;br /&gt;
If you want more than one image in the text paragraph, the same applies.&lt;/p&gt;

&lt;p&gt;So in my opinion you need to clear an image float in text paragraphs more often than not :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&#8220;If you&#8217;ve ever floated an image next to a block of text, then you&#8217;ve witnessed an instance where you did not have to clear your floats.&#8221;</p>
<p>If your text content is dynamic and/or the width of the text column is dynamic, you cannot be sure the text will extend the height of the image without clearing the image float.<br />
If you want more than one image in the text paragraph, the same applies.</p>
<p>So in my opinion you need to clear an image float in text paragraphs more often than not <img src='http://www.pathf.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Belafonte</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-307</link>
		<dc:creator>Aaron Belafonte</dc:creator>
		<pubDate>Sun, 23 Sep 2007 18:35:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-307</guid>
		<description>&lt;p&gt;quote: "I can't think of a single time I've ever _not_ needed to clear my floats. Can you? Tell me in the comments."&lt;/p&gt;

&lt;p&gt;If you've ever floated an image next to a block of text, then you've witnessed an instance where you did not have to clear your floats.&lt;/p&gt;

&lt;p&gt;Remember, that's what the originally conceived context of floated elements was intended to address.&lt;/p&gt;

&lt;p&gt;see this article by eric meyer from 2003&lt;br /&gt;
www.complexspiral.com/publications/containing-floats&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>quote: &#8220;I can&#8217;t think of a single time I&#8217;ve ever _not_ needed to clear my floats. Can you? Tell me in the comments.&#8221;</p>
<p>If you&#8217;ve ever floated an image next to a block of text, then you&#8217;ve witnessed an instance where you did not have to clear your floats.</p>
<p>Remember, that&#8217;s what the originally conceived context of floated elements was intended to address.</p>
<p>see this article by eric meyer from 2003<br />
<a href="http://www.complexspiral.com/publications/containing-floats" rel="nofollow">http://www.complexspiral.com/publications/containing-floats</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marcos</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-306</link>
		<dc:creator>marcos</dc:creator>
		<pubDate>Sun, 23 Sep 2007 16:10:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-306</guid>
		<description>&lt;p&gt;Me thinks it's a very ugly solution when this is cleaner:&lt;/p&gt;

&lt;p&gt;#container {overflow:hidden;}&lt;/p&gt;

&lt;p&gt;that for 'real' browsers.&lt;/p&gt;

&lt;p&gt;Add zoom:1, _height:1%, width:(something) to trigger haslayout and you have it for ie6 and up (I usually have a separate stylesheet and conditional comments for that, so _height can be just height)&lt;/p&gt;

&lt;p&gt;Needless to say that if #container already has a width value due to it's own nature all the ie stuff is not needed.&lt;/p&gt;

&lt;p&gt;Cheers from Spain&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Me thinks it&#8217;s a very ugly solution when this is cleaner:</p>
<p>#container {overflow:hidden;}</p>
<p>that for &#8216;real&#8217; browsers.</p>
<p>Add zoom:1, _height:1%, width:(something) to trigger haslayout and you have it for ie6 and up (I usually have a separate stylesheet and conditional comments for that, so _height can be just height)</p>
<p>Needless to say that if #container already has a width value due to it&#8217;s own nature all the ie stuff is not needed.</p>
<p>Cheers from Spain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Francis</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-305</link>
		<dc:creator>Craig Francis</dc:creator>
		<pubDate>Sat, 22 Sep 2007 11:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-305</guid>
		<description>&lt;p&gt;I thought the method used now was:&lt;/p&gt;

&lt;p&gt;-----&lt;/p&gt;

&lt;p&gt;[div id="wrapper"]&lt;br /&gt;
[div id="nav"][/div]&lt;br /&gt;
[div id="content"][/div]&lt;br /&gt;
[/div]&lt;/p&gt;

&lt;p&gt;-----&lt;/p&gt;

&lt;p&gt;#nav,&lt;br /&gt;
#content {&lt;br /&gt;
float: left;&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;#wrapper {&lt;br /&gt;
overflow: auto; /* For FF, Safari, Opera, etc */&lt;br /&gt;
width: 100%; /* For IE5, IE5.5, IE6, IE7 */&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;-----&lt;/p&gt;

&lt;p&gt;The basis is that the "good" browsers use the overflow:auto to contain the floated elements... but for IE, we use one of its bugs, whereby it contains the child floats when it has a width set.&lt;/p&gt;

&lt;p&gt;I have seen two issues with this technique though...&lt;/p&gt;

&lt;p&gt;1) Sometimes the design does not allow the width to be 100%, px, em etc... for example if you have padding on the fixed width container, the width gets incorrectly calculated (box model issue).&lt;/p&gt;

&lt;p&gt;2) If you have a link right against the edge of the floated element, then when you select that link (click, or tab focus), in FireFox it can cause the overflow scrollbars to appear due to the "selected" border it uses... sometimes you can to add a 1px margin to the link, which creates a small space for that border to appear.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I thought the method used now was:</p>
<p>&#8212;&#8211;</p>
<p>[div id="wrapper"]<br />
[div id="nav"][/div]<br />
[div id="content"][/div]<br />
[/div]</p>
<p>&#8212;&#8211;</p>
<p>#nav,<br />
#content {<br />
float: left;<br />
}</p>
<p>#wrapper {<br />
overflow: auto; /* For FF, Safari, Opera, etc */<br />
width: 100%; /* For IE5, IE5.5, IE6, IE7 */<br />
}</p>
<p>&#8212;&#8211;</p>
<p>The basis is that the &#8220;good&#8221; browsers use the overflow:auto to contain the floated elements&#8230; but for IE, we use one of its bugs, whereby it contains the child floats when it has a width set.</p>
<p>I have seen two issues with this technique though&#8230;</p>
<p>1) Sometimes the design does not allow the width to be 100%, px, em etc&#8230; for example if you have padding on the fixed width container, the width gets incorrectly calculated (box model issue).</p>
<p>2) If you have a link right against the edge of the floated element, then when you select that link (click, or tab focus), in FireFox it can cause the overflow scrollbars to appear due to the &#8220;selected&#8221; border it uses&#8230; sometimes you can to add a 1px margin to the link, which creates a small space for that border to appear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Doherty</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-304</link>
		<dc:creator>Ryan Doherty</dc:creator>
		<pubDate>Sat, 22 Sep 2007 03:41:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-304</guid>
		<description>&lt;p&gt;Ugh, those declarations should be for the floated elements container, not the element itself.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Ugh, those declarations should be for the floated elements container, not the element itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Doherty</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-303</link>
		<dc:creator>Ryan Doherty</dc:creator>
		<pubDate>Sat, 22 Sep 2007 03:39:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-303</guid>
		<description>&lt;p&gt;What about using &lt;/p&gt;

&lt;p&gt;floatedElementClassName {&lt;br /&gt;
zoom:1; &lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;for IE (forces hasLayout property) and &lt;/p&gt;

&lt;p&gt;floatedElementClassName:after { &lt;br /&gt;
content:".";&lt;br /&gt;
display:block;&lt;br /&gt;
clear:both;&lt;br /&gt;
height:0;&lt;br /&gt;
width:0;&lt;br /&gt;
line-height:0;&lt;br /&gt;
visibility:hidden;&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;For Firefox, Opera and Safari.&lt;/p&gt;

&lt;p&gt;No extra code in your html and just 1 extra declaration in your css. Works quite well for me!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>What about using </p>
<p>floatedElementClassName {<br />
zoom:1; <br />
}</p>
<p>for IE (forces hasLayout property) and </p>
<p>floatedElementClassName:after { <br />
content:&#8221;.&#8221;;<br />
display:block;<br />
clear:both;<br />
height:0;<br />
width:0;<br />
line-height:0;<br />
visibility:hidden;<br />
}</p>
<p>For Firefox, Opera and Safari.</p>
<p>No extra code in your html and just 1 extra declaration in your css. Works quite well for me!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: T.J.</title>
		<link>http://www.pathf.com/blogs/2007/09/developers-note-2/#comment-302</link>
		<dc:creator>T.J.</dc:creator>
		<pubDate>Fri, 21 Sep 2007 20:00:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=243#comment-302</guid>
		<description>&lt;p&gt;I think that both of these methods for clearing floated divs is sloppy.  Whether in your HTML or CSS, your still going to have sloppy code in the end run.  I used to use the .clearfix method mentioned above in your article, but still ran into the problem of having to either add that style to multiple classes or to make some significant layout changes to the website (or use inline float-clearing objects).&lt;/p&gt;

&lt;p&gt;I know semantically speaking your not supposed to have any extra HTML than is required, as everyone says CSS.  Personally I now use an extra div around floated content with it's only style definition (in the CSS) being a padding declaration.&lt;/p&gt;

&lt;p&gt;At the end of the day, my divs can expand and contract at will with no overlap issues, my html and css validate, and I can go on with my life not having to google for that annoying IE clearfix hack.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I think that both of these methods for clearing floated divs is sloppy.  Whether in your HTML or CSS, your still going to have sloppy code in the end run.  I used to use the .clearfix method mentioned above in your article, but still ran into the problem of having to either add that style to multiple classes or to make some significant layout changes to the website (or use inline float-clearing objects).</p>
<p>I know semantically speaking your not supposed to have any extra HTML than is required, as everyone says CSS.  Personally I now use an extra div around floated content with it&#8217;s only style definition (in the CSS) being a padding declaration.</p>
<p>At the end of the day, my divs can expand and contract at will with no overlap issues, my html and css validate, and I can go on with my life not having to google for that annoying IE clearfix hack.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
