
<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why you should deeply nest your CSS selectors.</title>
	<atom:link href="http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 22 Jul 2010 13:27:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: robocat</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-86</link>
		<dc:creator>robocat</dc:creator>
		<pubDate>Wed, 10 Mar 2010 02:27:23 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-86</guid>
		<description>Cory - love the article.


To all the &quot;Use efficient CSS selectors&quot; optimisation gurus: Get a grip and concentrate your development time on areas that get good performance improvements. Does changing selectors actually make a noticable difference in page load? Are you pre-optimising code to get a negligible speedup? Does IE process selectors right to left? I would be loath to lose the advantages of tidy code for a change if it only gives an insignificant performance improvement.

The only relevant selector performance testing I have found so far is: http://www.stevesouders.com/blog/2009/03/10/performance-impact-of-css-selectors/ (and even that is not for a realistic page).</description>
		<content:encoded><![CDATA[<p>Cory &#8211; love the article.</p>
<p>To all the &#8220;Use efficient CSS selectors&#8221; optimisation gurus: Get a grip and concentrate your development time on areas that get good performance improvements. Does changing selectors actually make a noticable difference in page load? Are you pre-optimising code to get a negligible speedup? Does IE process selectors right to left? I would be loath to lose the advantages of tidy code for a change if it only gives an insignificant performance improvement.</p>
<p>The only relevant selector performance testing I have found so far is: <a href="http://www.stevesouders.com/blog/2009/03/10/performance-impact-of-css-selectors/" rel="nofollow">http://www.stevesouders.com/blog/2009/03/10/performance-impact-of-css-selectors/</a> (and even that is not for a realistic page).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cory Schires</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-73</link>
		<dc:creator>Cory Schires</dc:creator>
		<pubDate>Tue, 02 Mar 2010 21:22:55 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-73</guid>
		<description>Jin,

I agree. Of course, you wouldn&#039;t want to write duplicate selectors. It&#039;s not only bad for performance but also for code maintainability. In the example you described, I would abstract those rules out into a more general (more shallowly nested) selector. 

Just to be clear, I&#039;m not suggesting you deeply nest everything just for the sake of doing it. General rules &#8212; list-styles, basic typography, page structure &#8212; should not use deep selectors. 

The main benefit here is that you can quickly determine the specificity of a set of rules by glancing at the selector (i.e. shorter selectors indicate more general rules whereas longer selectors indicate more specific rules.) 

In other words, if you deeply nest things unnecessarily, it not only makes for bad code but also destroys the benefit of using the method in the first place.</description>
		<content:encoded><![CDATA[<p>Jin,</p>
<p>I agree. Of course, you wouldn&#8217;t want to write duplicate selectors. It&#8217;s not only bad for performance but also for code maintainability. In the example you described, I would abstract those rules out into a more general (more shallowly nested) selector. </p>
<p>Just to be clear, I&#8217;m not suggesting you deeply nest everything just for the sake of doing it. General rules &mdash; list-styles, basic typography, page structure &mdash; should not use deep selectors. </p>
<p>The main benefit here is that you can quickly determine the specificity of a set of rules by glancing at the selector (i.e. shorter selectors indicate more general rules whereas longer selectors indicate more specific rules.) </p>
<p>In other words, if you deeply nest things unnecessarily, it not only makes for bad code but also destroys the benefit of using the method in the first place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jin</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-72</link>
		<dc:creator>Jin</dc:creator>
		<pubDate>Tue, 02 Mar 2010 21:02:48 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-72</guid>
		<description>it&#039;s not always practical. you may find yourself creating duplicating custom classes in practice. 

for example, what if you need another class that has the exact same styling as 

#our_team .employee { width: 230px; height: 65px; float: left; }

but inside of another parent id called &quot;#their_team ?&quot;

do you create another whole nested classes for &quot;#their_team?&quot;</description>
		<content:encoded><![CDATA[<p>it&#8217;s not always practical. you may find yourself creating duplicating custom classes in practice. </p>
<p>for example, what if you need another class that has the exact same styling as </p>
<p>#our_team .employee { width: 230px; height: 65px; float: left; }</p>
<p>but inside of another parent id called &#8220;#their_team ?&#8221;</p>
<p>do you create another whole nested classes for &#8220;#their_team?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cory Schires</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-69</link>
		<dc:creator>Cory Schires</dc:creator>
		<pubDate>Sat, 27 Feb 2010 01:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-69</guid>
		<description>Federico:

Yes. Most browsers do render deeply nested selectors more slowly. The reason is simple enough. Time is wasted reading through superfluous selectors before getting to the last few relevant selectors. But how much does this matter?

Well, it depends on your preference. I really like the flexibility and modularity that comes with deep nesting, and I&#039;m willing to trade a small amount of performance for those gains. But if you&#039;re a geek for optimization, on the other hand, then this method is probably not for you.

That said, I think developers should be careful about optimizing performance to absurd extremes. There are plenty of other factors that go into writing good code - stability, clarity, flexibility, etc. And often these other factors come only at the price of speed. 

For example, would you write a web application in C? Of course not. You&#039;d use a higher level language, like Java or Ruby. No one cares that C is about four times faster than Ruby or Java. We&#039;re happy to trade performance for the many benefits of developing in a higher level language.

It&#039;s simplistic to think about speed as the ultimate measure of good code. It&#039;s much better to think of it like a currency. Speed is useful because we can choose to trade it for other gains - tightened security, new features, usability, etc.</description>
		<content:encoded><![CDATA[<p>Federico:</p>
<p>Yes. Most browsers do render deeply nested selectors more slowly. The reason is simple enough. Time is wasted reading through superfluous selectors before getting to the last few relevant selectors. But how much does this matter?</p>
<p>Well, it depends on your preference. I really like the flexibility and modularity that comes with deep nesting, and I&#8217;m willing to trade a small amount of performance for those gains. But if you&#8217;re a geek for optimization, on the other hand, then this method is probably not for you.</p>
<p>That said, I think developers should be careful about optimizing performance to absurd extremes. There are plenty of other factors that go into writing good code &#8211; stability, clarity, flexibility, etc. And often these other factors come only at the price of speed. </p>
<p>For example, would you write a web application in C? Of course not. You&#8217;d use a higher level language, like Java or Ruby. No one cares that C is about four times faster than Ruby or Java. We&#8217;re happy to trade performance for the many benefits of developing in a higher level language.</p>
<p>It&#8217;s simplistic to think about speed as the ultimate measure of good code. It&#8217;s much better to think of it like a currency. Speed is useful because we can choose to trade it for other gains &#8211; tightened security, new features, usability, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-68</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Fri, 26 Feb 2010 12:17:49 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-68</guid>
		<description>I use deeply nested css selector quite often, but the speed test for firefox says that this rules are inefficent and should be shorter.
any thoughts?</description>
		<content:encoded><![CDATA[<p>I use deeply nested css selector quite often, but the speed test for firefox says that this rules are inefficent and should be shorter.<br />
any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cedric Dugas</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-67</link>
		<dc:creator>Cedric Dugas</dc:creator>
		<pubDate>Thu, 25 Feb 2010 13:51:59 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-67</guid>
		<description>I am also a fan of CSS deep linking,

I wonder what you think of indenting your css file? it help a lot for readability.</description>
		<content:encoded><![CDATA[<p>I am also a fan of CSS deep linking,</p>
<p>I wonder what you think of indenting your css file? it help a lot for readability.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gaspard</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-65</link>
		<dc:creator>gaspard</dc:creator>
		<pubDate>Tue, 23 Feb 2010 09:24:27 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-65</guid>
		<description>On other hand, you could think css in an object oriented way : making them reusable in different contexts and build a lighter code. Nicole Sullivan&#039;s initiative named OOCSS ( http://oocss.org/ ) is a good sample.</description>
		<content:encoded><![CDATA[<p>On other hand, you could think css in an object oriented way : making them reusable in different contexts and build a lighter code. Nicole Sullivan&#8217;s initiative named OOCSS ( <a href="http://oocss.org/" rel="nofollow">http://oocss.org/</a> ) is a good sample.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zolotoy</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-64</link>
		<dc:creator>zolotoy</dc:creator>
		<pubDate>Tue, 23 Feb 2010 06:52:06 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-64</guid>
		<description>Deeply nested CSS selectors is bad for rendering process in browser.</description>
		<content:encoded><![CDATA[<p>Deeply nested CSS selectors is bad for rendering process in browser.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Name</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-63</link>
		<dc:creator>Name</dc:creator>
		<pubDate>Tue, 23 Feb 2010 01:30:16 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-63</guid>
		<description>I used to code this way, but sometimes it becomes less maintenable when you use really deep nesting, unless you actually need it so rules aren&#039;t overrided.

I think that if a class exists and it&#039;s used only once within a containing div, just use the containing div and and that class.

Also a good example is for lists. Instead of doing this:
&lt;code&gt;
ul li a { styles... }
&lt;/code&gt;
It&#039;s better to do this:
&lt;code&gt;
ul a { styles... }
&lt;/code&gt;

That is, if only one link type exists in that list. Otherwise use classes, and use the same technique.</description>
		<content:encoded><![CDATA[<p>I used to code this way, but sometimes it becomes less maintenable when you use really deep nesting, unless you actually need it so rules aren&#8217;t overrided.</p>
<p>I think that if a class exists and it&#8217;s used only once within a containing div, just use the containing div and and that class.</p>
<p>Also a good example is for lists. Instead of doing this:<br />
<code><br />
ul li a { styles... }<br />
</code><br />
It&#8217;s better to do this:<br />
<code><br />
ul a { styles... }<br />
</code></p>
<p>That is, if only one link type exists in that list. Otherwise use classes, and use the same technique.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Powell</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-61</link>
		<dc:creator>Andrew Powell</dc:creator>
		<pubDate>Mon, 22 Feb 2010 21:36:11 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-61</guid>
		<description>What the article doesn&#039;t point out, is that deeply nested css should be used only after shallow css has been used to define the base/shared/common properties for page elements. Deeply nested rules can then be applied to affect and target specific elements. It has to be used responsibly, or the performance concerns raised will be an issue.

It does, without a doubt, lend more to readability and maintainability than development with only shallow css. Despite Sara W&#039;s comments, a 500 ms gain in rendering time, for example, does not usually win out over the time and cost of development with poorly structured and/or poorly organized css.

I demand excellent organization in all facets of development from my developers, and the combination of shallow + deep nesting is a fantastic technique.</description>
		<content:encoded><![CDATA[<p>What the article doesn&#8217;t point out, is that deeply nested css should be used only after shallow css has been used to define the base/shared/common properties for page elements. Deeply nested rules can then be applied to affect and target specific elements. It has to be used responsibly, or the performance concerns raised will be an issue.</p>
<p>It does, without a doubt, lend more to readability and maintainability than development with only shallow css. Despite Sara W&#8217;s comments, a 500 ms gain in rendering time, for example, does not usually win out over the time and cost of development with poorly structured and/or poorly organized css.</p>
<p>I demand excellent organization in all facets of development from my developers, and the combination of shallow + deep nesting is a fantastic technique.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
