<?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: CSS3 Feedback: Selector Blocks</title>
	<atom:link href="http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/feed/" rel="self" type="application/rss+xml" />
	<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/</link>
	<description>Things that Eric A. Meyer, CSS expert, writes about on his personal Web site; it&#039;s largely Web standards and Web technology, but also various bits of culture, politics, personal observations, and other miscellaneous stuff</description>
	<lastBuildDate>Wed, 17 Mar 2010 18:47:03 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Erling Ormar Vignisson</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-468651</link>
		<dc:creator>Erling Ormar Vignisson</dc:creator>
		<pubDate>Mon, 29 Jun 2009 14:00:55 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-468651</guid>
		<description>Hey Erice - care to print this out and fax it to the W3C? Surely, they have a fax machine by now ;-)

http://lesscss.org/</description>
		<content:encoded><![CDATA[<p>Hey Erice &#8211; care to print this out and fax it to the W3C? Surely, they have a fax machine by now ;-)</p>
<p><a href="http://lesscss.org/" rel="nofollow">http://lesscss.org/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-447218</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Wed, 11 Mar 2009 09:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-447218</guid>
		<description>I would have loved to have this when we redesigned our company website – we had a handful of colors that are randomly used on each page, and if you add page specific styles on top of that you end up with a loooot of different color + page + container + element scenarios that turned into pages of repeating CSS rules.

Instead of having to handle one huge unruly CSS file I sprinkled some utility classes in my templates instead. Presentational hooks, but what can you do? Ease of maintenance was more important.

And yes, I know I&#039;m late to join the party :)</description>
		<content:encoded><![CDATA[<p>I would have loved to have this when we redesigned our company website – we had a handful of colors that are randomly used on each page, and if you add page specific styles on top of that you end up with a loooot of different color + page + container + element scenarios that turned into pages of repeating CSS rules.</p>
<p>Instead of having to handle one huge unruly CSS file I sprinkled some utility classes in my templates instead. Presentational hooks, but what can you do? Ease of maintenance was more important.</p>
<p>And yes, I know I&#8217;m late to join the party :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arpan</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-444108</link>
		<dc:creator>Arpan</dc:creator>
		<pubDate>Fri, 20 Feb 2009 20:01:03 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-444108</guid>
		<description>Here&#039;s an idea, how about we use a pre-processor in addition to adding support for the new CSS syntax.

example:
link rel=sass href=layout.sass
link rel=stylesheet href=layout.css

The layout.css would be generated from the layout.sass and used by current browsers. Newer browsers that can handle SASS, when they came across sites with SASS would use that file and disregard the css file.

This way, the new syntax gets standardised instead of 10 different preprecessors, and we can start using it immediately, and don&#039;t have to wait all browsers catch up.

Advantage for us (designers &amp; developers), we get something standardized that we can start using right away, that will save time and make maintenance so much easier.

Advantage for users, smaller files.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s an idea, how about we use a pre-processor in addition to adding support for the new CSS syntax.</p>
<p>example:<br />
link rel=sass href=layout.sass<br />
link rel=stylesheet href=layout.css</p>
<p>The layout.css would be generated from the layout.sass and used by current browsers. Newer browsers that can handle SASS, when they came across sites with SASS would use that file and disregard the css file.</p>
<p>This way, the new syntax gets standardised instead of 10 different preprecessors, and we can start using it immediately, and don&#8217;t have to wait all browsers catch up.</p>
<p>Advantage for us (designers &amp; developers), we get something standardized that we can start using right away, that will save time and make maintenance so much easier.</p>
<p>Advantage for users, smaller files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Hollis</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443608</link>
		<dc:creator>Ben Hollis</dc:creator>
		<pubDate>Wed, 18 Feb 2009 05:59:55 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443608</guid>
		<description>As others have mentioned, SASS supports something very similar to this, and ever since I&#039;ve switched to using it I&#039;ve noticed a large increase in my productivity in creating complex, manageable styles. What&#039;s best is that with this feature, CSS becomes much more refactor-able - you can move blocks around or re-parent them with very little effort. Knocking out the redundancy is key in that situation. Honestly, there are projects I&#039;ve worked on where having this one feature has saved huge amounts of time and made the stylesheets immensely easier to read. 

SASS also adds a nice bit, the &quot;&amp;&quot; symbol, which lets you reference the parent selector when defining inner selectors, which can be useful for things like pseudo-selectors and browser-specific scoping:
&lt;code&gt;
#content {
&#160;&#160;width: 30px;
&#160;&#160;.msie &amp; {
&#160;&#160;&#160;&#160;width: 35px;
&#160;&#160;}
&#160;&#160;&amp;:hover {
&#160;&#160;&#160;&#160;color: blue;
&#160;&#160;}
}
&lt;/code&gt;
expands to:
&lt;code&gt;
#content {
&#160;&#160;width: 30px;
}
.msie #content {
&#160;&#160;width: 35px;
}
#content:hover {
&#160;&#160;color: blue;
}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>As others have mentioned, SASS supports something very similar to this, and ever since I&#8217;ve switched to using it I&#8217;ve noticed a large increase in my productivity in creating complex, manageable styles. What&#8217;s best is that with this feature, CSS becomes much more refactor-able &#8211; you can move blocks around or re-parent them with very little effort. Knocking out the redundancy is key in that situation. Honestly, there are projects I&#8217;ve worked on where having this one feature has saved huge amounts of time and made the stylesheets immensely easier to read. </p>
<p>SASS also adds a nice bit, the &#8220;&amp;&#8221; symbol, which lets you reference the parent selector when defining inner selectors, which can be useful for things like pseudo-selectors and browser-specific scoping:<br />
<code><br />
#content {<br />
&nbsp;&nbsp;width: 30px;<br />
&nbsp;&nbsp;.msie &amp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;width: 35px;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&amp;:hover {<br />
&nbsp;&nbsp;&nbsp;&nbsp;color: blue;<br />
&nbsp;&nbsp;}<br />
}<br />
</code><br />
expands to:<br />
<code><br />
#content {<br />
&nbsp;&nbsp;width: 30px;<br />
}<br />
.msie #content {<br />
&nbsp;&nbsp;width: 35px;<br />
}<br />
#content:hover {<br />
&nbsp;&nbsp;color: blue;<br />
}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Tallyce</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443320</link>
		<dc:creator>Thomas Tallyce</dc:creator>
		<pubDate>Tue, 17 Feb 2009 14:18:46 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443320</guid>
		<description>Real shame about the inability to implement parent selectors. The classic use case is indeed images that have a link round them, but you don&#039;t want underlining.

