<?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>Stubbornella</title>
	<atom:link href="http://www.stubbornella.org/content/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stubbornella.org/content</link>
	<description>A Term of Endearment</description>
	<lastBuildDate>Thu, 03 May 2012 19:25:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Cross-Browser Debugging CSS</title>
		<link>http://www.stubbornella.org/content/2012/05/02/cross-browser-debugging-css/</link>
		<comments>http://www.stubbornella.org/content/2012/05/02/cross-browser-debugging-css/#comments</comments>
		<pubDate>Thu, 03 May 2012 06:16:55 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=885</guid>
		<description><![CDATA[I was helping Laura (a developer who works with me) learn about cross-browser debugging this week, which got me excited to share my process.

The first principal is simply:

<blockquote>Work with CSS, not against it.</blockquote>

CSS has an underlying design and when you work with it, with the natural flow of how CSS is meant to be used, you will find you have a lot less bugs. I learned CSS by reading the W3C specifications, which is why I began coding according to the language's design, but however you learned it, you can pick up some of the key points involved.

The first thing I do is code to a good browser from the start. Our choice is Google Chrome, mainly because of the superior developer tools. When I have something working in Chrome and I am satisfied with it, I take a look at it in either Safari or Firefox. 

If there is a discrepancy between these good browsers, chances are you are working against CSS. Do not try to hack around discrepancies between good browsers. Your goal is to figure out *why* it is being interpreted differently. Usually there is a very good reason. These are some of the things I check on if I have bugs:]]></description>
			<content:encoded><![CDATA[<p>I was helping Laura (a developer who works with me) learn about cross-browser debugging this week, which got me excited to share my process.</p>
<p>The first principal is simply:</p>
<blockquote><p>Work with CSS, not against it.</p></blockquote>
<p>CSS has an underlying design and when you work with it, with the natural flow of how CSS is meant to be used, you will find you have a lot less bugs. I learned CSS by reading the W3C specifications, which is why I began coding according to the language&#8217;s design, but however you learned it, you can pick up some of the key points involved.</p>
<p>The first thing I do is code to a good browser from the start. Our choice is Google Chrome, mainly because of the superior developer tools. When I have something working in Chrome and I am satisfied with it, I take a look at it in either Safari or Firefox. </p>
<p>If there is a discrepancy between these good browsers, chances are you are working against CSS. Do not try to hack around discrepancies between good browsers. Your goal is to figure out *why* it is being interpreted differently. Usually there is a very good reason. These are some of the things I check on if I have bugs:</p>
<ul class="basicList">
<li><strong>HTML interpretation</strong> &#8211; did you forget to close a tag? Did you wrap an inline element around a block level element? Anything that veers off the standard will be interpreted differently by different browsers.</li>
<li>Run your CSS through <a href="http://csslint.net">CSS lint</a>. It will give you a good sense of any errors (missing semi colon?) that might be throwing you off. For debugging cross browser differences, the errors are more interesting than the warnings.</li>
<li><strong>Forgot to use a reset/normalize stylesheet</strong> and are relying on (different) browser default styles.</li>
<li><strong>Browser support differences</strong>. Are you using advanced CSS3 properties or HTML5 elements? Check browser support to be sure all your target browsers are covered (quirksmode is where I usually do this). If not, you may still be able to use the fancy-pants properties, you&#8217;ll just need to design clever fall-backs for the clunkier browsers. For example, borders instead of drop shadows or square instead of rounded.</li>
<li><strong>Margins are not being trapped correctly</strong>. If you have weird spaces in unexpected places, chances are your margins are collapsing in an undesirable way.</li>
<li>You created a <strong>new formatting context in one browser, but not in another</strong>. Typically this happens as a result of overzealous use of the zoom:1 property to trigger hasLayout in IE. Yes, hasLayout is essentially the same thing as a new formatting context in better browsers.</li>
<li>Using <strong>absolute position, without setting horizontal and vertical offset</strong>. For that reason, the absolutely positioned element will have the same position it would have had when set statically. However, if you try to manipulate the top, right, bottom, or left values, the element will all of the sudden be positioned relative to the nearest relatively positioned ancestor causing it to jump.</li>
<li>Did you <strong>combine display types in unexpected ways</strong>? For example, the spec doesn&#8217;t lay out what happens when a table-cell is next to a floated element without a table row or table in between. It doesn&#8217;t mean you can&#8217;t do it, but it does mean that if you do, you open yourself up to potential bugs and will need to spend more time cross browser testing.</li>
<li>Is <strong>whitespace affecting your layout</strong>? You almost never want to have whitespace dependencies on your CSS display, but sometimes it happens, particularly with display inline and inline block and with images since they look like blocks, but, unless you set them all to display block, don&#8217;t behave that way.</li>
<li><strong>Rounding errors can cause display differences</strong>. All flexible layouts and grids have to deal with sub-pixel rounding errors, they each find different ways to minimize the visibility of these differences.</li>
</ul>
<h3>If you don&#8217;t read anything else, read the next two paragraphs</h3>
<p>The most important thing to keep in mind is that <strong>error behavior is not defined in the spec</strong>. If you go off-roading you don&#8217;t know what you will get. Chances are it will be different between browsers. If you are combining odd properties (like margins on an inline element), you will have cross browser differences. </p>
<h4>Display</h4>
<p>I think of CSS like a choose your own adventure. When you have made certain choices, others become obvious. For example, you need to first choose your display type block, inline, inline-block, table. When you have chosen that, you are left with a tool-box of appropriate tools to use to alter the display. For example, </p>
<ul class="basicList">
<li>Block level elements should be used with margins, paddings, height and width. Line-height isn&#8217;t appropriate.
</li>
<li>Inline elements have line-height, vertical align, and can also be whitespace sensitive. Margins, paddings, heights, and widths aren&#8217;t appropriate.
</li>
<li>Tables have vertical and horizontal alignment and can sometimes behave bizarrely if you have one element of a table without the others (e.g. a table-row with no table-cell). Margins are inappropriate for table-rows and table-cells. Padding is inappropriate for tables and table rows.
</li>
</ul>
<p>If you stick to the tool box that naturally goes with your display type, you will have far fewer bugs and cross-browser differences.</p>
<h4>Positioning</h4>
<p>Next, if you chose block, you must choose your positioning mechanism. (The others are generally positioned according to the normal flow). So for blocks you can choose:</p>
<ul class="basicList">
<li>Float &#8211; brings blocks all the way to the right or left. If you floated something, you made it a block level element, which means previously applied vertical-align or line-height properties may no longer work.
</li>
<li>Absolute &#8211; positions the element relative to it&#8217;s nearest position relative ancestor. Keep in mind that absolutely positioned elements do not trigger reflows and are not reflowed when ancestors and siblings are changed. This is a strength for animations, but can cause display issues if you use too much position absolute with dynamically updating content. (e.g. the old-school example is corners that do not move when more content is added to the box).
</li>
<li>Static &#8211; the default, this is how you get back to a standard element in the normal flow.
</li>
<li>Fixed &#8211; positions the block relative to the viewport. Rarely used.
</li>
<li>Relative &#8211; mostly doesn&#8217;t affect the node it is applied to, but children will get their absolute position relative to this node.</li>
</ul>
<p>I&#8217;m not organized enough to enumerate all the display and positioning types and tell you which can be used/not used with which other properties, so you are going to have to think it through for yourself when debugging and writing code. There are two important things to consider:</p>
<ol>
<li>Do these properties go with the display and positioning types I have chosen?
</li>
<li>Do sibling positioning types go together?
</li>
</ol>
<p>For example, does it make sense to have a float, table-cell, and inline element interacting with each other? What should the browser do with that? Is it defined in the spec? If not, you are probably going against the grain of CSS. That can be ok sometimes, but you should know exactly why you chose to do it and leave extra time for cross browser testing.</p>
<h3>Internet Explorer</h3>
<p>When you have resolved all the discrepancies between the good browsers, you are ready to look at IE. I recommend starting with the oldest version of IE that you need to support because lots of bugs continue to exist in newer versions (in slightly modified form) so you will have less to fix if you start with the worst one. </p>
<p>Even with IE, you want to try to figure out why it is interpreting something differently rather than just hack around it. Adding * and _ hacks to your code willy-nilly is like finding out a function is returning the wrong value (say four less than it should be) and just adding the difference to it rather than figuring out where the math went wrong in the first place.</p>
<pre>
return result+4;
</pre>
<p>That said, it is ok and sometimes necessary to hack IE6 &#038; 7. IE8 usually only needs hacks to accomodate a lack of support for modern CSS3. If you think you need to hack, try to figure out the exact bug you are dealing with. There are tons of resources for this online (anyone remember PIE?). The particular problems which require hacks in IE6 &#038; 7 are:</p>
<ul class="basicList">
<li>Needing to add hasLayout with zoom:1
</li>
<li>Position relative causing things to disappear
</li>
<li>3px float bug
</li>
<li>Expanding container float bug (useful!) and overflow hidden which unfortunately &#8220;fixes&#8221; this useful bug.
</li>
<li>Do you have a favorite IE bug? I&#8217;d love to hear about it in the comments.</li>
</ul>
<p>There are, of course others, but these are the few I&#8217;ve had to hack around for OOCSS. The others occur far less frequently, like the duplicated content bug when you have two floated elements with a comment in between. I don&#8217;t know how to explain figuring out IE bugs because, for the most part, I&#8217;ve internalized them. Like speaking a foreign language. The best I can suggest is to carefully examine what you can see and carefully craft your google search to describe it. Don&#8217;t start hacking until you identify the bug. The dev tools for IE are horrible, so you may need to use background colors to &#8220;see&#8221; the problems. I create debug stylesheets for that purpose.</p>
<h3>Implementing solutions</h3>
<p>When you have figured out what is wrong and you know how to solve it, you are ready to figure out how to put it in your code without breaking everything. Here is my process:</p>
<ol>
<li>Rely on the cascade</li>
<li>Use vendor prefixes</li>
<li>Use * and _ hacks for IE6 &#038; 7</li>
<li>Almost never use \9 for IE8</li>
<li>Know when to quit trying to hack IE</li>
<li>Never use hacks to target the latest versions of Firefox, Chrome, or Safari.</li>
</ol>
<p>That&#8217;s a lot to take in, so I&#8217;ll detail each one below.</p>
<h4>Rely on the Cascade</h4>
<p>First, rely on the cascade whenever possible. CSS has a natural system of fallbacks built right in. Browsers take into account the last value that they were able to understand (this is how the cascade was designed to work). This means that if you order different solutions to the same problem from least advanced to most advanced, browsers will naturally use the most advanced solution they are capable of understanding. For example:</p>
<pre>
.foo{
  background-color: #ccc; /* older browsers will use this */
  background-color: rgba(0,0,0,0.2); /* browsers that understand rgba will use this */
}
</pre>
<h4>Use vendor prefixes</h4>
<p>The next tool you want to employ is vendor prefixes. They allow you to give different values to different browsers, particularly for properties that haven&#8217;t stabilized. </p>
<pre>
background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */
background: linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */
</pre>
<p>Notice the two syntaxes for webkit. Just like normal property fallbacks, vendor prefixes should be ordered from oldest version to newest so that each browser gets the best code it is capable of handling.</p>
<p>If there is a standard syntax, you want to put that last so that as support for the standard increases, more and more browsers will use the best code. This is marked with a comment &#8220;W3C&#8221; in the above code.</p>
<h3>Use * and _ hacks for IE6 &#038; 7</h3>
<p>When you have identified specific IE bugs, and you know how you want to work around them, use _ and * hacks to target that particular browser. For example:</p>
<pre>
.clearfix {
  overflow: hidden; /* new formatting context in better browsers */
  *overflow: visible; /* protect IE7 and older from the overflow property */
  *zoom: 1; /* give IE hasLayout, a new formatting context equivalent */
}
</pre>
<p>All IE hacks target a particular browser and everything before it, so for example: </p>
<ul class="basicList">
<li>_ targets IE6 and older
</li>
<li>* targets IE7 and older, and
</li>
<li>\9 targets IE8 and older UPDATE: IE9 is also targeted for certain properties.
</li>
</ul>
<p>That means that when you use multiple hacks you need to put them in order; underscore, then star, then \9.</p>
<h3>Almost never use \9 for IE8</h3>
<p>That said, I have not really needed to use \9 for any browser quirks in IE8. I use it simply to fill in the gaps when there is a difference in support. For example, if I&#8217;m using a box-shadow in better browsers, and the box looks weird without anything around it in IE8, I&#8217;ll use \9 to add a border for that browser. The cascading technique wouldn&#8217;t work in this case, because the backup method is applied to a different property.</p>
<h3>Know when to quit trying to hack IE</h3>
<p>Don&#8217;t try to make everything exactly the same in IE. It is important to think about what is in the best interest of each set of users. Do you waste another several HTTP requests, extra HTML, JS, and additional CSS to force rounded corners to work in IE6-8? For me, the answer is a clear &#8220;No.&#8221; </p>
<p>It is important to know when to give up on a particular feature. For example, don&#8217;t use filters to simulate css3 gradients. They cause performance issues and layout bugs. It is best to avoid the desire to make your site exactly the same in every single browser regardless of capability. Users of IE 6-8 are much better off with a simplified experience (not broken, just simpler) that with a site that rolls out all the bells and whistles using a ton of polyfills, but is incredibly slow. </p>
<p>For example, avoid the following code to duplicate the gradient from the example above.</p>
<pre>
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */
</pre>
<h3>Never use hacks to target the latest versions of Firefox, Chrome, or Safari.</h3>
<p>Finally, if you think you need to hack to serve different code to Firefox, Chrome, or Safari &#8212; something has gone very awry. It makes sense to go back and look at what you&#8217;ve written to see if you are going against the grain of CSS. </p>
<p>Do you have particular techniques for debugging CSS? Or for implementing fixes once you&#8217;ve found a solution? I&#8217;d love to hear more about it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2012/05/02/cross-browser-debugging-css/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Code formatting for CSS Gradients</title>
		<link>http://www.stubbornella.org/content/2012/03/14/code-formatting-for-css-gradients/</link>
		<comments>http://www.stubbornella.org/content/2012/03/14/code-formatting-for-css-gradients/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 21:53:29 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=875</guid>
		<description><![CDATA[I may have found a way to format CSS3 Gradients that doesn't make my eyes bleed. Yippee! 

I was talking to <a href="https://twitter.com/#!/glan">@glan</a> the other day about CSS3 gradients. We were discussing how to break them down into understandable layers and the difficulties when things you need to know about may be split across multiple properties. At the same time, I was checking out these cool <a href="https://github.com/csswizardry/CSS-Guidelines/blob/master/CSS%20Guidelines.md">CSS Coding Standards</a> shared by <a href="https://twitter.com/#!/csswizardry">@csswizardry</a>, and I started wondering if formatting the code for CSS gradients could make them easier to understand.
]]></description>
			<content:encoded><![CDATA[<p>I may have found a way to format CSS3 Gradients that doesn&#8217;t make my eyes bleed. Yippee! </p>
<p>I was talking to <a href="https://twitter.com/#!/glan">@glan</a> the other day about CSS3 gradients. We were discussing how to break them down into understandable layers and the difficulties when things you need to know about may be split across multiple properties. At the same time, I was checking out these cool <a href="https://github.com/csswizardry/CSS-Guidelines/blob/master/CSS%20Guidelines.md">CSS Coding Standards</a> shared by <a href="https://twitter.com/#!/csswizardry">@csswizardry</a>, and I started wondering if formatting the code for CSS gradients could make them easier to understand.</p>
<p>I grabbed one of <a href="http://lea.verou.me/css3patterns/">Lea Verou&#8217;s CSS3 gradient patterns</a> as a starting point. They are insane and amazing and mind blowing. If you haven&#8217;t checked them out, you totally should. Anyway, I grabbed the code from <a href="http://lea.verou.me/css3patterns/#arrows">the arrows example</a> to try out different formatting options.</p>
<h3>Option A &#8211; One line per property value pair</h3>
<p>Let&#8217;s start off with the standard <strong>one line per property value pair</strong>.</p>
<pre>
.arrows {
	background: linear-gradient(45deg, #92baac 45px, transparent 45px), linear-gradient(45deg, #92baac 45px, transparent 45px)64px 64px, linear-gradient(225deg, transparent 46px, #e1ebbd 46px, #e1ebbd 91px, transparent 91px), linear-gradient(-45deg, #92baac 23px, transparent 23px, transparent 68px,#92baac 68px,#92baac 113px,transparent 113px,transparent 158px,#92baac 158px);
	background-color:#e1ebbd;
	background-size: 128px 128px;
}
</pre>
<p>Ok, awful, right? </p>
<h3>Option B &#8211; Line return for each gradient</h3>
<p>Let&#8217;s try adding a line return for each linear gradient.</p>
<pre>
.arrows {
	background:
	linear-gradient(45deg, #92baac 45px, transparent 45px),
	linear-gradient(45deg, #92baac 45px, transparent 45px)64px 64px,
	linear-gradient(225deg, transparent 46px, #e1ebbd 46px, #e1ebbd 91px, transparent 91px),
	linear-gradient(-45deg, #92baac 23px, transparent 23px, transparent 68px,#92baac 68px,#92baac 113px,transparent 113px,transparent 158px,#92baac 158px);
	background-color:#e1ebbd;
	background-size: 128px 128px;
}
</pre>
<h3>Option C &#8211; Tab per value</h3>
<p>The last example was better, but I could kind of see a pattern in it, so next, I tried formatting it like a table with tabs to separate the columns.</p>
<pre>
.arrows {
	background:
	linear-gradient(45deg,	#92baac		45px,	transparent	45px),
	linear-gradient(45deg,	#92baac		45px,	transparent	45px)	64px		64px,
	linear-gradient(225deg,	transparent	46px,	#e1ebbd		46px,	#e1ebbd		91px,	transparent	91px),
	linear-gradient(-45deg,	#92baac 	23px,	transparent	23px,	transparent	68px,	#92baac 	68px,	#92baac	113px,	transparent	113px,	transparent	158px,	#92baac	158px);
	background-color: #e1ebbd;
	background-size: 128px 128px;
}
</pre>
<p>I wanted to like this option, I really did, but you have things lining up that aren&#8217;t the same kind of values and that feels weird. </p>
<h3>Option D &#8211; Line return per color stop</h3>
<p>So next, I thought I&#8217;d try adding a line return at every comma (thus every color stop).</p>
<pre>
.arrows {
	background:
		linear-gradient(
			45deg,
			#92baac 45px,
			transparent 45px
		), 

		linear-gradient(
			45deg,
			#92baac 45px,
			transparent 45px
		) 64px 64px, 

		linear-gradient(
			225deg,
			transparent 46px,
			#e1ebbd 46px,
			#e1ebbd 91px,
			transparent 91px
		), 

		linear-gradient(
			-45deg,
			#92baac 23px,
			transparent 23px,
			transparent 68px,
			#92baac 68px,
			#92baac 113px,
			transparent 113px,
			transparent 158px,
			#92baac 158px
		);
	background-color:#e1ebbd;
	background-size: 128px 128px;
}
</pre>
<p>Usually I write in a quite compressed style, but I find myself preferring to look at Option D.</p>
<p>What do you think? Would you vote for A, B, C, or D? Do you have a different way of formatting that works well for you? </p>
<p>UPDATE: Don&#8217;t forget to add a pre tag around your example code if you include it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2012/03/14/code-formatting-for-css-gradients/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Scope donuts</title>
		<link>http://www.stubbornella.org/content/2011/10/08/scope-donuts/</link>
		<comments>http://www.stubbornella.org/content/2011/10/08/scope-donuts/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 20:50:35 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[XHTML / HTML]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=854</guid>
		<description><![CDATA[Note: This article is esoteric-could-be-should-be wishing for future browsers. If you only like to hear about what you can use right now, you won't like this. You've been warned. ;)

At first, when the HTML5 working group added the scope attribute I was skeptical. I thought, "oh dear, this is going to be another way for developers to cause massive duplication and inconsistency." I still do worry, but I'm more excited about the tool and hoping we can also find really great things to do with it. 

<h3>Scope is great for mashups</h3>

The first that comes to mind, and the reason it was created, is mashups. Imagine you want to pull in a twitter feed or a video into your page. Unless you intend to rewrite it all (and often widgets block such fine grained control), you'll probably be allowing someone else's CSS onto your page. That can be daunting to say the least. 
]]></description>
			<content:encoded><![CDATA[<p>Note: This article is esoteric-could-be-should-be wishing for future browsers. If you only like to hear about what you can use right now, you won&#8217;t like this. You&#8217;ve been warned. <img src='http://www.stubbornella.org/content/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>At first, when the HTML5 working group added the scope attribute I was skeptical. I thought, &#8220;oh dear, this is going to be another way for developers to cause massive duplication and inconsistency.&#8221; I still do worry, but I&#8217;m more excited about the tool and hoping we can also find really great things to do with it. </p>
<h3>Scope is great for mashups</h3>
<p>The first that comes to mind, and the reason it was created, is mashups. Imagine you want to pull in a twitter feed or a video into your page. Unless you intend to rewrite it all (and often widgets block such fine grained control), you&#8217;ll probably be allowing someone else&#8217;s CSS onto your page. That can be daunting to say the least. </p>
<p>For example, the twitter widget I use pulls in <a href="http://widgets.twimg.com/j/2/widget.css">~1.36kb of CSS</a> that could potentially interfere with my site styles &#8212; and it does it via JavaScript, so unless I&#8217;m ready to switch to using the API rather than a widget, I&#8217;m stuck allowing their styles on my page.</p>
<p>The way to sandbox those styles today is to be sure each style starts with a twitter specific class name. You can see from their code that they did a very good job of it. None of their styles will be polluting mine. Unfortunately, not all widget CSS will be so enlightened (especially not ad code). HTML5 offers another option for allowing authors to sandbox styles called the scope attribute. <a href="http://dstorey.tumblr.com/post/11405550112/scoped">David Storey has a much better explaination of scope on his blog</a>, I&#8217;ve adapted this example from his:</p>
<pre>&lt;div&gt;
  &lt;style <strong>scoped</strong>&gt;
    p { color: blue; }
  &lt;/style&gt;
  &lt;p&gt;The text in this paragraph will be blue&lt;/p&gt;
  &lt;p&gt;And in this paragraph too&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This paragraph is out of scope so will be gray&lt;/p&gt;</pre>
<p>If your browser supports it, it will look like this:</p>
<div style="border: 1px solid gray; padding: 10px;">
<div>
<p style="color:blue">The text in this paragraph will be blue</p>
<p style="color:blue">And in this paragraph too</p>
</div>
<p>This paragraph is out of scope so will be gray</p>
</div>
<p>There are a lot of really great use cases for this, widgets, ads, even large companies with multiple teams putting functionality on a single page. On the other hand, there is a use case for which it falls flat: components. I&#8217;d love to see it extended so it could work for both.</p>
<h3>Scope is more than a starting point, it&#8217;s a donut</h3>
<p><a href="http://www.flickr.com/photos/janicecullivan/3922481017/" title="donuts by mamaloco, on Flickr"><img src="http://farm3.static.flickr.com/2495/3922481017_2fbac85fa1.jpg" width="500" height="332" alt="donuts"/></a><br />
Donuts by <a href="http://www.flickr.com/photos/janicecullivan/3922481017/">mamaloco</a></p>
<p>The interesting thing about UI components (different than ads or widgets) is that they can sometimes contain other unrelated components. You can have a tabset that contains headings, paragraphs, media blocks, or even (holy ugly!) another tabset. Ideally, you would scope the CSS of the tabset to the tabs only, so it can&#8217;t bleed outward and change styles on the rest of the page, <strong>but you also want to prevent the styles from bleeding inward to content components</strong>. So we need a way of saying, not only where scope starts, but where it ends. Thus, the scope donut. The styles affect the donut shape, but not the other components which can be found in the donut hole.</p>
<p><a href="http://www.stubbornella.org/content/wp-content/uploads/2011/10/tabs.png"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/10/tabs.png" alt="Tabs from the admin section of Let&#039;s Freckle, a time tracking app." title="tabs" width="539" height="379" class="alignnone size-full wp-image-859" /></a><br />
Figure 1: Tabs from Let&#8217;s Freckle, a time tracking software.</p>
<p>It has always struck me as odd that scope is declared in the HTML, because ideally with reusable components you wouldn&#8217;t want to repeat that code all over the place. Each of the tabs has different content related to my Freckle settings. The content styles aren&#8217;t specific to the tabs, but may also be used in other parts of the page. We want to make that reuse possible, by keeping our tabs from affecting the way content (the components in the donut hole) components look. I&#8217;d like to do this once, in the CSS, and then have it apply anywhere the component is used.</p>
<p>The first step is to be able to define that component, including both it&#8217;s HTML and CSS. Let&#8217;s start with a basic box. It&#8217;s HTML might look something like this:</p>
<pre>&lt;div class=&quot;box tabs&quot;&gt;
    &lt;div class=&quot;hd&quot;&gt;
    	  Box Header
    &lt;/div&gt;
    &lt;div class=&quot;bd&quot;&gt;
        Box Body
    &lt;/div&gt;
&lt;/div&gt;</pre>
<p>The scope of a box begins at the wrapper div with the class <code>box</code>, and ends at the box body. We don&#8217;t for example want the styles on the box spilling over into whatever content we put in the box. I&#8217;m not sure how exactly to say this in CSS, but I like the idea that using nested selectors implies meaning about the relationship of those parts. e.g. nesting the selectors means that the sub nodes belong to the same component.</p>
<p>In other words, if I applied a text color to my box, it would change the color of text in the header, but not to subnodes in the body. Let&#8217;s take a look at an example syntax. I don&#8217;t really know what the right syntax is, but I&#8217;m more and more convinced it is worth finding a syntax to express it.</p>
<pre>.box {
    border: 1px solid gray;
    color: red; // would cause text in the header to be red, but not inside the body.
    <strong>scope: start;</strong>
    &#038; .hd {
        border-bottom: 1px solid gray;
    }
    &#038; .bd {
        <strong>scope: end;</strong>
    }
}</pre>
<p>This basically says that <code>hd</code> and <code>bd</code> belong to the box object and that the scope of these styles starts at <code>.box</code> and ends at <code>.bd</code>. It prevents styles from bleeding either up or down. Note: I do wonder if we need to say where it starts given that the nature of CSS is that it is namespaced to wherever the selector begins. It also makes me wonder why in the world scope is in the HTML rather than the CSS. It seems oddly out of place. Moving on&#8230;</p>
<p>There are several ways to mark up tabs, but let&#8217;s assume the HTML of the tabs component looks like this:</p>
<pre>&lt;div class=&quot;box <strong>tabs</strong>&quot;&gt;
    &lt;div class=&quot;hd&quot;&gt;
        &lt;ul class=&quot;tabControl&quot;&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Personal&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Date &#038; Time&lt;/a&gt;&lt;/li&gt;
            &lt;li class=&quot;current&quot;&gt;&lt;a href=&quot;#&quot;&gt;Password&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;API&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Timer&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Rounding&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
    &lt;div class=&quot;bd&quot;&gt;
        &lt;ul&gt;
            &lt;li class=&quot;tab-bd&quot;&gt;Tab 1 Content&lt;/li&gt;
            &lt;li class=&quot;tab-bd&quot;&gt;Tab 2 Content&lt;/li&gt;
            &lt;li class=&quot;tab-bd current&quot;&gt;Tab 3 Content&lt;/li&gt;
            &lt;li class=&quot;tab-bd&quot;&gt;Tab 4 Content&lt;/li&gt;
            &lt;li class=&quot;tab-bd&quot;&gt;Tab 5 Content&lt;/li&gt;
            &lt;li class=&quot;tab-bd&quot;&gt;Tab 6 Content&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre>
<p>What you can see is that tabs are an extension of an ordinary box. They have a head and body wrapped in a div with the classes <code>box</code> and <code>tabs</code>. What makes the tabs unique is that both the head and body are filled with unordered lists which correspond to the tab control and tab body respectively.</p>
<p><a href="http://www.stubbornella.org/content/wp-content/uploads/2011/10/tabs-donut.png"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/10/tabs-donut.png" alt="Tabs with the donut highlighted" title="tabs-donut" width="639" height="379" class="alignnone size-full wp-image-861" /></a><br />
Figure 2: Tabs with the donut highlighted. We don&#8217;t want any styles falling either into the donut hole. This where scope ends. (See? It&#8217;s donut colored! Forgive me, this diagram is very very ugly.)</p>
<p>We could try to express the next bit by combining three tools: </p>
<ul class="basicList">
<li>nesting for defining the component structure,</li>
<li>extends so we don&#8217;t need to repeat anything we already know about boxes in the code for tabs, and</li>
<li>a new property &#8220;scope&#8221; which tells the browser where to stop allowing styles to bleed down.</li>
</ul>
<pre>.tab {
    extends: .box; // so inherits the starting scope
    &#038; .tab-bd {
        <strong>scope: end;</strong>
    }
}</pre>
<p>So, any styles for tabs should only apply to the nodes between the start and end of scope, or between <code>.box</code> and <code>.tab-bd</code>. Is this the right syntax? I&#8217;m not sure actually, but I tend to like it.</p>
<p><a href="http://www.stubbornella.org/content/wp-content/uploads/2011/10/tabs-styled-region.png"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/10/tabs-styled-region.png" alt="The region we want to apply styles to." title="tabs-styled-region" width="639" height="379" class="alignnone size-full wp-image-862" /></a><br />
Figure 3: the region we want styles to apply to.</p>
<p>Figure 3 sums up what I&#8217;m asking for &#8212; a way to apply styles only to the divs which make up my object and not to content that simply happens to be inside it. You can do that today with careful use of style and the child selector &#8220;>&#8221;, but in a world where some content is trusted more than other content, it might be easier to just be able to say explicitly which donut of elements I want a particular set of styles to apply to.</p>
<p>You may have heard the Henry Ford quote: </p>
<blockquote><p>If I&#8217;d asked customers what they wanted, they would have said &#8220;a faster horse&#8221;.</p>
<p class="author">Henry Ford</p>
</blockquote>
<p>I think lots of us want *way* more than just a faster horse. <img src='http://www.stubbornella.org/content/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>What do you think? Useful? I&#8217;ve been holding on to this post for four months because I wasn&#8217;t sure about it, because it is quite different from how things work now, but I thought I&#8217;d put it out there and see what other people think.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/10/08/scope-donuts/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t Style Headings Using HTML5 Sections</title>
		<link>http://www.stubbornella.org/content/2011/09/06/style-headings-using-html5-sections/</link>
		<comments>http://www.stubbornella.org/content/2011/09/06/style-headings-using-html5-sections/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 09:43:37 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[oocss]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[XHTML / HTML]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=827</guid>
		<description><![CDATA[Styling headings is either a deceptively complex problem, or maybe the design of CSS made it appear complex when it need not have done. 

When styling headings (or really anything) we want three big goals to be met:

<ol>
	<li>DRY - Do not repeat yourself. We want to set headings once and never (ok, rarely!) repeat those font styles or selectors. This will make our site easier to maintain.</li>
	<li>Predictable - The heading should look the same no matter where on the page it is placed. This will make creating new pages and content easier.</li>
	<li>Keep specificity low and selectors as simple as possible. This will help with performance and keep the site from growing more and more tangled over time.</li>
</ol>

The html5 section tag is weird. It dramatically changes the way we use headings in the HTML. It also changes the way browsers and assistive technologies are meant to interpret those headings. For that reason, we've got to revisit how we style headings. The old way simply won't work anymore! 

It is a subtle difference, but section elements are meant to help the browser figure out what level the heading really is, but not necessarily to decide how to style it. By tying styles to browser heading level interpretation, developers (trying to implement html5 from the spec) are ending up with selectors that look like this:

<pre>
h1{font-size: 36px}
section h1{font-size: 28px}
section section h1{font-size: 22px}
section section section h1{font-size: 18px}
section section section section h1{font-size: 16px}
section section section section section h1{font-size: 14px}
section section section section section section h1{font-size: 13px}
section section section section section section section h1{font-size: 11px}
</pre>

<a href="http://www.stubbornella.org/content/?p=827">Learn how this can go awry and a better way of styling headings</a>.]]></description>
			<content:encoded><![CDATA[<p>Styling headings is either a deceptively complex problem, or maybe the design of CSS made it appear complex when it need not have done. </p>
<p>When styling headings (or really anything) we want three big goals to be met:</p>
<ol>
<li><strong>DRY</strong> &#8211; Do not repeat yourself. We want to set headings once and never (ok, rarely!) repeat those font styles or selectors. This will make our site easier to maintain.</li>
<li><strong>Predictable</strong> &#8211; The heading should look the same no matter where on the page it is placed. This will make creating new pages and content easier.</li>
<li><strong>Keep specificity low and selectors as simple as possible</strong>. This will help with performance and keep the site from growing more and more tangled over time.</li>
</ol>
<p>The html5 section tag is weird. It dramatically changes the way we use headings. It also changes the way browsers and assistive technologies are meant to interpret those headings. The spec says:</p>
<blockquote><p>&#8220;The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.&#8221;<br />
<cite class="author"><a href="http://www.whatwg.org/specs/web-apps/current-work/#the-section-element">The HTML5 Spec</a></cite>
</p></blockquote>
<p>The spec goes on to warn us that sections are not really meant to be used just because you want to attach a style a particular piece of content:</p>
<blockquote id="secondQuote"><p>&#8220;The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element&#8217;s contents would be listed explicitly in the document&#8217;s outline.&#8221;<br />
<cite class="author"><a href="http://www.whatwg.org/specs/web-apps/current-work/#the-section-element">The HTML5 Spec</a></cite>
</p></blockquote>
<p>People seem to have blocked out this last (very important) bit, so I&#8217;ll reiterate. Sections aren&#8217;t really meant to be used by CSS for style purposes (at least not *only* for styles). So, if sections aren&#8217;t meant to be used to make my headings purty, why do they exist? They change the way the browser and assistive technologies interpret the importance of a heading relative to the other headings on the page. To understand this, you need to know a bit about the pitfalls of the way headings have been written up until now.</p>
<h3>HTML Headings</h3>
<p>Think back to the outlines you wrote for term papers in high school. Each bit of a website is meant to be like that, each heading corresponds to a piece of that outline, and you know when you go up or down a level by the heading level chosen. H2 is down one level from H1. And h6 is down four levels from H2.</p>
<pre>
THE TITLE IS THE H1
I. Big roman numerals are the H2s
   A. This is an h3
   B. This is also and h3
      i. Now we have an h4
      ii. And another h4
II. Big roman numerals are the H2s
III. Big roman numerals are the H2s
IV. Big roman numerals are the H2s
</pre>
<p>The trouble is, on a modern website or web app, this model isn&#8217;t a really natural fit. Especially if a site &#8220;mashes up&#8221; content from sources they don&#8217;t control (say for example adding a twitter feed to a blog), they may not be able to set the heading levels used by the mashup content. In this case, most developers, just include the new content, and the outline gets a little murkier. </p>
<p>A murky outline may be somewhat normal, because I&#8217;d take it a step further and say that, on most modern websites, the idea that the site has much in common with a high school term paper outline is a bit of a stretch &#8212; The section element tries to bridge the gap between the w3c&#8217;s outline view of the web and the way developers are really building sites. The <em>section element</em> essentially reorders the heading tree so that whatever headings are used, if they are wrapped in a section element, they will be made to fit in with other content on the page. They need only be internally consistent within each section.</p>
<pre>&lt;h2&gt;Me on the web...&lt;/h2&gt;
&lt;h1&gt;My Twitter Feed&lt;/h1&gt;
&lt;ul class=&quot;tweets&quot;&gt;
 &lt;li&gt;Mmmm, cornflakes.&lt;/li&gt;
 &lt;li&gt;Something inane...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;more.html&quot;&gt;More stuff on the web&lt;/a&gt;&lt;/p&gt;
</pre>
<h3>HTML5 Headings &#038; Section Elements</h3>
<p>If you wrap it in a section, the browser will interpret it as one level down from it&#8217;s parent heading. </p>
<pre>&lt;h2&gt;Me on the web...&lt;/h2&gt;
<strong>&lt;section&gt;</strong>
&lt;h1&gt;My Twitter Feed&lt;/h1&gt;
&lt;ul class=&quot;tweets&quot;&gt;
 &lt;li&gt;Mmmm, cornflakes.&lt;/li&gt;
 &lt;li&gt;Something inane...&lt;/li&gt;
&lt;/ul&gt;
<strong>&lt;/section&gt;</strong>
&lt;p&gt;&lt;a href=&quot;more.html&quot;&gt;More stuff on the web&lt;/a&gt;&lt;/p&gt;</pre>
<p>The section element also makes it clear that the list of tweets belongs to the Twitter feed, and the more link does not. This makes content more portable, which is okay &#8212; even if it maybe isn&#8217;t that important. However, it does seem to be confusing people about how they should <strong>style</strong> their headings. I think this bit of the spec might be confusing people:</p>
<blockquote><p>Notice how the use of section means that the author can use h1 elements throughout, without having to worry about whether a particular section is at the top level, the second level, the third level, and so on.<br />
<cite class="author"><a href="http://www.whatwg.org/specs/web-apps/current-work/#the-section-element">The HTML5 Spec</a></cite>
</p></blockquote>
<p>This has lead people to think that they should only ever use h1s (which, is a fair interpretation of the working group&#8217;s note). However, lots of people have taken it a little too far because they didn&#8217;t read the second quote <a href="#secondQuote">[1]</a>, where it says additional section elements shouldn&#8217;t really be used only to apply CSS styles. Admittedly a subtle difference, but important! Section elements are meant to help the browser figure out what level the heading really is, but not necessarily to decide how to style it. By tying styles to browser heading level interpretation, developers (trying to implement html5 from the spec) are ending up with selectors that look like this:</p>
<pre>
h1{font-size: 36px}
section h1{font-size: 28px}
section section h1{font-size: 22px}
section section section h1{font-size: 18px}
section section section section h1{font-size: 16px}
section section section section section h1{font-size: 14px}
section section section section section section h1{font-size: 13px}
section section section section section section section h1{font-size: 11px}
</pre>
<p>(Note: This is vastly simplified as I&#8217;ve only included sections and not the other sectioning elements like <code>articles</code> or <code>asides</code>. <a href="https://github.com/cboone/hypsometric-css/blob/master/html5/html5-defaults.css#L426">This is a more realistic, real life code sample</a>.)</p>
<h3>Let&#8217;s see how well this meets our goals:</h3>
<h4>Q: What if, semantically speaking, you need to add an additional section to a bit of html? </h4>
<p>It will unintentionally change the way your headings look. If it is high enough on the document tree it could change your entire page. That seems badly unpredictable.</p>
<h4>Q: What happens if the design calls for a 14px heading in a part of the site that is only nested two sectioning contents deep?</h4>
<p>To make it work with the existing code, you would need to add additional unnecessary section elements. The spec pretty clearly states that section elements are not meant to be added just to change styles. Plus, that is just kind of gross.</p>
<h4>Q: What if we create another rule that duplicates the 14px property value pair?</h4>
<pre>
section.special section h1 {font-size:14px}
</pre>
<p>This clearly isn&#8217;t DRY. We&#8217;re repeating the code to set the font-size to 14px, and our specificity is starting to get weird. If we want a normal two-section deep heading (22px) we now can&#8217;t have it in the special section. We also can&#8217;t reuse the new rule anywhere else. Continue in this direction for a while on a project and you can end up with hundreds or even thousands of heading declarations. Eek! This isn&#8217;t meeting our stated goals at all.</p>
<p>(For more info about how this can get out of control, check out this <a href="http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/">video on how our current methods for styling headings are leading to bad outcomes</a>.)</p>
<h3>So, how do we style headings in an HTML5 world?</h3>
<p>The answer is right there in the spec, next to the place where we learned to use only H1s. <strong>We shouldn&#8217;t use sectioning elements for styling.</strong> We should let them do the job they were designed for, which is sorting out the document tree, and solve styling issues another way that meets our goals better: with simple reusable class names that can be applied to any of our headings no matter how deep they may be in the sectioning content.</p>
<p>I recommend abstracting site wide headings into classes because then they are portable, predictable, and dry. You can call them anything you like. Jeremy Keith recommends something like: </p>
<pre>
.Alpha {}
.Beta {}
.Gamma {}
.Delta {}
.Epsilon {}
.Zeta {}
</pre>
<p>or </p>
<pre>
.tera {}
.giga {}
.mega {}
.kilo {}
.hecto {}
.deca {}
.deci {}
.centi {}
.milli {}
.micro {}
.nano {}
.pico {}
</pre>
<p>I keep it simple with: </p>
<pre>
.h1{}
.h2{}
.h3{}
.h4{}
.h5{}
.h6{}
</pre>
<p>It doesn&#8217;t really matter what <a href="https://github.com/stubbornella/oocss/blob/master/core/heading/heading.css">system</a> you choose as long as it is something easy for your team to remember. Then, no matter how many section levels deep your heading is nested, you can make it look just how you want:</p>
<pre>&lt;h1 class=&quot;<strong>giga</strong>&quot;&gt;Me on the web...&lt;/h1&gt;
&lt;section&gt;
  &lt;h1 class=&quot;<strong>kilo</strong>&quot;&gt;My Twitter Feed&lt;/h1&gt;
  &lt;ul class=&quot;tweets&quot;&gt;
    &lt;li&gt;Mmmm, cornflakes.&lt;/li&gt;
    &lt;li&gt;Something inane...&lt;/li&gt;
  &lt;/ul&gt;
&lt;/section&gt;
&lt;p&gt;&lt;a href=&quot;more.html&quot;&gt;More stuff on the web&lt;/a&gt;&lt;/p&gt;</pre>
<p>So now, your twitter feed, from the previous example, can be in the sidebar on an article page, or in the footer of your homepage, and it will still look the way it was designed to. Whether you are using html5 sections or not, you don&#8217;t want to repeat code or have it be unpredictable, so I think separating styles from how the browser generates the page outline is just sensible. </p>
<p>UPDATE 9/6: If you truly cannot change the HTML, even to add class names, then the only way to style that bit is to put a wrapper around it with a unique class and use descendent selectors to force the style you want. This should be the exception, not the rule! (Thanks Simon for pointing out that I wasn&#8217;t addressing one of the use cases I had talked about above)</p>
<pre>&lt;h1 class=&quot;giga&quot;&gt;Me on the web...&lt;/h1&gt;
&lt;section<strong> class="tweetfeed"&gt;</strong>
  &lt;h1&gt;My Twitter Feed&lt;/h1&gt;
  &lt;ul class=&quot;tweets&quot;&gt;
    &lt;li&gt;Mmmm, cornflakes.&lt;/li&gt;
    &lt;li&gt;Something inane...&lt;/li&gt;
  &lt;/ul&gt;
&lt;/section&gt;
&lt;p&gt;&lt;a href=&quot;more.html&quot;&gt;More stuff on the web&lt;/a&gt;&lt;/p&gt;</pre>
<p>If you would like a far more eloquent walk through all the new html5 elements, get <a href="http://adactio.com">Jeremy Keith&#8217;s</a> book <a href="http://www.abookapart.com/products/html5-for-web-designers">HTML5 For Web Designers</a>.</p>
<p>Thanks to Alex Kessinger and Josh for helping me solidify my thoughts around this by <a href="http://groups.google.com/group/css-lint/browse_thread/thread/dc33aaa950765efb?hl=en_US">bringing up good questions</a> on the <a href="http://csslint.net">CSS Lint</a> Google Group.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/09/06/style-headings-using-html5-sections/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>CSS Lint open sourced</title>
		<link>http://www.stubbornella.org/content/2011/06/15/css-lint-open-sourced/</link>
		<comments>http://www.stubbornella.org/content/2011/06/15/css-lint-open-sourced/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 22:06:53 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[oocss]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=820</guid>
		<description><![CDATA[<a href="http://nczonline.net">Nicholas Zakas</a> and I spoke at Velocity a few minutes ago. First we talked about CSS 3 and it's impact on performance, then we demoed and open sourced <a href="http://csslint.net">CSS Lint</a>! I really couldn't be more excited (or relieved, I was super duper nervous before this presentation).

CSS Lint is a tool to help point out problems with your CSS code. It does basic syntax checking as well as applying a set of rules to the code that look for problematic patterns or signs of inefficiency. The rules are all pluggable, so you can easily write your own or omit ones you don't want.]]></description>
			<content:encoded><![CDATA[<p><a href="http://nczonline.net">Nicholas Zakas</a> and I spoke at Velocity a few minutes ago. First we talked about CSS 3 and it&#8217;s impact on performance, then we demoed and open sourced <a href="http://csslint.net">CSS Lint</a>! I really couldn&#8217;t be more excited (or relieved, I was super duper nervous before this presentation).</p>
<p>CSS Lint is a tool to help point out problems with your CSS code. It does basic syntax checking as well as applying a set of rules to the code that look for problematic patterns or signs of inefficiency. The rules are all pluggable, so you can easily write your own or omit ones you don&#8217;t want.</p>
<h3>Rules currently tested </h3>
<ul class="basicList">
<li>Parsing errors should be fixed
</li>
<li>Don&#8217;t use adjoining classes
</li>
<li>Remove empty rules
</li>
<li>Use correct properties for a display
</li>
<li>Don&#8217;t use too many floats
</li>
<li>Don&#8217;t use too many web fonts
</li>
<li>Don&#8217;t use too may font-size declarations
</li>
<li>Don&#8217;t use IDs in selectors
</li>
<li>Don&#8217;t qualify headings
</li>
<li>Heading elements should have a consistent appearance across a site.
</li>
<li>Heading styles should only be defined once
</li>
<li>Be careful using width: 100%
</li>
<li>Zero values don&#8217;t need units
</li>
<li>Vendor prefixed properties should also have the standard
</li>
<li>CSS gradients require all browser prefixes
</li>
<li>Avoid selectors that look like regular expressions
</li>
<li>Beware of broken box models</li>
</ul>
<p>(We&#8217;ll allow you to turn off rules that hurt your feelings soon!)</p>
<h3>Contribute</h3>
<p>Many people have expressed an interest in contributing to the CSS Lint project. We were waiting to have a solid plugable architecture and API before taking contributions. The exciting news is that we are now ready! There are several ways you can contribute:</p>
<ol class="enumlist">
<li>If you are comfortable with CSS, <a href="https://github.com/stubbornella/csslint/issues">submit rule ideas</a>. You must provide the rule name, a human readable explanation, browsers affected, and a test case.</li>
<li>If you are comfortable in JavaScript, <a href="https://github.com/stubbornella/csslint">fork the github project</a>, code up a rule, and submit a pull request. You&#8217;ll need to provide all the same documentation requsted in item 1.</li>
<li>If you are comfortable with Node, <a href="https://github.com/stubbornella/csslint/tree/master/src/node">test out the command line version</a>, submit feature requests.</li>
</ol>
<h2 id="node">CSS Lint for Node.js</h2>
<p>If you&#8217;d like a command line version of CSS Lint, you can install CSS Lint for Node.js using <a href="http://npmjs.org">npm</a> using the following:</p>
<pre><code>sudo npm install -g csslint</code></pre>
<p>Once installed, you can pass in any number of CSS files or directories containing CSS files to see the results. For example:</p>
<pre><code>csslint test.css dir_of_css/ test2.css</code></pre>
<p>You&#8217;ll receive the same errors and warnings as you would with the web interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/06/15/css-lint-open-sourced/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Welcoming Nicholas Zakas to the Team</title>
		<link>http://www.stubbornella.org/content/2011/06/03/welcoming-nicholas-zakas-to-the-team/</link>
		<comments>http://www.stubbornella.org/content/2011/06/03/welcoming-nicholas-zakas-to-the-team/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 15:30:11 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Latest Happenings]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=806</guid>
		<description><![CDATA[I am so very pleased to announce that <a href="http://www.nczonline.net/blog/2011/06/03/on-leaving-yahoo-and-whats-next/">Nicholas Zakas and I are joining forces</a> to form a consulting duo. Nicholas has spent the last five years defining what it meant to to be a client-side engineer at Yahoo!. He consistently raised the client-side glass ceiling with his commitment to good code and practical solutions. He also literally wrote the book on <a href="http://www.amazon.com/gp/product/059680279X/ref=as_li_ss_tl?ie=UTF8&#038;tag=nicolsulli-20&#038;linkCode=as2&#038;camp=217153&#038;creative=399349&#038;creativeASIN=059680279X">JavaScript Performance</a><img src="http://www.assoc-amazon.com/e/ir?t=&#038;l=as2&#038;o=1&#038;a=059680279X&#038;camp=217153&#038;creative=399349" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. Like me, Nicholas cares deeply about performance and scalability. And, most importantly, we share a love of finding elegant solutions to hard problems, which we feel makes us a good match. 

I'll let Nicholas speak for himself:

<blockquote>I’ll be ... teaming up with my friend (and former Yahoo) Nicole Sullivan to do consulting work. Nicole and I have talked off and on about working together on outside projects after having fun working together on a couple of projects at Yahoo!. Between the two of us, we hope to provide a wide range of front-end consulting services including performance evaluations, general architecture, and of course, JavaScript and CSS. If you’re interested in hiring us, please email projects (at) stubbornella.org.
<cite class="author">Nicholas Zakas</cite>
</blockquote>


Please come see us at <a href="http://velocityconf.com/velocity2011">Velocity Conference</a> on June 14.  ]]></description>
			<content:encoded><![CDATA[<p>I am so very pleased to announce that <a href="http://www.nczonline.net/blog/2011/06/03/on-leaving-yahoo-and-whats-next/">Nicholas Zakas and I are joining forces</a> to form a consulting duo. Nicholas has spent the last five years defining what it meant to to be a client-side engineer at Yahoo!. He consistently raised the client-side glass ceiling with his commitment to good code and practical solutions. He also literally wrote the book on <a href="http://www.amazon.com/gp/product/059680279X/ref=as_li_ss_tl?ie=UTF8&#038;tag=nicolsulli-20&#038;linkCode=as2&#038;camp=217153&#038;creative=399349&#038;creativeASIN=059680279X">JavaScript Performance</a><img src="http://www.assoc-amazon.com/e/ir?t=&#038;l=as2&#038;o=1&#038;a=059680279X&#038;camp=217153&#038;creative=399349" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. Like me, Nicholas cares deeply about performance and scalability. And, most importantly, we share a love of finding elegant solutions to hard problems, which we feel makes us a good match. </p>
<p>I&#8217;ll let Nicholas speak for himself:</p>
<blockquote><p>I’ll be &#8230; teaming up with my friend (and former Yahoo) Nicole Sullivan to do consulting work. Nicole and I have talked off and on about working together on outside projects after having fun working together on a couple of projects at Yahoo!. Between the two of us, we hope to provide a wide range of front-end consulting services including performance evaluations, general architecture, and of course, JavaScript and CSS. If you’re interested in hiring us, please email projects (at) stubbornella.org.<br />
<cite class="author">Nicholas Zakas</cite>
</p></blockquote>
<p>Please come see us at <a href="http://velocityconf.com/velocity2011">Velocity Conference</a> on June 14.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/06/03/welcoming-nicholas-zakas-to-the-team/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Our (CSS) Best Practices Are Killing US</title>
		<link>http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/</link>
		<comments>http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:09:18 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[oocss]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[XHTML / HTML]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=785</guid>
		<description><![CDATA[I was prepping to speak at <a href="http://www.webstock.org.nz/">Webstock</a> this year when I realized I didn't want to give the talk I had proposed. I didn't want to talk about the <em>Mistakes of Massive CSS</em>, because I realized it went deeper than that. In fact, in most cases, the things we considered best practices were <strong>leading to the bad outcomes</strong> we sought to avoid. I realized (unpopular though it might be), that we couldn't make it work out well by <strong>trying harder</strong>. Each time we start a new project, we think "this time, I'm going to keep the code clean. This time the project will be a shining example of what can be done with CSS." And without fail, over time, as more content and features are added to the site, the code becomes a spaghetti tangle of duplication and unpredictability. 

It is time to let ourselves off the hook. There is nothing we could have done by trying harder. There is no magic juju that some other developer has that we don't. Following our beloved best practices leads to bad outcomes every. single. time.

What are those flawed best practices?

<ul class="basicList">
	<li>Classitis!</li>
	<li>Never add an non-semantic element </li>
	<li>Or, a non-semantic class</li>
	<li>Use descendant selectors exclusively</li>
</ul>

<a href="http://www.stubbornella.org/content/?p=785">Here is the video of my talk at Webstock 2011</a>.]]></description>
			<content:encoded><![CDATA[<p>Another day, another melodramatic blog post title. <img src='http://www.stubbornella.org/content/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I was prepping to speak at <a href="http://www.webstock.org.nz/">Webstock</a> this year when I realized I didn&#8217;t want to give the talk I had proposed. I didn&#8217;t want to talk about the <em>Mistakes of Massive CSS</em>, because I realized it went deeper than that. In fact, in most cases, the things we considered best practices were <strong>leading to the bad outcomes</strong> we sought to avoid. I realized (unpopular though it might be), that we couldn&#8217;t make it work out well by <strong>trying harder</strong>. Each time we start a new project, we think &#8220;this time, I&#8217;m going to keep the code clean. This time the project will be a shining example of what can be done with CSS.&#8221; And without fail, over time, as more content and features are added to the site, the code becomes a spaghetti tangle of duplication and unpredictability. </p>
<p>It is time to let ourselves off the hook. There is nothing we could have done by trying harder. There is no magic juju that some other developer has that we don&#8217;t. Following our beloved best practices leads to bad outcomes every. single. time.</p>
<p>What are those flawed best practices?</p>
<ul class="basicList">
<li>Classitis!</li>
<li>Never add an non-semantic element </li>
<li>Or, a non-semantic class</li>
<li>Use descendant selectors exclusively</li>
<li>Sites need to look exactly the same in every browser</li>
</ul>
<p>Here is the video of my talk at Webstock 2011:</p>
<p><a href="http://www.webstock.org.nz/talks/speakers/nicole-sullivan/css-tools-massive-websites/"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/04/webstock1.jpg" alt="" title="webstock" width="500" height="330" class="alignnone size-full wp-image-801" /></a></p>
<h3>Classitis!</h3>
<p>How in the world did we even get the idea that some aspects of CSS were good and others evil? Who decided and what data did they use to judge? Did their goals fit our goals? There is nothing wrong with using classes. In almost every case, classes work well and have fewer unintended consequences than either IDs or element selectors. </p>
<p>You should style almost everything with classes. The goal is to find a balance between classes that are too broad and include everything and the kitchen sink and classes that are too narrow. Generally speaking, you don&#8217;t want your classes to be so narrow that each one applies a single property value pair. It becomes extremely hard to evolve your design if every item is composed of mini-mixins. </p>
<p>On the other hand, if classes are too broad, you will have duplication. Try to find the middle ground where all the repeating visual patterns can be abstracted. This is hard, but very worthwhile. If you do it, your code will stay clean. You will finally see results from trying harder.</p>
<p>Classes are our friends. Seeing a lot of IDs is actually very bad. Run from this kind of code:</p>
<pre>
#sidebar #accounts #accountDetails h3{}
</pre>
<h3>Never add non semantic elements</h3>
<p>We don&#8217;t want to have unnecessarily heavy HTML with a lot of extra elements. On the other hand, adding an extra element can often provide a buffer between two sets of classes that weren&#8217;t necessarily coded to interact with one another. For example, I prefer to have the decorative elements of a container completely separated from its content. </p>
<p>Using a paragraph that happens to be inside a rounded corner box to make a corner decoration means that the container can never hold content other than a paragraph. If you want to include a <code>UL</code> you will need to duplicate all those styles. This doesn&#8217;t work.</p>
<p>You want your content to be marked up in beautiful HTML that uses a diverse set of tags like <code>P, UL, OL, LI, H1-6, strong, em</code>. Add a few extra wrapper elements to keep your content nicely cordoned off from your containers or separate out decorative flourishes! Your HTML will be clean and your CSS predictable.</p>
<h3>Never add non-semantic classes</h3>
<p>We absolutely don&#8217;t ever want to use classes like &#8220;bigRedHeading&#8221;, not because it is non-semantic, but because it isn&#8217;t future proof. As the design evolves, the CSS needs to keep pace. On the other hand, CSS needs <strong>abstractions</strong>. We need to be able to solve a particular problem really well, and then allow people to go on using that solution long afterward. Grids for example solve the layout problem. Once they have been implemented on a site, developers can spend time on more important features and stop re-implementing a layout solution over and over. Abstract solutions are <em>necessarily</em> disconnected from the content they happen to contain. This is something we should look for in a solution, not condemn.</p>
<p>The semantics debate has really gone too far. It is useful as a general principal, but often I see standards aware developers trying to stuff in semantics that never existed in the design. If the design didn&#8217;t make a distinction between two things visually, why add additional complexity?  Classes work much better when we use them to represent visual semantics, rather than keeping them tied to content. </p>
<p>One more point on the topic. Screen readers don&#8217;t read class names. It is not an accessibility issue. (Thanks to John Foliot for confirming)</p>
<h3>Use descendant selectors exclusively</h3>
<p>Never has more terrible advice been given (ok, ok, I exaggerate, but for CSS, this is as bad as it gets). The descendent selector is *only* appropriate between multiple nodes of the same object (say, a tab container and its&#8217; tabs), and even then, only when you are absolutely certain that there will never be any markup changes. Very hard to guarantee, no?</p>
<p>I have had a designer give me a tab container that had one group of tabs to the left and another grouping (usually more simply styled) to the right. In which case, if you had styled the UL using the descendant selector, you would be stuck overriding a bunch of styles you no longer needed. Classes are much much better and can be used in combination with the descendant selector when the nodes belong to the same object.</p>
<p>I guess the only time I use the descendant selector with elements is to style LI, and even then, I often get bitten when someone wants to nest those lists. Better support for the child selector will make that issue easier to fix. Ideally, we don&#8217;t want any styles flowing from container to content.</p>
<p>Even with the media block, you might consider putting a class on the media block which sets the styles of the image. It sounds reasonable until you realize that the image is actually its own object. You might have multiple nested media blocks and you will get very weird interactions unless you apply the image style class directly to the image itself. </p>
<p>In the middle layer, you might decide to create one display objects for each of the different types, and that would probably make the objects easier to use, but in the CSS layer, you don&#8217;t want to tie it all together like that.</p>
<h3>Sites need to look exactly the same in every browser</h3>
<p>Forking your design is bad, it makes testing even more complicated, but that doesn&#8217;t mean that pixel for pixel a site needs to be exactly the same in every browser. If you try to force the complexities of a modern design onto users of IE6, their user experience will suffer. The site will load slower and reflows and repaints will make the javascript sluggish. IE6 users need a reasonably fast user experience, they do not *need* rounded corners. </p>
<p>Anyway, enough ranting. Please do checkout the slides and video. I hope you find them useful.</p>
<div style="width:425px" id="__ss_7451831"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/stubbornella/our-best-practices-are-killing-us" title="Our Best Practices Are Killing Us">Our Best Practices Are Killing Us</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/7451831" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/stubbornella">Nicole Sullivan</a> </div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Automating CSS 3 Gradients</title>
		<link>http://www.stubbornella.org/content/2011/04/25/css-3-gradients/</link>
		<comments>http://www.stubbornella.org/content/2011/04/25/css-3-gradients/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 23:04:25 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[oocss]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=771</guid>
		<description><![CDATA[CSS 3 is full of ways to reduce our dependence on background images, one of which is pure CSS gradients. They have several features, which I'm sure designers are salivating over, like multiple color stops, and angled, radial, and linear gradients. Many people had built cool designer-focused tools to make interacting with a somewhat confusing gradient syntax a little easier. The issue for me has been that I'm not a designer. I generally work off of photoshop comps or (when doing big re-architecture projects) the site itself, as if the old version were a design. This means that, for the most part, I was trying desperately to match CSS gradients to an image with zero information about how that image would have been created. Because of my focus on fixing old and broken CSS, the original designer may not even still work at the company.

If you don't know what I mean, picture me with a color picker going pixel by pixel to try to figure out by hand where the color stops should be and what colors I should use versus extrapolate. Then, for each version, making an image of the gradient I've created, blowing it up so I can compare it to the image of the original. Rinse, repeat until I've come up with something that kinda, sorta approximates the original. Oh yeah, painful. ]]></description>
			<content:encoded><![CDATA[<p>CSS 3 is full of ways to reduce our dependence on background images, one of which is pure CSS gradients. They have several features, which I&#8217;m sure designers are salivating over, like multiple color stops, and angled, radial, and linear gradients. Many people had built cool designer-focused tools to make interacting with a somewhat confusing gradient syntax a little easier. The issue for me has been that I&#8217;m not a designer. I generally work off of photoshop comps or (when doing big re-architecture projects) the site itself, as if the old version were a design. This means that, for the most part, I was trying desperately to match CSS gradients to an image with zero information about how that image would have been created. Because of my focus on fixing old and broken CSS, the original designer may not even still work at the company.</p>
<p>If you don&#8217;t know what I mean, picture me with a color picker going pixel by pixel to try to figure out by hand where the color stops should be and what colors I should use versus extrapolate. Then, for each version, making an image of the gradient I&#8217;ve created, blowing it up so I can compare it to the image of the original. Rinse, repeat until I&#8217;ve come up with something that kinda, sorta approximates the original. Oh yeah, painful. </p>
<p><span id="more-771"></span></p>
<p>Which lead me to tweet the following:</p>
<p><a href="https://twitter.com/#!/stubbornella/status/61499795801505792"><img alt=" I need a tool where I upload an image of a gradient and it spits out the CSS required to create that gradient... exists?" src="https://img.skitch.com/20110423-dh9axwes4t8d8srfcsw1n774i4.png" class="alignnone" width="632" height="344" /></a></p>
<p>There was a lot of response, many people re-tweeted saying that if I found such a tool, they wanted to know about it! Several others said it was interesting, but that the more complex cases would be difficult to navigate. Twelve hours later, Philip Tellis had gone from not knowing what a CSS 3 gradient was, to writing an <a href="https://github.com/bluesmoon/pngtocss">open source command line tool to convert png to CSS</a>. It solved for linear gradients, which is exactly what I needed to fix the performance of sites whose that had gotten sloggy. Most of these sites used linear gradients as images, which are notoriously difficult to sprite.</p>
<p><a href="https://github.com/bluesmoon/pngtocss"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/04/philipstool.png" alt="@bluesmoon Philip Tellis @stubbornella ok, I just wrote a tool to do that. here: https://github.com/bluesmoon/pngtocss it&#039;s command line only" title="philipstool" width="585" height="285" class="alignnone size-full wp-image-772" /></a></p>
<p>I was excited, to give it a try, and also, a little nervous to once again meet my nemesis, the command line. Then, before I could blink Zoompf took Philip&#8217;s BSD licensed code and created a hosted version (w00t! hosted version!):</p>
<p><a href="http://zoompf.com/grad2css.html"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/04/zoompf.png" alt="Hosted ported @bluesmoon&#039;s png2css Create CSS for background imgs w/ gradients. http://zoompf.com/grad2css.html /cc: @webinista @nimbuin" title="zoompf" width="513" height="294" class="alignnone size-full wp-image-774" /></a></p>
<p>In the mean time, Colorzilla, creators of several fab tools for designers, had also gotten word about my plea for a conversion tool, and they thought it would be a great addition to their own functionality. A couple days later they tweeted that they had a prototype up:</p>
<p><a href="http://bit.ly/bY6lSb"><img src="http://www.stubbornella.org/content/wp-content/uploads/2011/04/colorzilla.png" alt="@stubbornella &#039;import gradient from image&#039; is now live! supports multi-stop gradients. Check it out - http://bit.ly/bY6lSb :)" title="colorzilla" width="510" height="256" class="alignnone size-full wp-image-775" /></a></p>
<p>Perhaps I&#8217;m being a little too Californian, but I have a warm fuzzy feeling about our community. I think one of the biggest challenges we are going to face is the lack of tools we have relative to other communities. So when we can come together to build tools that will save loads of developer time, I kind of love it. Even better, Philip&#8217;s choice to open source his work meant that others were free to expand upon it.</p>
<p>Is anyone else doing something really cool with CSS 3 gradients? I&#8217;d love to hear more about it. The <a href="http://leaverou.me/css3patterns/">CSS 3 Pattern Gallery</a> kind of blew my mind. With every example, the boundaries of what is possible expand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/04/25/css-3-gradients/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Performance Double Whammy Hits New Zealand at Webstock</title>
		<link>http://www.stubbornella.org/content/2011/02/07/performance-double-whammy-hits-new-zealand-at-webstock/</link>
		<comments>http://www.stubbornella.org/content/2011/02/07/performance-double-whammy-hits-new-zealand-at-webstock/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 17:37:56 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[oocss]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[XHTML / HTML]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=757</guid>
		<description><![CDATA[Interested in Performance and scaling sites to a large number of visitors or pages? I just realized <strong>both</strong> Steve Souders and I will be giving talks at Webstock <em>next week</em>! This is a pretty amazing opportunity to massively increase your Performance mojo in one go. :)

I'm going to be hosting a workshop in which you will learn to <a href="http://www.webstock.org.nz/11/programme/workshops.php#sullivan">build your own site using OOCSS techniques</a>. By the time you leave you will have the skills necessary to write efficient, scalable CSS. You'll understand the joy and pain of CSS3 and HTML5, and be ready to go build the next generation of websites and web apps.

<a href="http://www.webstock.org.nz/11/programme/workshops.php#souders">Steve's workshop is filled with Mobile yummy goodness</a>. How do you figure out that your mobile app is slow <strong>before</strong> your clients start complaining? What's even going on in there? In his workshop, Steve is going to open up the mobile black-box and teach you to take a peek inside.

I am super excited about Webstock, even more so now that I found out it will be a perf-geek-meet-up. New Zealand here I come! 

]]></description>
			<content:encoded><![CDATA[<p>Interested in Performance and scaling sites to a large number of visitors or pages? I just realized <strong>both</strong> Steve Souders and I will be giving talks at Webstock <em>next week</em>! This is a pretty amazing opportunity to massively increase your Performance mojo in one go. <img src='http://www.stubbornella.org/content/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;m going to be hosting a workshop in which you will learn to <a href="http://www.webstock.org.nz/11/programme/workshops.php#sullivan">build your own site using OOCSS techniques</a>. By the time you leave you will have the skills necessary to write efficient, scalable CSS. You&#8217;ll understand the joy and pain of CSS3 and HTML5, and be ready to go build the next generation of websites and web apps.</p>
<p><a href="http://www.webstock.org.nz/11/programme/workshops.php#souders">Steve&#8217;s workshop is filled with Mobile yummy goodness</a>. How do you figure out that your mobile app is slow <strong>before</strong> your clients start complaining? What&#8217;s even going on in there? In his workshop, Steve is going to open up the mobile black-box and teach you to take a peek inside.</p>
<p>I am super excited about Webstock, even more so now that I found out it will be a perf-geek-meet-up. New Zealand here I come! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/02/07/performance-double-whammy-hits-new-zealand-at-webstock/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Grids improve site performance</title>
		<link>http://www.stubbornella.org/content/2011/01/22/grids-improve-site-performance/</link>
		<comments>http://www.stubbornella.org/content/2011/01/22/grids-improve-site-performance/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 23:29:47 +0000</pubDate>
		<dc:creator>Nicole Sullivan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[XHTML / HTML]]></category>

		<guid isPermaLink="false">http://www.stubbornella.org/content/?p=96</guid>
		<description><![CDATA[CSS grids can improve performance?  How so?

<h3>The Importance of Page Weight</h3> 

The weightier your page the slower the user experience.  There are a few notable ways you can ease this correlation, but for the most part keeping your pages snappy is about being absolutely relentless when reducing and optimizing code.  CSS is no exception.

On the other hand, a blank white page with unstyled black text and blue links would be very fast -- but no one would care to visit.  When we accept that we want sites which are both graphically interesting <em>and</em> fast we can begin to find ways to achieve what I think of as a <strong>one to many</strong> relationship between the amount of CSS we write and the potential layouts we can achieve.

<h3>The cure for bloat</h3>

Finding common denominators in our site will allow us to standardize the way we group related content, and the classes we use to style that content.  You can think of these common denominators as the semantic building blocks of a high performance website. On a basic level that means that most sites have a particular way of displaying, for instance, a product.  Perhaps with an image of the product to the left and a description of the product to the right.  If that configuration appears throughout the site it should not be rewritten each time or we'll have a 1:1 correlation between the size of the CSS and the complexity or number of pages in the site.  These are the kind of sites that might start off fast but over the course of their lifetime become slower and slower. Once clean CSS becomes bloated with unnecessary recoding of semantically and visually identical elements.]]></description>
			<content:encoded><![CDATA[<p>CSS grids can improve performance?  How so?</p>
<h3>The Importance of Page Weight</h3>
<p>The weightier your page the slower the user experience.  There are a few notable ways you can ease this correlation, but for the most part keeping your pages snappy is about being absolutely relentless when reducing and optimizing code.  CSS is no exception.</p>
<p>On the other hand, a blank white page with unstyled black text and blue links would be very fast &#8212; but no one would care to visit.  When we accept that we want sites which are both graphically interesting <em>and</em> fast we can begin to find ways to achieve what I think of as a <strong>one to many</strong> relationship between the amount of CSS we write and the potential layouts we can achieve.</p>
<h3>The cure for bloat</h3>
<p>Finding common denominators in our site will allow us to standardize the way we group related content, and the classes we use to style that content.  You can think of these common denominators as the semantic building blocks of a high performance website. On a basic level that means that most sites have a particular way of displaying, for instance, a product.  Perhaps with an image of the product to the left and a description of the product to the right.  If that configuration appears throughout the site it should not be rewritten each time or we&#8217;ll have a 1:1 correlation between the size of the CSS and the complexity or number of pages in the site.  These are the kind of sites that might start off fast but over the course of their lifetime become slower and slower. Once clean CSS becomes bloated with unnecessary recoding of semantically and visually identical elements.</p>
<h3>Where do grids fit into the mix? </h3>
<p>Grids are one of the simplest examples (to see, not to code) of patterns that can be abstracted across a site.  The same basic three unit pattern which divides grouped content into three semantically linked chunks can be seen inside the main column content and also inside a module, defining different groups of content. In the next two pictures, I&#8217;ve outlined in orange the same grid being used two ways. Not coding this again and again is a huge performance win when multiplied over all the components and pages of a large site.</p>
<p>Image 1: Grids can be used to define the structure of the main column of a page.<br />
<img src="http://www.stubbornella.org/content/wp-content/uploads/2007/12/grids_macro.png" alt="Grids Macro" /></p>
<p>Image 2: The same grids being used to break up the content within the body of a module.<br />
<img src="http://www.stubbornella.org/content/wp-content/uploads/2007/12/grids_micro.png" alt="Grids Micro" /></p>
<p>It&#8217;s easy to see each piece of your site as a one-off, unique, something which will never vary &#8212; but performance dictates that we take a more sage approach. We need to abstract objects, the simple building blocks of your pages.  The objects can then be combined to create pages and the pages combined to create entire sites.  </p>
<h3>Do not reinvent the wheel, grasshopper (at least not for a major client)</h3>
<p>You may be tempted to write your own grids framework rather than use one that is already out there.  The <em>not invented here</em> mentality is really hard to get around.  If you really can&#8217;t resist the urge to write your own grids, do it for your blog, not a major international company. It&#8217;s a fun exercise, but the pitfalls are treacherous.</p>
<h3>The Requirements &#038; Constraints</h3>
<ul class="basicList">
<li>Grids and units can be nested inside each other to achieve complex layouts.  The logic is very simple; <strong>any grid can be nested inside any other</strong>.  Keeping constraints low simplifies CMS development. You should not need to write any additional CSS to make this possible or you start getting n! css rules. Yes, this is bad.
	</li>
<li>Each unit controls it’s own destiny, uh, width that is.  In CMS design, one of the most costly operations is when you need to make changes elsewhere in the DOM in order to generate display or behavior in the current location.  <strong>Keep all the classes necessary for the unit to function on the unit itself</strong>. This will make page building much quicker and code easier to navigate.
	</li>
<li><strong>Unit width can be any fraction of the total width</strong>. Generally I create fractions up to fifths, more than that is probably overkill.
	</li>
<li><strong>Fewer templates</strong>.  Templates are unique starting points for building pages.  They complicate using a CMS because generally they aren’t designed so that you can go from one to another easily.  Developers love to create new templates, while CMS users hate them.  Try to refrain.
</li>
<li><strong>No JS required</strong>. Using JS for basic layout is wasteful. We need JS to do other important things, thus we need to solve layout problems with CSS.</li>
</ul>
<h3>Redefining the template</h3>
<p>Traditionally, a new template is created for each page type.  Separate templates might be defined for one column, two column, and three column layouts, as well as home pages, main product pages, etc.  Grids allow you to base all of these pages on the same template, which might include only the basic frame, header, body and footer.  The template stays simple because grids allow you to break up any one of these regions into convenient units of content.  You should then include a “save as a template” option.  Your users can then define templates as they build pages in your CMS, saving at convenient points from which they can build pages.  Having a common starting point, or one single base template will mean that users can undo any choice they’ve made. </p>
<p>More about templates in another article.</p>
<h3>Grids solutions </h3>
<p>So now that you know a bit more about how to choose a grids solution, go check out these frameworks to find the one that will work for you:</p>
<div class="data">
<table>
<tr>
<th></th>
<th>nest</th>
<th>Size (kb)</th>
<th>fixed or liquid</th>
<th>columns</th>
<th>units</th>
<th>License</th>
<th>gutter</th>
</tr>
<tr>
<th><a href="http://www.blueprintcss.org/">Blueprint</a></th>
<td>No</td>
<td align=right>7.2</td>
<td>fixed</td>
<td align=right>24</td>
<td>30px</td>
<td>GPL</td>
<td>10px</td>
</tr>
<tr>
<th><a href="http://960.gs/">960s</a></th>
<td>No</td>
<td align=right>5.4</td>
<td>fixed</td>
<td>12 &amp; 16</td>
<td>40 &amp; 60px</td>
<td>GPL</td>
<td>20px</td>
</tr>
<tr>
<th><a href="http://developer.yahoo.com/yui/grids/">YUI2</a></th>
<td>No</td>
<td align=right>2.8</td>
<td>liquid</td>
<td>1 to 3</td>
<td>1/2 1/3</td>
<td>BSD</td>
<td>1-4%</td>
</tr>
<tr>
<th><a href="https://github.com/stubbornella/oocss/wiki/Grids">OOCSS</a></th>
<td>Yes</td>
<td align=right>0.7</td>
<td>liquid</td>
<td>1 to 5</td>
<td>1/2 1/3 1/4 1/5</td>
<td>BSD</td>
<td>0px</td>
</tr>
<tr>
<th><a href="http://developer.yahoo.com/yui/3/cssgrids/">YUI3</a></th>
<td>Yes</td>
<td align=right>1.5</td>
<td>liquid</td>
<td>1 to 24</td>
<td>1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/12 1/24 </td>
<td>BSD</td>
<td>10px*</td>
</tr>
</table>
</div>
<p>* YUI3 requires an extra sub-node wrapper for the gutter.</p>
<p>Any other grids frameworks I should have included? </p>
<p class="note">Note: I wrote most of this article years ago, but never got around to publishing it because it wasn&#8217;t &#8220;perfect&#8221;. (Oh how annoying it can be to be me). If you notice anything out-of-date, please do bring it to my attention.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbornella.org/content/2011/01/22/grids-improve-site-performance/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: www.stubbornella.org @ 2012-05-16 17:20:22 by W3 Total Cache -->
