
<?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, 19 Jan 2012 06:08:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Cory Schires</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-3223</link>
		<dc:creator>Cory Schires</dc:creator>
		<pubDate>Fri, 29 Jul 2011 15:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-3223</guid>
		<description>@georgi

Check out the previous comments. There&#039;s been quite a bit of debate about this. There&#039;s definitely more to writing quality code than pure performance. For example, we use high level languages – like Ruby and even PHP – rather than something like C which would be about 4X faster. In doing so, we trade performance for a more flexible, maintainable code base. 

Deep nesting is a good idea for these same reasons. You&#039;re trading performance for maintainability. That said, I obviously recommend combining/minifying your assets in production, especially if performance is a pressing concern.</description>
		<content:encoded><![CDATA[<p>@georgi</p>
<p>Check out the previous comments. There&#8217;s been quite a bit of debate about this. There&#8217;s definitely more to writing quality code than pure performance. For example, we use high level languages – like Ruby and even PHP – rather than something like C which would be about 4X faster. In doing so, we trade performance for a more flexible, maintainable code base. </p>
<p>Deep nesting is a good idea for these same reasons. You&#8217;re trading performance for maintainability. That said, I obviously recommend combining/minifying your assets in production, especially if performance is a pressing concern.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: georgi</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-3222</link>
		<dc:creator>georgi</dc:creator>
		<pubDate>Fri, 29 Jul 2011 08:15:30 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-3222</guid>
		<description>This article is absolute wrong and has nothing true in it. You can read google guidelines and you will see that you should not use deep nesting. Use as least as possible parent selectors for best performance.</description>
		<content:encoded><![CDATA[<p>This article is absolute wrong and has nothing true in it. You can read google guidelines and you will see that you should not use deep nesting. Use as least as possible parent selectors for best performance.</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-1341</link>
		<dc:creator>Cory Schires</dc:creator>
		<pubDate>Sun, 06 Mar 2011 22:50:23 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-1341</guid>
		<description>@Andy

The depth of your selectors is not going to cause a significant difference in your page load. That&#039;s just nonsense. Nest as deeply as you like.

But using @import too much could make a difference since it increases the number of http requests. So, if you&#039;re really looking to optimize, you might want to steer clear of @import altogether.

Overall though, I would suggest using something like &lt;a href=&quot;http://lesscss.org/&quot; title=&quot;LESS &#171; The Dynamic Stylesheet language&quot; rel=&quot;nofollow&quot;&gt;LESS&lt;/a&gt; or &lt;a href=&quot;http://sass-lang.com/&quot; title=&quot;Sass - Syntactically Awesome Stylesheets&quot; rel=&quot;nofollow&quot;&gt;SASS&lt;/a&gt; to dynamically compile your stylesheets. This lets you have the best of both worlds: You can deeply nest and modularize using @import while still loading all your stylesheets with a single http request.</description>
		<content:encoded><![CDATA[<p>@Andy</p>
<p>The depth of your selectors is not going to cause a significant difference in your page load. That&#8217;s just nonsense. Nest as deeply as you like.</p>
<p>But using @import too much could make a difference since it increases the number of http requests. So, if you&#8217;re really looking to optimize, you might want to steer clear of @import altogether.</p>
<p>Overall though, I would suggest using something like <a href="http://lesscss.org/" title="LESS &laquo; The Dynamic Stylesheet language" rel="nofollow">LESS</a> or <a href="http://sass-lang.com/" title="Sass - Syntactically Awesome Stylesheets" rel="nofollow">SASS</a> to dynamically compile your stylesheets. This lets you have the best of both worlds: You can deeply nest and modularize using @import while still loading all your stylesheets with a single http request.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-1338</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Sun, 06 Mar 2011 21:03:11 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-1338</guid>
		<description>Very interesting read and some good points... I am a big fan of using deep selectors and found this article after realising the need to improve page load speeds of my CSS. Having read this article there seems to be plus and minus points for both arguments. Personally I&#039;ll be trying to cut down on my selectors whilst still trying to maintain some meaning to my CSS. Would be interested to know how much difference minifying a style sheet with a lot deep selectors would make?</description>
		<content:encoded><![CDATA[<p>Very interesting read and some good points&#8230; I am a big fan of using deep selectors and found this article after realising the need to improve page load speeds of my CSS. Having read this article there seems to be plus and minus points for both arguments. Personally I&#8217;ll be trying to cut down on my selectors whilst still trying to maintain some meaning to my CSS. Would be interested to know how much difference minifying a style sheet with a lot deep selectors would make?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-467</link>
		<dc:creator>jeff</dc:creator>
		<pubDate>Thu, 16 Sep 2010 12:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-467</guid>
		<description>Ok,

But according to your example, when would you use .employee, more then once?

Should&#039;nt that also be an ID as well? 

It is just a content container, just like #our_team.</description>
		<content:encoded><![CDATA[<p>Ok,</p>
<p>But according to your example, when would you use .employee, more then once?</p>
<p>Should&#8217;nt that also be an ID as well? </p>
<p>It is just a content container, just like #our_team.</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-459</link>
		<dc:creator>Cory Schires</dc:creator>
		<pubDate>Tue, 14 Sep 2010 19:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-459</guid>
		<description>As far as I know, there is no best practice suggesting that ids should only be used for layouts and classes only for content. Rather, the important difference is that ids should always be unique (only used once on a page) whereas classes may be reused. 

Also, reusing ids can sometimes cause javascript errors.</description>
		<content:encoded><![CDATA[<p>As far as I know, there is no best practice suggesting that ids should only be used for layouts and classes only for content. Rather, the important difference is that ids should always be unique (only used once on a page) whereas classes may be reused. </p>
<p>Also, reusing ids can sometimes cause javascript errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff</title>
		<link>http://coryschires.com/why-you-should-deeply-nest-your-css-selectors/comment-page-1/#comment-455</link>
		<dc:creator>jeff</dc:creator>
		<pubDate>Tue, 14 Sep 2010 16:14:51 +0000</pubDate>
		<guid isPermaLink="false">http://coryschires.com/?p=276#comment-455</guid>
		<description>I was curious why you use classes and id&#039;s for layouts. I was always told to use only ids. I&#039;m not saying your wrong, infact I have used your way numerous times, but I&#039;d like to know why.

Generally, do you use id&#039;s for the basic elements (container, nav, content, footer)
Then classes for the placement/style of internal elements? (photos, text, etc)

I understand if you used all id&#039;s you wouldn&#039;t be able to nest your styles the way you did, but is there another reason?</description>
		<content:encoded><![CDATA[<p>I was curious why you use classes and id&#8217;s for layouts. I was always told to use only ids. I&#8217;m not saying your wrong, infact I have used your way numerous times, but I&#8217;d like to know why.</p>
<p>Generally, do you use id&#8217;s for the basic elements (container, nav, content, footer)<br />
Then classes for the placement/style of internal elements? (photos, text, etc)</p>
<p>I understand if you used all id&#8217;s you wouldn&#8217;t be able to nest your styles the way you did, but is there another reason?</p>
]]></content:encoded>
	</item>
	<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>
</channel>
</rss>