Perhaps Eric&#039;s proposal for any-element linking would remove that use case?</description>
		<content:encoded><![CDATA[<p>Real shame about the inability to implement parent selectors. The classic use case is indeed images that have a link round them, but you don&#8217;t want underlining.</p>
<p>Perhaps Eric&#8217;s proposal for any-element linking would remove that use case?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Design - standards based web design, development and training &#187; Some links for light reading (17/2/09)</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443277</link>
		<dc:creator>Max Design - standards based web design, development and training &#187; Some links for light reading (17/2/09)</dc:creator>
		<pubDate>Tue, 17 Feb 2009 08:00:12 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443277</guid>
		<description>[...] Eric&#8217;s Archived Thoughts: CSS3 Feedback: Selector Blocks [...]</description>
		<content:encoded><![CDATA[<p>[...] Eric&#8217;s Archived Thoughts: CSS3 Feedback: Selector Blocks [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Penney</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443219</link>
		<dc:creator>Jason Penney</dc:creator>
		<pubDate>Mon, 16 Feb 2009 19:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443219</guid>
		<description>I sometimes have to work with third party controls that inject their own styles, but don&#039;t take enough care to make sure they aren&#039;t inheriting something that will cause the whole thing to fall apart.

More then once I&#039;ve copied the entire contents of reset.css and replaced each selector with some prefix rule, and I really like the idea of being able to do:

&lt;code&gt;#someContainer {@import url(reset.css);}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I sometimes have to work with third party controls that inject their own styles, but don&#8217;t take enough care to make sure they aren&#8217;t inheriting something that will cause the whole thing to fall apart.</p>
<p>More then once I&#8217;ve copied the entire contents of reset.css and replaced each selector with some prefix rule, and I really like the idea of being able to do:</p>
<p><code>#someContainer {@import url(reset.css);}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Howard</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443210</link>
		<dc:creator>Stephen Howard</dc:creator>
		<pubDate>Mon, 16 Feb 2009 18:12:29 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443210</guid>
		<description>Just to clarify, when I mentioned preprocessing it was because I wish CSS did this natively, and I was just looking to do it for myself as I didn&#039;t know if it would ever happen in the standard.  The less preprocessing the better, I think.</description>
		<content:encoded><![CDATA[<p>Just to clarify, when I mentioned preprocessing it was because I wish CSS did this natively, and I was just looking to do it for myself as I didn&#8217;t know if it would ever happen in the standard.  The less preprocessing the better, I think.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Mogensen</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443187</link>
		<dc:creator>Erik Mogensen</dc:creator>
		<pubDate>Mon, 16 Feb 2009 14:23:44 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443187</guid>
		<description>Wirh regard to descendant selectors, I would build on today&#039;s selector syntax:

&lt;code&gt;
body.home #content &gt; .entry &gt; {
 h1, h2, h3, h4, h5, h6 {...}
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Wirh regard to descendant selectors, I would build on today&#8217;s selector syntax:</p>
<p><code><br />
body.home #content &gt; .entry &gt; {<br />
 h1, h2, h3, h4, h5, h6 {...}<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Wright</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443024</link>
		<dc:creator>Tim Wright</dc:creator>
		<pubDate>Sun, 15 Feb 2009 16:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443024</guid>
		<description>I&#039;m actually not a fan of nesting CSS like that. It doesn&#039;t seem like it would advance CSS at all, just bring up more arguments about structure. 

I&#039;d really rather see CSS variables implemented.</description>
		<content:encoded><![CDATA[<p>I&#8217;m actually not a fan of nesting CSS like that. It doesn&#8217;t seem like it would advance CSS at all, just bring up more arguments about structure. </p>
<p>I&#8217;d really rather see CSS variables implemented.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jemaleddin</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-443023</link>
		<dc:creator>Jemaleddin</dc:creator>
		<pubDate>Sun, 15 Feb 2009 16:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-443023</guid>
		<description>Another nice thing would be to take thinks like blueprint classes and equate them to a single class:

#headline { .span-12, .prepend-5, .append-7, .last, .column }

Semantics + grid = awesome.</description>
		<content:encoded><![CDATA[<p>Another nice thing would be to take thinks like blueprint classes and equate them to a single class:</p>
<p>#headline { .span-12, .prepend-5, .append-7, .last, .column }</p>
<p>Semantics + grid = awesome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-442569</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Fri, 13 Feb 2009 15:55:27 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-442569</guid>
		<description>The comments feed comes up empty for me, btw ...</description>
		<content:encoded><![CDATA[<p>The comments feed comes up empty for me, btw &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Johnson</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-442553</link>
		<dc:creator>Michael Johnson</dc:creator>
		<pubDate>Fri, 13 Feb 2009 14:53:01 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-442553</guid>
		<description>&lt;a href=&quot;http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/?#comment-442412&quot; rel=&quot;nofollow&quot;&gt;Steven&lt;/a&gt;, I don&#039;t have time to do it right now, but I&#039;ll try to work on the Dojo Soria stylesheet tonight. That&#039;s 350 rules in 1474 lines and about 41KB.

But you may be right about the gzip compression. The soria.css file compresses to 6536 bytes from 41374 bytes uncompressed, for 84% compression rate. However, I still perfer the grouping from a readability/maintainability standpoint.</description>
		<content:encoded><![CDATA[<p><a href="http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/?#comment-442412" rel="nofollow">Steven</a>, I don&#8217;t have time to do it right now, but I&#8217;ll try to work on the Dojo Soria stylesheet tonight. That&#8217;s 350 rules in 1474 lines and about 41KB.</p>
<p>But you may be right about the gzip compression. The soria.css file compresses to 6536 bytes from 41374 bytes uncompressed, for 84% compression rate. However, I still perfer the grouping from a readability/maintainability standpoint.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bertilo Wennergren</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-442537</link>
		<dc:creator>Bertilo Wennergren</dc:creator>
		<pubDate>Fri, 13 Feb 2009 14:15:25 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-442537</guid>
		<description>I agree with Eric that the HTML 5 scooped style element seems like a bad idea.

The thing that struck me about it, is that it would work (somewhat) well only for styles that are scooped for certain unique elements. It could do the equivalent of this:


@with #mydiv {
  .this { ... }
  .that { ... }
}


But it could not do anything like this:


@with .mykindofdiv {
  .this { ... }
  .that { ... }
}


You&#039;d have to add a scooped style element to every single div with the class &quot;mykindofdiv&quot;. That kind of repetition is not the right thing to do.</description>
		<content:encoded><![CDATA[<p>I agree with Eric that the HTML 5 scooped style element seems like a bad idea.</p>
<p>The thing that struck me about it, is that it would work (somewhat) well only for styles that are scooped for certain unique elements. It could do the equivalent of this:</p>
<p>@with #mydiv {<br />
  .this { &#8230; }<br />
  .that { &#8230; }<br />
}</p>
<p>But it could not do anything like this:</p>
<p>@with .mykindofdiv {<br />
  .this { &#8230; }<br />
  .that { &#8230; }<br />
}</p>
<p>You&#8217;d have to add a scooped style element to every single div with the class &#8220;mykindofdiv&#8221;. That kind of repetition is not the right thing to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Meyer</title>
		<link>http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-442529</link>
		<dc:creator>Eric Meyer</dc:creator>
		<pubDate>Fri, 13 Feb 2009 13:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://meyerweb.com/?p=1034#comment-442529</guid>
		<description>&lt;a href=&quot;http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-442323&quot; rel=&quot;nofollow&quot;&gt;Lachlan&lt;/a&gt;, so far as I can tell, that exact same capability exists in the CSS style-attribute module to which I linked, and it has for almost seven years now.  What&#039;s the rationale for adding brand-new element capabilities to HTML 5 in this circumstance, when the same thing could be done more cleanly through CSS alone?</description>
		<content:encoded><![CDATA[<p><a href="http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comment-442323" rel="nofollow">Lachlan</a>, so far as I can tell, that exact same capability exists in the CSS style-attribute module to which I linked, and it has for almost seven years now.  What&#8217;s the rationale for adding brand-new element capabilities to HTML 5 in this circumstance, when the same thing could be done more cleanly through CSS alone?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head profile="http://gmpg.org/xfn/1">
<title>meyerweb.com</title>
<link rel="openid.server" href="http://www.myopenid.com/server">
<link rel="openid.delegate" href="http://emeyer.myopenid.com/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link rel="shortcut icon" href="/favicon.ico"><link rel="home" href="http://meyerweb.com/" title="Home" ><link rel="stylesheet" href="http://meyerweb.com/ui/meyerweb.css" type="text/css" media="screen, projection"><link rel="stylesheet" href="http://meyerweb.com/ui/theme.css" type="text/css" media="screen, projection" id="themeLink"><link rel="stylesheet" href="http://meyerweb.com/ui/print.css" type="text/css" media="print"><script src="http://meyerweb.com/ui/addresses.js" type="text/javascript"></script><link rel="stylesheet" href="/ui/wordpress.css" type="text/css" media="screen">
<link rel="stylesheet" href="/ui/tfe.css" type="text/css" media="screen">
<link rel="stylesheet" href="/ui/home.css" type="text/css" media="screen">
<link rel="alternate" type="application/rss+xml" title="Thoughts From Eric" href="/eric/thoughts/rss2/full" />
<link rel="alternate" type="application/rss+xml" title="Thoughts From Eric (only technical posts)" href="/eric/thoughts/category/tech/rss2/full" />
<link rel="alternate" type="application/rss+xml" title="Thoughts From Eric (only personal posts)" href="/eric/thoughts/category/personal/rss2/full" />
<link rel="alternate" type="application/rss+xml" title="Distractions" href="/eric/thoughts/recent-links/rss2" />
<link rel="alternate" type="application/rss+xml" title="Excuse of the Day" href="/feeds/excuse/rss20.xml" />
</head>
<body id="www-meyerweb-com" class="hpg">

<div id="sitemast"><h1><a href="/"><span>meyerweb</span>.com</a></h1></div><div id="search"><h4>Exploration</h4><!-- SiteSearch Google --><form method="get" action="http://www.google.com/custom" target="_top"><div><input type="hidden" name="domains" value="meyerweb.com"></input><label for="sbb" style="display: none">Submit search form</label><input type="submit" name="sa" value="Google Search" id="sbb"></input><label for="sbi" style="display: none">Enter your search terms</label><input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input><p><input type="radio" name="sitesearch" value="meyerweb.com" checked id="ss1"></input><label for="ss1" title="Search meyerweb.com">meyerweb.com</label><input type="radio" name="sitesearch" value="" id="ss0"></input><label for="ss0" title="Search the Web">Web</label></p><input type="hidden" name="client" value="pub-3772084027748653"></input><input type="hidden" name="forid" value="1"></input><input type="hidden" name="ie" value="ISO-8859-1"></input><input type="hidden" name="oe" value="ISO-8859-1"></input><input type="hidden" name="safe" value="active"></input><input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input><input type="hidden" name="hl" value="en"></input></div></form><!-- SiteSearch Google --><!-- <form method="get" action="http://www.google.com/custom"><div><input type="submit" name="sa" value="Search"><input type="text" name="q" size="20" maxlength="255" value=""><input type="hidden" name="sitesearch" value="meyerweb.com"></div></form><small><a href="http://www.google.com/search">Powered by Google</a></small> --></div><div id="main"><div class="skipper">Skip to: <a href="#extra">site navigation/presentation</a></div><div class="skipper">Skip to: <a href="#thoughts">Thoughts From Eric</a></div>
<div id="thoughts">


<div class="entry">
<h3><a href="http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/" rel="bookmark" title="Permanent Link: CSS3 Feedback: Selector Blocks">CSS3 Feedback: Selector Blocks</a></h3>
<ul class="meta">
<li class="date">Thu 12 Feb 2009</li>
<li class="time">1037</li>
<li class="cat"><a href="http://meyerweb.com/eric/thoughts/category/tech/css/" title="View all posts in CSS" rel="category tag">CSS</a><br> <a href="http://meyerweb.com/eric/thoughts/category/commentary/" title="View all posts in Commentary" rel="category tag">Commentary</a><br> <a href="http://meyerweb.com/eric/thoughts/category/tech/standards/" title="View all posts in Standards" rel="category tag">Standards</a><br> <a href="http://meyerweb.com/eric/thoughts/category/tech/w3c/" title="View all posts in W3C" rel="category tag">W3C</a><br> <a href="http://meyerweb.com/eric/thoughts/category/tech/web/" title="View all posts in Web" rel="category tag">Web</a></li>
<li class="cmt"><a href="http://meyerweb.com/eric/thoughts/2009/02/12/selector-blocks/#comments">38 responses</a></li>
<li></li><li></li></ul>

<div class="text">
<p class="aside">(This is part of the <a href="http://meyerweb.com/eric/thoughts/2009/02/11/feedback-on-wasp-community-css3-feedback-2008/">Feedback on &#8216;WaSP Community CSS3 Feedback 2008&#8242;</a> series.)</p>
<p>
Out of all the <a href="http://fantasai.inkedblade.net/style/discuss/wasp-feedback-2008#selectors">selector feedback</a>, <a href="http://fantasai.inkedblade.net/style/discuss/wasp-feedback-2008#nested-selectors">selector blocks</a> was the part that really caught my attention.  I also see the usefulness of a <a href="http://fantasai.inkedblade.net/style/discuss/wasp-feedback-2008#parent-selector">parent selector</a>, but that one has come up many times before, and it&#8217;s always died at the doorstep of implementors, who point out that it&#8217;s far too difficult to implement without serious performance penalties and even risk of browser lockup.  See, for example, <a href="http://shauninman.com/archive/2008/05/05/css_qualified_selectors#comment_3942">the comment left by David Hyatt</a> on <a href="http://shauninman.com/archive/2008/05/05/css_qualified_selectors">Shaun Inman&#8217;s post</a> on the idea.  Similarly, I think <a href="http://fantasai.inkedblade.net/style/discuss/wasp-feedback-2008#contants">constants</a> (or macros or whatever they&#8217;re called) are a great idea and would be very helpful, especially if you&#8217;re coding up a <a href="http://jasonsantamaria.com/" rel="friend colleague met">Jason</a> Special.  Both are loaded with use cases, so I don&#8217;t feel like I can add a lot; besides, constants are already in the WG charter, so there&#8217;s once more hope in the land.
</p>
<p>
So anyway, selector blocks.  To pick one recent example, while working on a project that should very soon see the light of day, I had a situation involving the following chunk of rules.
</p>

<pre>h1, h2, h3, h4, h5, h6, table {
   font: 1em Arial, "Helvetica Neue", Helvetica, sans-serif;}
h1 {font-size: 275%;}
h3:first-child {margin-top: 1em;}
p.tagline {margin: -0.25em 0 1.25em;
   font-size: 125%;
   color: #7B7960;}
h3 {margin: 1.5em 0 0.25em; font-size: 125%;}
h3:before {font-size: 75%; counter-increment: subhead;}
h4 {margin: 2.5em 0 0.75em;
   text-transform: uppercase; font-size: 125%;
   color: #928F59;}
p {margin: 0 0 1em;}
ul {padding-left: 1.5em;}
ul li {list-style: disc; margin: 0.5em 0;}
</pre>

<p>
Nothing unusual about them, of course, unless you count my use of counters.  These rules had been written early on in development, and the design had evolved around that part of the document.  As more page components were added, I realized that I needed to scope all these rules to one section of the document: specifically, a <code>div</code> with a <code>class</code> of <code>main</code>.  So here&#8217;s what I had to do.
</p>

<pre>.main h1, .main h2, .main h3, .main h4, 
.main h5, .main h6, .main table {
   font: 1em Arial, "Helvetica Neue", Helvetica, sans-serif;}
.main h1 {font-size: 275%;}
.main h3:first-child {margin-top: 1em;}
.main p.tagline {margin: -0.25em 0 1.25em;
   font-size: 125%;
   color: #7B7960;}
.main h3 {margin: 1.5em 0 0.25em; font-size: 125%;}
.main h3:before {font-size: 75%; counter-increment: subhead;}
.main h4 {margin: 2.5em 0 0.75em;
   text-transform: uppercase; font-size: 125%;
   color: #928F59;}
.main p {margin: 0 0 1em;}
.main ul {padding-left: 1.5em;}
.main ul li {list-style: disc; margin: 0.5em 0;}
</pre>

<p>
This, on the other hand, is what I really <em>wanted</em> to do:
</p>

<pre>.main {
   h1, h2, h3, h4, h5, h6, table {
      font: 1em Arial, "Helvetica Neue", Helvetica, sans-serif;}
   h1 {font-size: 275%;}
   h3:first-child {margin-top: 1em;}
   p.tagline {margin: -0.25em 0 1.25em;
      font-size: 125%;
      color: #7B7960;}
   h3 {margin: 1.5em 0 0.25em; font-size: 125%;}
   h3:before {font-size: 75%; counter-increment: subhead;}
   h4 {margin: 2.5em 0 0.75em;
      text-transform: uppercase; font-size: 125%;
      color: #928F59;}
   p {margin: 1em 0;}
   ul {padding-left: 1.5em;}
   ul li {list-style: disc; margin: 0.5em 0;}
}
</pre>

<p>
Or, if necessary, to put the whole original chunk into its own style sheet and then do one of the following:
</p>

<pre>div.main {@import url(main-style.css);}

&lt;div class="main" style="@import url(main-style.css);"&gt;
</pre>

<p>
Interestingly, the latter is theoretically possible, thanks to the more advanced profiles in the CSS module &#8220;<a href="http://www.w3.org/TR/css-style-attr">Syntax of CSS rules in HTML&#8217;s &#8217;style&#8217; attribute</a>&#8220;.  I&#8217;m not aware of the former having been seriously considered (despite my best efforts, once upon a time), though it&#8217;s always possible I missed something.
</p>
<p>
But either one of those approaches would be a last resort, in my opinion.  I&#8217;d much rather just wrap the whole chunk in <code>.main { }</code>, like I showed previously, and be done with it.  That capability would also simplify certain annoyingly repetitive patterns, like the very first of those rules.  I think it&#8217;s pretty obvious which of the following is easier to write and maintain:
</p>

<pre>
body.home #content .entry h2, 
body.home #content .entry h3, 
body.home #content .entry h4, 
body.home #content .entry h5, 
body.home #content .entry h6 {...}

body.home #content .entry {
   h2, h3, h4, h5, h6 {...}
}
</pre>

<p>
I mean, just look at the former, and imagine what one goes through to write it in the first place.  Copy, paste, paste, paste, paste, paste&#8230; maddening.  And that&#8217;s just for a small block of CSS like this one.  Imagine the tedium of doing this for a block of 50 rules, or 150.  (Also, this is the the same thing that was requested in the feedback as &#8220;<a href="http://fantasai.inkedblade.net/style/discuss/wasp-feedback-2008#grouped-alternates">Grouped Alternates</a>&#8220;, albeit with a different syntax.)
</p>
<p>
One objection to this sort of pattern is that it increases dependence on descendant selectors, which are computationally inefficient.  But it doesn&#8217;t: I had to create a whole bunch of descendant selectors as it was, and did so far more clumsily.  And had I missed a command-V somewhere, I&#8217;d have had styles that applied outside their intended subtree.  Introducing a way to nest blocks like this doesn&#8217;t change anything except make it easier and more maintainable to do what we already do.  Honestly, it&#8217;s pretty much impossible to increase dependence on descendant selectors.  The best we can do now is make them less difficult to write.
</p>
<p>
I realize that the syntax I depict would cause backwards-compatibility problems, as in older browsers would not behave as intended when exposed to this sort of thing, but I&#8217;ve also stopped being concerned about that.  We can&#8217;t keep holding ourselves hostage to decisions made a decade or more back.  Provide the capability and authors will use it when they can.  Over time, its use will become more prevalent&#8212;kind of the same way authors adopted CSS in the first place.
</p>
<p>
I also realize that this case has been made time and again by many, many other people.  This isn&#8217;t even the first time I&#8217;ve made this case, though I think the other times were within the WG and therefore off the public record.  The fact that it keeps being made is a strong indicator that the need exists, and dismissing the idea because the same end effect can be achieved with existing selector syntax (as shown above) isn&#8217;t acceptable.  That&#8217;s like saying that complex selection effects can be achieved with JavaScript or XPath, so there&#8217;s no need for advanced CSS selectors.
</p>
<p>
So that&#8217;s my use case.  I actually have a bunch more, but they all follow the same basic pattern: the desire to group rules together into subsections of a document, or to otherwise simplify the writing of CSS.
</p></div>

</div>

</div>
<p style="font-size: 90%; text-align: right; margin-top: 0.5em; padding-top: 0;">(If you care, there's even an <a href="/eric/thoughts/page/2/">archive of previous thoughts</a>...)</p>

</div><div id="extra"><div class="panel" id="archipelago"><h4>Identity Archipelago</h4><ul><li><a href="http://flickr.com/photos/meyerweb/" rel="me">Flickr</a></li><li><a href="http://twitter.com/meyerweb/" rel="me">Twitter</a></li><li><a href="http://dopplr.com/traveller/meyerweb">Dopplr</a></li><li><a href="http://www.linkedin.com/in/meyerweb" rel="me">LinkedIn</a></li><li><a href="http://technorati.com/profile/emeyer" rel="me">Technorati</a></li></ul></div><div class="panel" id="pointers"><h4>Projects Elsewhere</h4><ul><li><a href="http://aneventapart.com/">An Event Apart</a></li><li><a href="http://complexspiral.com/">Complex Spiral Consulting</a></li><li><a href="http://www.webassist.com/go/css/emeyer/">CSS Sculptor</a></li><li><a href="http://css-discuss.org/">css-discuss</a></li><li><a href="http://microformats.org/">Microformats</a></li><li><a href="http://s5project.org/">S5</a></li></ul></div><div class="panel" id="tour"><ul><li><a href="http://fray.com/issue3/"><img src="http://fray.com/images/i3c.gif" alt="Fray Contributor (Issue 3: Sex &amp; Death)" /></a></li><!-- <li><a href="http://www.webassist.com/go/css/emeyer/"><img src="/pix/CS_ad_180x109.jpg" alt="CSS Sculptor for Dreamweaver" style="max-width: 100%;" /></a></li> --></ul></div><div class="panel">
<h4>Recently Tweeted</h4>
<p class="more"><a href="http://twitter.com/meyerweb">see more</a></p>
<p>About once a year, I de-clutter my office.  I usually do it in the spring because the snow shovel is no longer needed elsewhere. <small>&#8211;tweeted 7 hours, 8 minutes ago</small></p>
</div><div id="sideblog" class="panel">
<h4>Distractions</h4>
<p class="more">
<a href="/eric/thoughts/recent-links/">archive</a>
</p>
<ul>
<li><a href="http://8bitnyc.com/" title="March 17 | All of a sudden I want to establish a mission in Central Park and negotiate with the natives for gold and food.">8-Bit NYC</a></li>
<li><a href="http://www.youtube.com/watch?v=nFicqklGuB0&amp;feature=player_embedded" title="March 12 | Wry comment expressing my appreciation of the creative derivativeness of this video and its uncanny accuracy in mocking common tropes.">Academy Award Winning Movie Trailer</a></li>
<li><a href="http://www.youtube.com/watch?v=414TmP12WAU" title="March 9 | &#8220;Apple juice&#8230; for half price!&#8221;  More like twice PRICELESS.  (Note: If you&#8217;re at work, don your headphones.)">Happy in Paraguay</a> <small>[via <a href="http://unstoppablerobotninja.com/">Ethan</a>]</small></li>
<li><a href="http://www.youtube.com/watch?v=9V5ubAOeOBk&amp;feature=player_embedded" title="February 10 | This is approximately the best thing ever.">U900 -Walk Don&#8217;t Run (Isogabamaware)</a></li>
<li><a href="http://www.456bereastreet.com/archive/201002/sifr_default_css_hides_content_from_at_least_one_screen_reader/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A 456bereastreet %28456 Berea Street%29" title="February 8 | -9999px comes through again, but I really wish we were beyond that kind of thing.">sIFR default CSS hides content from at least one screen reader</a></li>
<li><a href="http://www.macosxhints.com/article.php?story=20100117064356428" title="February 8 | Storing this for future use.">Take a picture with the iSight camera when a folder is opened</a></li>
<li><a href="http://mingle2.com/blog/view/web-developer-mind" title="February 4 | Mostly valid.  (SEE WHAT I DID THERE?)">The Mind of a Web Developer: An Illustrated Diagram</a></li>
<li><a href="http://www.theonion.com/content/news/science_channel_refuses_to_dumb" title="January 28 | &#8220;Punkin Chunkin, for Christ&#8217;s sake&#8230; What more do you people want?&#8221;">Science Channel Refuses To Dumb Down Science Any Further</a></li>
<li><a href="http://www.mailchimp.com/blog/project-omnivore-declassified/" title="January 27 | Sounds like quite a feat.  But I wonder how we&#8217;d feel if Microsoft or Google announced the same kind of thing on their e-mail services.">MailChimp&#8217;s Project Omnivore: Declassified</a></li>
<li><a href="http://www.politifact.com/truth-o-meter/statements/2010/jan/25/carolyn-maloney/congresswoman-says-democratic-presidents-create-mo/" title="January 26 | &#8220;Obviously, luck matters a lot, but when there is a consistent pattern over more than 60 years, it starts to look like more than just luck.&#8221;">Congresswoman says Democratic presidents create more private-sector jobs</a></li>
<li><a href="http://www.ted.com/talks/taylor_mali_what_teachers_make.html" title="January 25 | Truth.">Taylor Mali: What teachers make</a></li>
<li><a href="http://notebook.johnmartz.com/how-websites-work?c=1" title="January 22 | At last, the truth is out and I can stop pretending:  beatific monkeys are what makes it all go.">How websites work</a></li>
<li><a href="http://morsecode.scphillips.com/jtranslator.html" title="January 22 | &#8211; &#8230;. .. &#8230; / .. &#8230; / .- .&#8211; . &#8230; &#8212; &#8212; . / -. &#8212; / &#8230; . .-. .. &#8212; ..- &#8230; .-.. -.&#8211;">Morse Code Translator</a></li>
</ul>
</div>
<div class="panel" id="advisory">
<div class="guarded">
<a href="http://blogadvisorysystem.com/"><img src="/pix/bas/guarded.png" alt="Blog Advisory System Alert Level: Guarded"></a>
</div>
</div>

<div class="panel" id="excuse">
<h4>The <a href="/feeds/excuse/">excuse of the day</a> is</h4>
<p>failure of the AE-35 unit</p>
</div>

<div class="panel" id="extras">
<h4>Extras</h4>
<ul>
<li><a href="/feeds/">Feeds</a> &#8226;</li>
<li><a href="/eric/faq.html">FAQ</a> &#8226;</li>
<li><a href="/family.html">Family</a></li>
</ul>
</div>

</div>

<div id="navigate">
<h4>Navigation</h4>
<ul id="navlinks">
<li id="archLink"><a href="/eric/thoughts/">Archives</a></li>
<li id="cssLink"><a href="/eric/css/">CSS</a></li>
<li id="toolsLink"><a href="/eric/tools/">Toolbox</a></li>
<li id="writeLink"><a href="/eric/writing.html">Writing</a></li>
<li id="speakLink"><a href="/eric/talks/">Speaking</a></li>
<li id="otherLink"><a href="/other/">Leftovers</a></li>
<li id="aboutsite"><a href="/ui/about.html">About this site</a></li>
</ul>
</div>

<div id="footer">
<p class="sosumi">All contents of this site, unless otherwise noted, are &copy;1995-2008 <strong>Eric A. and Kathryn S. Meyer</strong>.  All Rights Reserved.</p>
<p>"<a href="/eric/thoughts/">Thoughts From Eric</a>" is powered by the &uuml;bercool <a href="http://wordpress.org/">WordPress</a></p>
</div>
</body>
</html>
