<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>willoller.com &#187; css</title>
	<atom:link href="http://www.willoller.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.willoller.com</link>
	<description>Learning to match the beat of the Old World man.</description>
	<lastBuildDate>Thu, 02 Feb 2012 23:34:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Combining css selectors</title>
		<link>http://www.willoller.com/combining-css-selectors/</link>
		<comments>http://www.willoller.com/combining-css-selectors/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 16:37:35 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.blackdogdev.com/?p=89</guid>
		<description><![CDATA[We often come across css code in dire need of optimization (details have been changed to protect the guilty), and shows a misunderstanding about the power of css: h1 &#123; &#160; &#160;font-family: Arial, Helvetica, Geneva, Swiss,&#160; sans-serif; &#160; &#160;font-size: 18px; &#160; &#160;font-style: normal; &#160; &#160;font-weight: bold; &#160; &#160;text-transform: none; &#160; &#160;color: #7D0126; &#160; &#160;margin-bottom: 2px; [...]]]></description>
			<content:encoded><![CDATA[	<p>We often come across css code in dire need of optimization (details have been changed to protect the guilty), and shows a misunderstanding about the power of css:</p>
	<div class="code css" style="font-family: monospace;"><br />
h1 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 18px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-transform</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #7D0126;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 2px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-bottom</span>: 0px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 26px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 12px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-top</span>: 0px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h2 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 16px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-transform</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #7D0126;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 2px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-bottom</span>: 0px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 24px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-top</span>: 0px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h3 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 14px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">italic</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 20px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #6B917C;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 7px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h4 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 12px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 18px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 6px;<br />
<span style="color: #66cc66;">&#125;</span><br />
p <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 11px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 17px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 6px;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* It keeps going like this but we're going to stop here */</span><br />
<br />
&nbsp;</div>
	<p>As you can see, several properties are repeated across elements.<br />
These can (and should) be consolidated.</p>
	<p>Let&#8217;s consolidate them first by applying very common properties to the <code>body</code> element:</p>
	<div class="code css" style="font-family: monospace;"><br />
body <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 11px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 15px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #cc66cc;">600</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-variant</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-transform</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-decoration</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #000000; font-weight: bold;">left</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">white-space</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">000000</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
h1 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 18px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #7D0126;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 2px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-bottom</span>: 0px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 26px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 12px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-top</span>: 0px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h2 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 16px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #7D0126;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 2px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-bottom</span>: 0px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 24px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding-top</span>: 0px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h3 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 14px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">italic</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 20px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #6B917C;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 7px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h4 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 12px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 18px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 6px;<br />
<span style="color: #66cc66;">&#125;</span><br />
p <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 17px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 11px;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp;</div>
	<p>Okay, now we see a lot of repetion is still happening here.  Much of this repetition can be removed by using the comma (,) selector, which allows you to make lists of elements:</p>
	<div class="code css" style="font-family: monospace;"><br />
body <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 11px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 17px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #cc66cc;">600</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-variant</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-transform</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-decoration</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #000000; font-weight: bold;">left</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">white-space</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">000000</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
h1, h2, h3, h4, p <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 0px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h1, h2 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 16px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #7D0126;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 2px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 16px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 24px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h1 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 18px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 26px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 12px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h3 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 14px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">italic</span>;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 20px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #6B917C;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 7px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h4 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 12px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: 18px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 6px;<br />
<span style="color: #66cc66;">&#125;</span><br />
p <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 6px;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp;</div>
	<p>There is a pattern to the font-size, margin-height, and line-heights.  We will now use this to our advantage to make life even easier.</p>
	<div class="code css" style="font-family: monospace;"><br />
body <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-family</span>: Arial, Helvetica, Geneva, Swiss,&nbsp; <span style="color: #993333;">sans-serif</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 11px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #cc66cc;">600</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-variant</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-transform</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-decoration</span>: <span style="color: #993333;">none</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">text-align</span>: <span style="color: #000000; font-weight: bold;">left</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">white-space</span>: <span style="color: #993333;">normal</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #<span style="color: #cc66cc;">000000</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
h1, h2, h3, h4, p <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin</span>: 0px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">padding</span>: 0px;<br />
&nbsp; &nbsp;line-<span style="color: #000000; font-weight: bold;">height</span>: <span style="color: #cc66cc;">150</span>%;&nbsp; <span style="color: #808080; font-style: italic;">/* A good approximation */</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: <span style="color: #cc66cc;">0</span><span style="color: #6666ff;">.5em </span><span style="color: #808080; font-style: italic;">/* another approximation */</span><br />
<span style="color: #66cc66;">&#125;</span><br />
h1, h2 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 16px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-weight</span>: <span style="color: #993333;">bold</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #7D0126;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 2px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h1 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 18px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-top</span>: 12px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h3 <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-size</span>: 14px;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">font-style</span>: <span style="color: #993333;">italic</span>;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: #6B917C;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">margin-bottom</span>: 7px;<br />
<span style="color: #66cc66;">&#125;</span><br />
h4 <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span>: 12px; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp;</div>
	<p>With just a few basic css selectors, this code was cut in half.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/combining-css-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Cascading&#8221; in CSS</title>
		<link>http://www.willoller.com/cascading-in-css/</link>
		<comments>http://www.willoller.com/cascading-in-css/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 16:58:54 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.blackdogdev.com/?p=94</guid>
		<description><![CDATA[The &#8220;cascading&#8221; in &#8220;Cascading Style Sheets&#8221; has several facets: computed values, inheritance, and specificity. Understanding how these cascades work is an integral part of your css ninja training. Computed Values Many of the values assigned have a unit. Some of these are relative (like em and &#60;span&#62;), and some are absolute (like px and in). [...]]]></description>
			<content:encoded><![CDATA[	<p>The &#8220;cascading&#8221; in &#8220;Cascading Style Sheets&#8221; has several facets: computed values, inheritance, and specificity.  Understanding how these cascades work is an integral part of your css ninja training.</p>
	<h2>Computed Values</h2>
	<p>Many of the values assigned have a unit.  Some of these are <strong>relative</strong> (like <code>em</code> and <code>&lt;span&gt;</code>), and some are <strong>absolute</strong> (like <code>px</code> and <code>in</code>).  Relative values are based on their parents: an element with a width of 50</span> uses the element&#8217;s parent to determine the actual width of the element.</p>
<div style="width:50%;font-family:Georgia,serif;float:left;background:#fcf9ce; border: 1px solid #dfdfdf;padding:4px;margin-bottom:1em;">
width: 50%
<div style="width:50%;float:left;background:#9eee5c;border:1px solid #bababa;padding:2px 4px;">
width: 50%
</div>
</div>
	<p style="clear:left;;">Likewise, if both the parent and child elements&#8217; font-sizes are <code>1.5em</code>, the child&#8217;s actual font size will be larger than the parent&#8217;s.</p>
<div style="border:1px solid #dfdfdf;font-family:Georgia,serif;color:#26838e; font-size:1.5em; background: #eee; margin-bottom:1em;">
1.5em <span style="font-size: 1.5em;">1.5em <span style="font-size: 1.5em;">1.5em </span></span>
</div>
	<p>Absolute values do not change based on their parent values.  These are often obvious: <code>color: red;</code> for example.  Pixel values are absolute, though the actual value displayed by the UA(User Agent) may differ (due to display or text-size settings).</p>
	<h2>Inheritance</h2>
	<p>Inheritance is the passing on of attributes from parents to children.  It works in CSS like this: An element&#8217;s font  color is set to red.  The color for its child elements will also be red (if left unspecified or set to <code>inherit</code>).</p>
<div style="color: red; padding:4px; border: 1px solid #ddd;font-family:Georgia,serif;">
color: red
<div style="padding:4px; border: 1px solid #ddd;">
no color specified
<div style="color: inherit; padding:4px; border: 1px solid #ddd;">
color: inherit
</div>
</div>
</div>
	<h2>Specificity</h2>
	<p>This is how CSS decides between competing styles. Take a look at the following code:</p>
	<div class="code css" style="font-family: monospace;"><br />
p#special_error <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #993333;">red</span>; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #6666ff;">.error </span><span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">color</span>: orange; <span style="color: #66cc66;">&#125;</span><br />
p <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #000000; font-weight: bold;">black</span>; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp;</div>
	<div class="code html" style="font-family: monospace;"><br />
&lt;p&gt;no class or id&lt;/p&gt;<br />
&lt;p id=&quot;special_error&quot; class=&quot;error&quot;&gt;class and id&lt;/p&gt;<br />
&lt;p class=&quot;error&quot;&gt;p class&lt;/p&gt;<br />
&lt;div class=&quot;error&quot;&gt;div class&lt;/div&gt;<br />
&lt;div id=&quot;special_error&quot;&gt;div id&lt;/div&gt;<br />
&nbsp;</div>
	<p>So what color do the elements end up with?  To answer that question, we need to know how the competing selectors are chosen.</p>
	<p>Each selector has a particular weight outlined in this table:</p>
<table cellspacing="0" cellpadding="0" class="open"><tr>
<th>selector</th><th>weight</th><th>example</th></tr><tr>
<td>id</td><td>100</td><td>#special_error</td></tr><tr class="odd">
<td>class</td><td>10</td><td>.error</td></tr><tr>
<td>element</td><td>1</td><td>p</td></tr></table>
	<p>These weights are all added up and the &#8220;heaviest&#8221; selector set wins.  So using the css above, here are the results:</p>
	<div class="code html" style="font-family: monospace;"><br />
&lt;p&gt;no class or id&lt;/p&gt;&lt;!-- #000000 --&gt;<br />
&lt;p id=&quot;special_error&quot; class=&quot;error&quot;&gt;class and id&lt;/p&gt;&lt;!-- red --&gt;<br />
&lt;p class=&quot;error&quot;&gt;p class&lt;/p&gt;&lt;!-- orange --&gt;<br />
&lt;div class=&quot;error&quot;&gt;div class&lt;/div&gt;&lt;!-- orange --&gt;<br />
&lt;div id=&quot;special_error&quot;&gt;div id&lt;/div&gt;&lt;!-- inherits --&gt;<br />
&nbsp;</div>
	<h3>Links</h3>
	<p><a href="http://www.w3.org/TR/REC-CSS2/cascade.html">w3.org</a><br />
<a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets">wikipedia</a><br />
<a href="http://htmlhelp.com/reference/css/structure.html">htmlhelp</a></p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/cascading-in-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>X-UA-Bloated</title>
		<link>http://www.willoller.com/x-ua-bloated/</link>
		<comments>http://www.willoller.com/x-ua-bloated/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 21:37:46 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://www.willoller.com/x-ua-bloated/</guid>
		<description><![CDATA[The problems with the new solution are many. The ones that concern me: After just a few versions, the browser will be hopelessly bloated and bogged down trying to maintain several versions with all of their features and bugs The point of the solution is to make browser bugs immortal. But will there be bugs [...]]]></description>
			<content:encoded><![CDATA[	<p>The problems with the new solution are many.  The ones that concern me:<br />
<ul><br />
<li>After just a few versions, the browser will be hopelessly bloated and bogged down trying to maintain several versions with all of their features and bugs</li></p>
	<p><li>The point of the solution is to make browser bugs immortal.  But will there be bugs in the bugs?  Will the peekaboo bug or hasPosition act differently on the embedded IE6 from the original IE6? My head hurts just thinking about it.</li></p>
        <li>Like it or not, web design is a craft.  The building industry doesn&#8217;t give special exceptions to architects who want to build a skyscraper out of wood just because they&#8217;ve always built birdhouses and wrap-around decks.  Instead, they tell the architects to learn about steel and concrete and glass or find a new industry.</li>
	<p></ul></p>
	<p>Those issues aside, maybe <a href="http://alistapart.com/articles/fromswitchestotargets">version targeting is not all bad</a>  (God help me, but I trust that Eric Meyer).  But I agree with <a href="http://unstoppablerobotninja.com/journal/entry/527/">Ethan Marcotte</a> that the solution is elsewhere; and by elsewhere i mean right here.</p>
	<p>It&#8217;s not complicated. The flaming will die down. The Web will be saved. Our job &#8211; our <em>craft</em> will get a little easier and a little better.</p>
<h2>The Solution</h2>
	<p>Microsoft should release <strong>stand-alone downloadable versions of Internet Explorer</strong>. </p>
	<p>It should also give IE7-8-9-10 the ability to &#8220;nest&#8221; browsers in the parent browser window, just like <a href="https://addons.mozilla.org/en-US/firefox/addon/1419">Firefox already has</a>.  Sure, the <code>&lt;meta http-equiv="X-UA-Compatible" /&gt;</code> tag could still be used to automatically specify the IE version, and the user could be asked if they want to view the file in the pre-selected X-UA-Compatible version or in the current (IE8-9-10) version they have now.  Then, if the version is not installed, they could choose to install it or go ahead and view it in some other installed version.</p>
	<p>IE7 has a plugin architecture; IE8 should too. The only thing missing is the standalone IE releases (<a href="http://tredosoft.com/Multiple_IE">MultiIE</a> already does it for XP, but it fails horribly in Vista).</p>
	<p>I think this gives all of us the best of all worlds:  Corporations who <em>need</em> a certain version of IE for their intranet <em>will have it</em>.  Users who want cutting-edge compatibility and speed <em>will have it</em>.  Developers who need a solution for future-broken sites under IE11 <em>will have it</em>.  Standardistas who need those versions to browser-test for backward compatibility <em>will have them</em>.</p>
	<p>Freezing all future versions is not the answer; we will be sorry.  Let us pick-and-choose the fossilized browsers  <em>as we need them</em> and we will all have what we want.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/x-ua-bloated/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Joe Clark is Squashing a persistent myth</title>
		<link>http://www.willoller.com/squashing-a-persistent-myth-%c2%b6-personal-weblog-of-joe-clark-toronto/</link>
		<comments>http://www.willoller.com/squashing-a-persistent-myth-%c2%b6-personal-weblog-of-joe-clark-toronto/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 03:37:07 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.willoller.com/squashing-a-persistent-myth-%c2%b6-personal-weblog-of-joe-clark-toronto/</guid>
		<description><![CDATA[The use of px units, when viewed with IE6 or IE7, leads to fonts you can’t resize (unless you turn off some seriously buried preferences). Every other browser on every platform can enlarge or reduce fonts in any CSS unit, including px. It’s true that pt makes sense only for print stylesheets, but px is [...]]]></description>
			<content:encoded><![CDATA[	<p><blockquote cite="http://blog.fawny.org/2007/12/20/px-pt/">The use of px units, when viewed with IE6 or IE7, leads to fonts you can’t resize (unless you turn off some seriously buried preferences). Every other browser on every platform can enlarge or reduce fonts in any CSS unit, including px. It’s true that pt makes sense only for print stylesheets, but px is a “relative” unit, as I keep reminding people.</blockquote><cite cite="http://blog.fawny.org/2007/12/20/px-pt/"><a href="http://blog.fawny.org/2007/12/20/px-pt/">Squashing a persistent myth ¶ Personal Weblog of Joe Clark, Toronto</a></cite></p>
	<p>Joe Clark makes a good point about the nature of font resizing in ie vs all other browsers.&nbsp; I, too, think it should be up to the consumer to use a browser (or accessibility software) that is compatible with their needs.</p>
	<p>However, I still use relative font sizes in my web design projects.&nbsp; It seems to me to be the most accessible method because of the ie limitations.</p>
	<p>Whither do I turn? Do I embrace my capitalist side, saying <span style="font-style: italic;">caveat emptor, download Opera if you&#8217;ve got a problem with your eyes</span> or do I continue listening to my communistic all-for-one accessibility side that says keep struggling late nights with relative font sizes?</p>
	<p>I think the capitalist (and pragmatic) side is winning.  Is that wrong?</p>
	<p><small>squish squash</small></p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/squashing-a-persistent-myth-%c2%b6-personal-weblog-of-joe-clark-toronto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smashing Magazine on Microformats</title>
		<link>http://www.willoller.com/smashing-magazine-on-microformats/</link>
		<comments>http://www.willoller.com/smashing-magazine-on-microformats/#comments</comments>
		<pubDate>Fri, 25 May 2007 14:51:43 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[standards]]></category>

		<guid isPermaLink="false">http://www.blackdogdev.com/2007/smashing-magazine-on-microformats/</guid>
		<description><![CDATA[Smashing Magazine has a great comprehensive article on Microformats and their future. Microformats are a cool technology: they allow metadata (such as vCard info: Name, Address, Postal Code, etc.) to be inserted directly into traditional markup using existing hooks like classes. Don&#8217;t discount this kind of stuff, people. Its going to be native in Firefox [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.smashingmagazine.com/">Smashing Magazine</a> has a great comprehensive <a href="http://www.smashingmagazine.com/2007/05/04/microformats-what-they-are-and-how-to-use-them/">article on Microformats</a> and their future.</p><br />
<p>Microformats are a cool technology: they allow metadata (such as vCard info: Name, Address, Postal Code, etc.) to be inserted directly into traditional markup using existing hooks like <code>class</code>es.</p><br />
<p>Don&#8217;t discount this kind of stuff, people. Its going to be <a href="http://www.readwriteweb.com/archives/mozilla_does_microformats_firefox3.php">native in Firefox 3</a>, and if adoption rates are high, they could be everywhere.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/smashing-magazine-on-microformats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Google Sees Your Site</title>
		<link>http://www.willoller.com/how-google-sees-your-site/</link>
		<comments>http://www.willoller.com/how-google-sees-your-site/#comments</comments>
		<pubDate>Wed, 09 May 2007 01:04:26 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[standards]]></category>

		<guid isPermaLink="false">http://www.blackdogdev.com/2007/how-google-sees-your-site/</guid>
		<description><![CDATA[Google&#8217;s massive databases come from its tiny minions &#8220;crawling&#8221; the web, traversing links and storing page views. They are called &#8220;spiders,&#8221; and for your site to get a good search rank from Google (and MSN, and Yahoo, etc&#8230; each of which has their own spiders), you need to know a little bit about what they [...]]]></description>
			<content:encoded><![CDATA[<p>Google&#8217;s massive databases come from its tiny minions &#8220;crawling&#8221; the web, traversing links and storing page views.   They are called &#8220;spiders,&#8221; and for your site to get a good search rank from Google (and MSN, and Yahoo, etc&#8230; each of which has their own spiders), you need to know a little bit about what they are and how they work.</p><br />
<p>This is by no means a comprehensive explanation of spiders or <acronym title="Search Engine Optimization">seo</acronym> methods. Volumes are being written about those topics.  This is just a basic introduction to spiders and accessability on the web.</p><br />
<h3>References</h3><br />
<ul><br />
<li><a href="http://www.google.com/bot.html" rel="nofollow">Google&#8217;s official Googlebot FAQ</a></li><br />
<li><a href="http://en.wikipedia.org/wiki/Googlebot">Googlebot</a> in <a href="http://en.wikipedia.org/">Wikipedia</a></li><br />
<li><a href="http://www.googleguide.com/google_works.html">How Google Works</a> from <a href="http://www.googleguide.com/">GoogleGuide</a></li><br />
</ul><br />
<h3>Spiders</h3><br />
<p>First of all, spiders are not people. They are programs run from Google&#8217;s servers that view your websites in a stripped-down, text-only virtual browser.  Second, unlike your house, having your website crawling with spiders can be a very good thing.</p><br />
<p>Black Dog&#8217;s home page might look a little like this when viewed by a spider:<br />

<a href="http://blackdogdev.com/blog/wp-content/uploads/2007/05/woller_how-google-sees-you.gif" title="Lynx Viewer showing the BlackDogDev Homepage" target="_blank" rel="lightbox"><img src="http://blackdogdev.com/blog/wp-content/uploads/2007/05/woller_how-google-sees-you.thumbnail.gif" alt="Lynx Viewer showing the BlackDogDev Homepage" /></a></p><br />
<p>This is a screenshot of a text-only view of blackdogdev.com&#8217;s homepage. As you can see, the big photo of an adorable dog is gone; so is our nice-looking logo.  All that remains is the most important part: the content. The text is the only thing the spiders care about.</p><br />
<h3>Accessability</h3><br />
<p>A spider can&#8217;t tell the difference between a photo of your dog and a photo of a fire engine, unless there is text available to give it meaning. Typically, this is achieved using an image&#8217;s <code>alt</code> attribute.</p><br />
<p>On blackdogdev.com, the <code>alt</code> text on the big dog photo is not very specific: &#8220;Loading Image&#8230;&#8221; doesn&#8217;t really mean anything.  The logo, however, is better. Its <code>alt</code> text is &#8220;Black Dog Studios&#8221;.  Much more relevant!</p><br />
<p>These <code>alt</code> attributes aren&#8217;t just for search engines. They are also used by screen-readers for the blind, who cannot see the screen at all but still take advantage of the wealth of knowledge on the net.  For the images on your site to be meaningful to the blind or to spiders, they must have descriptive alt tags: &#8220;Portrait of Henry Flagler, January 2, 1830 – May 20, 1913&#8221; rather than &#8220;H_Flagler&#8221;.  <code>alt</code> tags should <strong>never</strong> be left blank.</p><br />
<p>Remember: if you can&#8217;t navigate your site without graphics or flash, then spiders and the disabled can&#8217;t either. If you don&#8217;t like what you see when your site is stripped down to just text, a structural redesign may be in order.</p><br />
<h3>Tools</h3><br />
<p><a href="http://www.yellowpipe.com/yis/tools/lynx/IElynxviewEXT.cgi?url=http://blackdogdev.com/blog/2007/05/08/how-google-sees-your-site/">See this blog entry in a text-only browser</a>.</p><br />
<p>To see your site like Google does, you can use any of the available text-based browsers out there. A short list includes:</p>
<ul>
<li><a href="http://lynx.isc.org/">Lynx</a>, for UNIX and Linux, propably the most popular console-based borwser around</li>
<li><a href="https://addons.mozilla.org/firefox/1944/">Yellowpipe Lynx Viewer Firefox extension</a>. This is what I used for the screenshot.  Very handy.</li>
<li><a href="http://www.delorie.com/web/lynxview.html">delorie.com&#8217;s online Lynx converter</a> will turn any url into a Lynx-like text page.</li>
</ul>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/how-google-sees-your-site/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS Sibling Selectors</title>
		<link>http://www.willoller.com/7/</link>
		<comments>http://www.willoller.com/7/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 20:11:39 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://www.blackdogdev.com/2007/7/</guid>
		<description><![CDATA[For those of us who care about the semantic web, standards, or the W3C, The Web Standards Project needs to be in your feed reader. I&#8217;ll admit, it wasn&#8217;t in mine; until now that is. The design of the site is awesome, and they eat their own cooking. (Plus, they use WordPress!) They employ css [...]]]></description>
			<content:encoded><![CDATA[	<p>For those of us who care about the semantic web, standards, or the W3C, <a href="http://www.webstandards.org/" title="Permanent link to The Web Standards Project">The Web Standards Project</a> needs to be in your feed reader.  I&#8217;ll admit, it wasn&#8217;t in mine; until now that is.</p>
	<p>The design of the site is awesome, and they eat their own cooking.  (Plus, they use WordPress!)  They employ css tricks I have seldom seen used before, and consistently use semantic tags (<code>&lt;abbr&gt;</code>, <code>&lt;q&gt;</code>).</p>
	<p>The best trick of all: the sibling selector.  Why?  Because it allows for truly semantic output with the leanest markup possible.  Before, I might have marked up a simple content block like this:</p>
	<p>[html]<br />
<div class="content">
   <h1>Title</h1>
   <img src="url" alt="pic related to story"/>
   <div class="block">
      <p class="intro">This is an introduction sentance or paragraph.  It is supposed to represent a blurb about the article below.</p>
      <div class="mainbody">
         <p>content</p>
         <p>content</p>
         <p>content</p>
         <p>content</p>
      </div>
      <p class="footer">Footer.  Date or links, or whatever.</p>
   </div><br />
</div><br />
[/html]</p>
	<p>This way, all of the elements have class hooks.  CSS is applied using the classes and simple hierarchies:</p>
	<p>[css]<br />
div.content { }<br />
div.content h1 { font-size: 1.8em; }<br />
div.content div.block { border: 1px solid black; }<br />
div.block p.intro { font-weight: bold; }<br />
div.block img { float: right; }<br />
div.block div.mainbody { clear: both; }<br />
div.mainbody p { color: #006; }<br />
p.footer { font-size: 0.7em; color: #888; }<br />
[/css]</p>
	<p>Class hooks are helpful, but not really needed if you use sibling selectors!  You, too, can write super-styled code without the additional markup headache!</p>
	<p>[html]<br />
<div class="content" >
   <h1>Title</h1>
   <img src="url" alt="That image again"/>
   <p>This is an introduction sentance or paragraph.  It is supposed to represent a blurb about the article below.</p>
   <p>content</p>
   <p>content</p>
   <p>content</p>
   <p>content</p>
   <p class="footer">Footer.  Date or links, or whatever.</p><br />
</div><br />
[/html]</p>
	<p>See, that code is cleaner and easier to maintain.  The CSS required to</p>
	<p>[css]<br />
div.content { }<br />
div.content h1 { font-size: 1.8em; }<br />
div.content p { color: #006; }<br />
div.content h1+p { color: #000; font-weight: bold; clear: both;}<br />
div.content h1+img { float: right; }<br />
div.content img { float: left } /* Just for fun */<br />
div.content p.footer { font-size: 0.7em; color: #888; }<br />
[/css]</p>
	<p>That&#8217;s all there is to it.  Now, the line between content and design is darkened.</p>
	<p>One thing: the class hook remains on the footer element.  This is because adjacent-sibling selectors do not work in reverse.  The selector applies only to the element after the <code>+</code>, and there is no selector that applies to a previous adjacent-sibling element.<br />
<h3>Sources</h3><br />
<a href="http://meyerweb.com/eric/articles/webrev/200007a.html">Eric Myer wrote about them</a>.<br />
<a href="http://www.w3.org/TR/REC-CSS2/selector.html">The W3C recommends them</a>.<br />
<a href="http://www.communitymx.com/content/article.cfm?cid=1C603">John Gallant and Holly Bergevin say IE7 supports them</a>.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Sibling selectors</title>
		<link>http://www.willoller.com/css-sibling-selectors/</link>
		<comments>http://www.willoller.com/css-sibling-selectors/#comments</comments>
		<pubDate>Fri, 15 Dec 2006 04:27:50 +0000</pubDate>
		<dc:creator>will</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.willoller.com/css-sibling-selectors/</guid>
		<description><![CDATA[For those of us who care about the semantic web, standards, or the W3C, The Web Standards Project needs to be in your feed reader. I&#8217;ll admt, it wasn&#8217;t in mine; until now that is. The design of the site is awesome, and they eat their own cooking. (Plus, they use WordPress!) They employ css [...]]]></description>
			<content:encoded><![CDATA[	<p>For those of us who care about the semantic web, standards, or the W3C, <a href="http://www.webstandards.org/" title="Permanent link to The Web Standards Project">The Web Standards Project</a> needs to be in your feed reader.  I&#8217;ll admt, it wasn&#8217;t in mine; until now that is.</p>
	<p>The design of the site is awesome, and they eat their own cooking.  (Plus, they use WordPress!)  They employ css tricks I have seldom seen used before, and consistently use semantic tags (<code>&lt;abbr&gt;</code>, <code>&lt;q&gt;</code>).</p>
	<p>The best trick of all: the sibling selector.  Why?  Because it allows for truly semantic output with the leanest markup possible.  Before, I might have marked up a simple content block like this:<br />
<pre><br />
<code><br />
&lt;div class="content"&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;h1&gt;Title&lt;/h1&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;img src="url" alt="pic related to story"&gt;<br />
&#160;&#160; &lt;div class="block"&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&lt;p class="intro"&gt;This is an introduction sentance or paragraph.&#160;&#160;It is supposed to represent a blurb about the article below.&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&lt;div class="mainbody"&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&lt;/div&gt;&lt;br /&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&lt;p class="footer"&gt;Footer.&#160;&#160;Date or links, or whatever.&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;/div&gt;&lt;br /&gt;<br />
&lt;/div&gt;<br />
</code><br />
</pre><br />
This way, all of the elements have class hooks.  CSS is applied using the classes and simple hierarchies:<br />
<pre><br />
<code><br />
div.content { }<br />
div.content h1 { font-size:1.8em; }<br />
div.content div.block { border:1px solid black; }<br />
div.block p.intro { font-weight: bold; }<br />
div.block img { float:right; }<br />
div.block div.mainbody { clear: both; }<br />
div.mainbody p { color: #006; }<br />
p.footer { font-size: 0.7em; color: #888; }<br />
</code><br />
</pre><br />
Class hooks are helpful, but not really needed if you use sibling selectors!  You, too, can write super-styled code without the additional markup headache!<br />
<pre><br />
<code><br />
&lt;div class="content" &gt;&lt;br /&gt;<br />
&#160;&#160; &lt;h1&gt;Title&lt;/h1&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;img src="url" alt="That image again"/&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;p&gt;This is an introduction sentance or paragraph.&#160;&#160;It is supposed to represent a blurb about the article below.&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;p&gt;content&lt;/p&gt;&lt;br /&gt;<br />
&#160;&#160; &lt;p class="footer"&gt;Footer.&#160;&#160;Date or links, or whatever.&lt;/p&gt;&lt;br /&gt;<br />
&lt;/div&gt;<br />
</code><br />
</pre><br />
See, that code is cleaner and easier to maintain.  The CSS required to <br />
<pre><br />
<code><br />
div.content { }<br />
div.content h1 { font-size:1.8em; }<br />
div.content p { color: #006; }<br />
div.content h1+p { color: #000; font-weight: bold; clear:both;}<br />
div.content h1+img { float:right; }<br />
div.content img { float:left } /* Just for fun */<br />
div.content p.footer { font-size: 0.7em; color: #888; }<br />
</code></p>
	<p>That&#8217;s all there is to it.  Now, the line between content and design is darkened.</p>
	<p>One thing: the class hook remains on the footer element.  This is because adjacent-sibling selectors do not work in reverse.  The selector applies only to the element after the <code>+</code>, and there is no selector that applies to a previous adjacent-sibling element.</p>
	<p><h3>Sources</h3><br />
<a href="http://meyerweb.com/eric/articles/webrev/200007a.html">Eric Myer wrote about them</a>.<br />
<a href="http://www.w3.org/TR/REC-CSS2/selector.html">The W3C recommends them</a>.<br />
<a href="http://www.communitymx.com/content/article.cfm?cid=1C603">John Gallant and Holly Bergevin say IE7 supports them</a>.</pre></p>

 ]]></content:encoded>
			<wfw:commentRss>http://www.willoller.com/css-sibling-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

