<?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>Big Red Tin &#187; CSS</title>
	<atom:link href="http://bigredtin.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigredtin.com</link>
	<description>Thoughts about the web and business from the large pantry</description>
	<lastBuildDate>Tue, 15 Nov 2011 23:15:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Faux Columns Revistited</title>
		<link>http://bigredtin.com/2011/css3-faux-columns/</link>
		<comments>http://bigredtin.com/2011/css3-faux-columns/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 07:10:25 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Quick Notes]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=1302</guid>
		<description><![CDATA[It's time to update Dan Cederholm’s faux columns to take advantage of CSS3 gradients and reduce http requests.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time to update Dan Cederholm’s <a href="http://www.alistapart.com/articles/fauxcolumns/">faux columns</a> to take advantage of CSS3 gradients and reduce http requests.</p>
<p>I&#8217;ve put a <a href="http://gh.peterwilson.cc/quick-demos/css3fauxcols.html">demo on Github</a> where you can also see the <a href="https://github.com/peterwilsoncc/quick-demos/blob/gh-pages/css3fauxcols.html">source code</a>.<span id="more-1302"></span></p>
<h3>Two columns, both with solid colours</h3>
<pre><code>background: #fff url(css3faux-i/cols.png);
background-image: -o-linear-gradient(left, #fff 639px, #bed751 640px);
background-image: -moz-linear-gradient(left, #fff 639px, #bed751 640px);
background-image: -webkit-linear-gradient(left, #fff 639px, #bed751 640px);
background-image: -ms-linear-gradient(left, #fff 639px, #bed751 640px);
background-image: linear-gradient(left, #fff 639px, #bed751 640px);</code></pre>
<h3>Two columns, with a one pixel divider</h3>
<pre><code>background: #fff url(css3faux-i/div.png);
background-image: -o-linear-gradient(left, #fff 639px, #bed751 640px, #fff 641px);
background-image: -moz-linear-gradient(left, #fff 639px, #bed751 640px, #fff 641px);
background-image: -webkit-linear-gradient(left, #fff 639px, #bed751 640px, #fff 641px);
background-image: -ms-linear-gradient(left, #fff 639px, #bed751 640px, #fff 641px);
background-image: linear-gradient(left, #fff 639px, #bed751 640px, #fff 641px);</code></pre>
<h3>Two columns, one with a gradient</h3>
<pre><code>background: #fff url(css3faux-i/gradient.png);
background-image: -o-linear-gradient(left, #fff 639px, #bed751 640px, #efffa5 100%);
background-image: -moz-linear-gradient(left, #fff 639px, #bed751 640px, #efffa5 100%);
background-image: -webkit-linear-gradient(left, #fff 639px, #bed751 640px, #efffa5 100%);
background-image: -ms-linear-gradient(left, #fff 639px, #bed751 640px, #efffa5 100%);
background-image: linear-gradient(left, #fff 639px, #bed751 640px, #efffa5 100%);</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2011/css3-faux-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How we do IE Hacks</title>
		<link>http://bigredtin.com/2011/iehacks/</link>
		<comments>http://bigredtin.com/2011/iehacks/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 01:30:50 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Quick Notes]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=1256</guid>
		<description><![CDATA[We've recently changed the way we do IE hacks at Soupgiant. For years we were using conditional comments to load separate CSS files.]]></description>
			<content:encoded><![CDATA[<p>We recently changed the way we do <abbr title="Internet Explorer">IE</abbr> hacks at <a href="http://soupgiant.com">Soupgiant</a>. For years we used conditional comments to load separate CSS files.</p>
<p>For a few sites, we used <a href="http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">Paul Irish&#8217;s conditional HTML classes hacks</a>. Without workarounds, this puts <a href="https://github.com/paulirish/html5-boilerplate/issues/378"><abbr>IE</abbr> in compatibility mode</a>.</p>
<p><span id="more-1256"></span></p>
<p>Recently, we decided to go back to attribute hacks.</p>
<p>Using <a href="http://lesscss.org">LESS CSS</a> and compiling with <a href="http://incident57.com/less/">less.app</a>, it&#8217;s possible to store the hacks in a single location and remove them once the browsers die.</p>
<p>The hacks we use are:</p>
<pre><code>/* <abbr>IE6</abbr> */
#something {
  _color: blue;
}

/* <abbr>IE6</abbr>, <abbr>IE7</abbr> */
#something {
  *color: blue;
}</code></pre>
<p>Around the time we switched, Mathias Bynens wrote a post detailing <a href="http://mathiasbynens.be/notes/safe-css-hacks">much the same conclusions we reached</a>. I won&#8217;t rehash them here.</p>
<p><em>Excuse the dull and highly unfashionable post. It&#8217;s main purpose is so we can go to <a href="http://bigredtin.com/iehacks">bigredtin.com/iehacks</a> when memory fails us. We use this blog a resource.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2011/iehacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintaining Link Focus</title>
		<link>http://bigredtin.com/2011/maintaining-link-focus/</link>
		<comments>http://bigredtin.com/2011/maintaining-link-focus/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 03:39:20 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Eric Meyer]]></category>
		<category><![CDATA[reset]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=1236</guid>
		<description><![CDATA[Anyone who has attempted to navigate a web page using the keyboard will have experienced sites that remove the default a:focus style without adding in a replacement.]]></description>
			<content:encoded><![CDATA[<p>Anyone who has attempted to navigate a web page using the keyboard, will have experienced sites that remove the default <code>a:focus</code> style without adding in a replacement.</p>
<p>The cause – but not the fault – lays with Eric Meyer&#8217;s original <a href="http://meyerweb.com/eric/tools/css/reset/"><abbr>CSS</abbr> reset</a>, subsequently included in the <abbr>YUI</abbr> <abbr>CSS</abbr> framework, among others.</p>
<p><span id="more-1236"></span>
<p>Eric warned that he didn&#8217;t &#8220;recommend that you just use this in its unaltered state&#8221; but people did so anyway. Including the code:</p>
<pre><code>:focus {
  outline: 0;
}</code></pre>
<p>The problem became so widespread that Eric has <a href="https://twitter.com/meyerweb/status/60685012059688960">apologised for it</a>, even though <strong>it wasn&#8217;t his fault people ignored his advice!</strong> In the second version of his reset, he removed the code above.</p>
<p> </p>
<p>At <a href="http://soupgiant.com/">Soupgiant</a>, we take a two-fold approach to link focus styles. We leave the outline in place because users have come to expect it. To increase the contrast of focused links further, we reverse the foreground and background colours too.</p>
<pre><code>a:link, a:visited {
  color: #00f;
  background: transparent;
  text-decoration: underline;
}
a:focus {
  color: #fff;
  background: #00f;
  text-decoration: none;
}
a:hover, a:active {
  color: #00f;
  background: transparent;
  text-decoration: none;
}</code></pre>
<p>While it seems we are doubling up on some code, it&#8217;s a necessary evil as multiple pseudo-classes can be applied to single a link at once (for example: <code>:hover</code> and <code>:focus</code>).</p>
<p> </p>
<p>For the cost of a few extra bytes, we believe it adds significantly to the usability of our sites. For that reason, we&#8217;ve included it in <a href="http://www.minimumpage.com/">Minimum Page</a>: our reset-free, <abbr>CSS</abbr> starting point.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2011/maintaining-link-focus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minimum Page, A CSS Base</title>
		<link>http://bigredtin.com/2011/minimum-page-css/</link>
		<comments>http://bigredtin.com/2011/minimum-page-css/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 00:25:52 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=1225</guid>
		<description><![CDATA[We decided to release <a href="http://soupgiant.com">Soupgiant</a>'s <abbr>CSS</abbr> base to the world at large, you'll find it at <a href="http://www.minimumpage.com">minimumpage.com</a>.]]></description>
			<content:encoded><![CDATA[<p>We decided to release <a href="http://soupgiant.com">Soupgiant</a>&#8216;s <abbr>CSS</abbr> base to the world at large. You can find it at <a href="http://www.minimumpage.com">minimumpage.com</a>.</p>
<p>Minimum Page comes from a frustration with <abbr>CSS</abbr> resets and bases. Ripping down the styling only to rebuild many of the same styles is unnecessary, especially for defaults common to all browsers.</p>
<p>To encourage people to consider the code they insert in their site, the styles aren&#8217;t provided in a minimised form. Developers should edit the original base to make generic, site wide changes.</p>
<p>It&#8217;s exactly what we use to start all of our CSS at Soupgiant. We think it&#8217;s important to share.</p>
<ul class="download" style="width: 220px; text-align: center; margin-left: auto; margin-right: auto;">
<li class="download" style="list-style: none;"><a style="display: block; color: #fff; background: #00813F; padding: 10px; text-align: center; border-radius: 5px;" href="http://www.minimumpage.com">Find out more</a></li>
<li class="github" style="display: inline-block; padding: 5px;"><a href="https://github.com/soupgiant/minimum-page">View on github</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2011/minimum-page-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>!important is Important</title>
		<link>http://bigredtin.com/2011/css-important-is-important/</link>
		<comments>http://bigredtin.com/2011/css-important-is-important/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 00:52:54 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Responsive Web]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=1110</guid>
		<description><![CDATA[The <code>!important</code> declaration has really bad reputation, and deservedly so. As is often the way, this reputation results from abuse rather an inherent problem with the property itself.]]></description>
			<content:encoded><![CDATA[<p>The <code>!important</code> declaration has really bad reputation, and deservedly so. As is often the way, this reputation results from abuse rather an inherent problem with the property itself. An example of its abuse might be:</p>
<pre><code>#nav {
  float: none !important;
  /* where did I float this? */
}
/* ...jumble of code... */
ul#nav {
    float: left;
}</code></pre>
<p>There are, however, instances where the <code>!important</code> declaration is the best tool for the job.</p>
<p><span id="more-1110"></span></p>
<h3>Responsive Web</h3>
<p>The increase of users accessing web sites via mobile devices has redefined the way many design for the web. Rather than considering the desktop first, they now consider the mobile user. Andy Clarke&#8217;s <a href="http://stuffandnonsense.co.uk/projects/320andup/">320 and Up</a> is one reaction to this.</p>
<p>A requirement of the responsive web is that images expand and contract according to the width of the browser. To achieve this, the advice to define the width and height in the <abbr>HTML</abbr> has been reversed, an image should now be added without these attributes.</p>
<pre><code>&lt;img src="img.png" <del>width="30" height="30"</del> /&gt;</code></pre>
<p>This leads to problems when redesigning a site, images in previous blog posts and older content could have the width and height defined. If the site uses a <abbr>CMS</abbr> with a visual editor, it may add the dimension to an image by default and content editors may unwittingly break the layout by leaving them in place.</p>
<p>To allow for this, I usually add the following to the <abbr>CSS</abbr></p>
<pre><code>img {
  height: auto !important;
  max-width: 100% !important;
}</code></pre>
<h3>Print Styles</h3>
<p>There are certain elements that are almost always hidden from print styles: skip links, navigation, and oversized footers, for example. Backgrounds are also removed as they&#8217;re not printed by default. Changes to the screen layout won&#8217;t alter these needs. To avoid future problems, it is legitimate to include the following in your style sheet:</p>
<pre><code>@media print {
  #nav, #footer, .sidebar {
    display: none !important;
  }
  .has-a-background {
    background: #fff !important;
  }
}</code></pre>
<p><a href="http://bigredtin.com/2011/css-important-is-important/#comments">Leave a comment</a> with your thoughts if you frequently use <code>!important</code> for other purposes, agree or disagree.</p>
<p><strong>Update 16 Nov, 2011:</strong> changed <code>img</code> code block. </p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2011/css-important-is-important/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5: I couldn&#8217;t (quite) do it</title>
		<link>http://bigredtin.com/2010/html5-couldnt-do-it/</link>
		<comments>http://bigredtin.com/2010/html5-couldnt-do-it/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 04:40:36 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=967</guid>
		<description><![CDATA[I found it difficult to use pure and semantic <abbr>HTML5</abbr> when dealing with current versions of Internet Explorer. I really tried to adopt the commonly advocated view that it's okay to require website visitors have JavaScript enabled but settled on a different option I could actually live with.]]></description>
			<content:encoded><![CDATA[<p>For most of my career as a web developer I&#8217;ve produced websites that work without JavaScript. For the JavaScript impaired the sites may be missing a minor visual feature or be a little clunky in places, but they work and the meaning remains clear. It doesn&#8217;t bother me that, sometimes, the cost of allowing for sites to load without JavaScript can mean missing out on the latest web fashion. I&#8217;m <a title="Why I will not be dropping support for IE6" href="http://bigredtin.com/behind-the-websites/not-dropping-ie6/">not a big fan of fashion</a>.</p>
<p>Currently, web development is undergoing some major transitions: the <abbr>HTML5</abbr> spec is being developed and <abbr>CSS3</abbr> is being implemented. The browser wars have returned, although this time around, it&#8217;s a battle to win developers&#8217; hearts by implementing the newest standards.</p>
<p>Now is the time for developers to re-evaluate their past practices; moving on from the old and embracing the new. I kept that ethos in mind when upgrading the Soupgiant WordPress base theme recently. Among other things we were porting it to <abbr>HTML5</abbr>.</p>
<p><span id="more-967"></span></p>
<p>I really tried to adopt the commonly advocated view that it&#8217;s okay to require website visitors have JavaScript enabled. It was going very well, right up to the final hurdle when I couldn&#8217;t resist checking the site I was working on without JavaScript.</p>
<p>Everything looked fine in Chrome, Firefox, and Opera. It was, predictably, Internet Explorer that threw a spanner in the works. For an artist&#8217;s impression, <a href="http://code.bigredtin.com/html5/">visit the demo in <abbr>IE8</abbr></a> (<a href="http://www.webpagetest.org/result/101213_2W1A/1/screen_shot/">screenshot</a> via WebPageTest):</p>
<div id="attachment_970" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.webpagetest.org/result/101213_2W1A/1/screen_shot/"><img class="size-medium wp-image-970 " title="HTML5 as seen in IE8" src="http://bigredtin.com/files/2010/12/ie8html5-300x166.jpg" alt="" width="300" height="166" /></a><p class="wp-caption-text">HTML5 as seen in IE8</p></div>
<p>Without <a href="http://remysharp.com/2009/01/07/html5-enabling-script/">Remy Sharp&#8217;s <abbr>HTML5</abbr> enabling script</a> the site I was working on was unusable, if anything, it looked worse than the demo provided.</p>
<p>I couldn&#8217;t, in good faith, sell a website to a client that some visitors would find unstyled, half styled or difficult to follow in places. I didn&#8217;t want to throw out the baby with the bathwater, the additional meaning provided by <abbr>HTML5</abbr> elements is just too great. <code>&lt;header&gt;</code>, <code>&lt;section&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;article&gt;</code>, etc all provide meaning to a document that it&#8217;s difficult to justify going without.</p>
<p>It&#8217;s with the additional meaning in mind that I decided to go with &#8211; what I&#8217;ve dubbed &#8211; <abbr>HTML4.5</abbr>. <abbr>HTML5</abbr> provides the meaning while using traditional <abbr>HTML</abbr> 4 tags as hooks for styling. It introduces a bit of tag soup, as instead of <code>&lt;article id="content"&gt; ... &lt;/article&gt;</code> the code becomes <code>&lt;div id="content"&gt;&lt;article&gt; ... &lt;/article&gt;&lt;/div&gt;</code>.</p>
<p>The improvement to site I was working on was immediate, as you can see by <a href="http://code.bigredtin.com/html5/html45.html">visiting the <abbr>html4.5</abbr> demo in IE8</a> (<a href="http://www.webpagetest.org/result/101213_2W1B/1/screen_shot/">screenshot</a> via WebPageTest):</p>
<div id="attachment_973" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.webpagetest.org/result/101213_2W1B/1/screen_shot/"><img class="size-medium wp-image-973" title="HTML4.5 as seen in IE8" src="http://bigredtin.com/files/2010/12/html45-300x174.jpg" alt="" width="300" height="174" /></a><p class="wp-caption-text">HTML4.5 as seen in IE8</p></div>
<h4>I don&#8217;t care about tag soup</h4>
<p>If given the choice between an unusable website for some visitors or a little tag bloat, I&#8217;ll take the bloat any day of the week. In the demo the bloat adds an extra 14 bytes. On the home page for the site I was working on, it&#8217;s 40 bytes. I save plenty more than 40 bytes by minimising my JavaScript and <abbr>CSS</abbr> (a single key combo with the <a href="http://www.experienceinternet.co.uk/software/yui-compressor-textmate-bundle/">YUI Compressor TextMate bundle</a>), so I&#8217;m not too concerned about the side effects.</p>
<p>A technically beautiful site is the ideal but if a portion of your visitors can&#8217;t use it, then the beauty isn&#8217;t even skin deep. As <a href="http://allinthehead.com/">Drew McLellan</a> said recently on <a href="http://24ways.org/2010/finding-your-way-with-static-maps">24 ways</a>, progressive enhancement is &#8220;also known as doing our jobs properly.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2010/html5-couldnt-do-it/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How @font-face loads in different browsers</title>
		<link>http://bigredtin.com/2010/how-font-face-loads-in-different-browsers/</link>
		<comments>http://bigredtin.com/2010/how-font-face-loads-in-different-browsers/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 23:36:03 +0000</pubDate>
		<dc:creator>Josh Kinal</dc:creator>
				<category><![CDATA[Quick Notes]]></category>
		<category><![CDATA[@font-face]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=955</guid>
		<description><![CDATA[Why do you sometimes see the fonts change on a website after it loads? This is just one of the many ways browsers behave differently, as explained in this quote from Richard Rutter.]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://24ways.org/2010/using-the-webfont-loader-to-make-browsers-behave-the-same"><em>24 ways</em>: Using the WebFont Loader to Make Browsers Behave the Same</a>:</p>
<blockquote><p>&#8220;Safari, Chrome and Internet Explorer leave a blank space in place of the styled text while the web font is loading. Opera and Firefox show text with the default font which switches over when the web font has loaded, resulting in the so-called Flash of Unstyled Text (aka FOUT).&#8221;</p></blockquote>
<p> <a href="http://clagnut.com/" title="Clagnut is Richard Rutter">Richard Rutter</a> wrote <a href="http://24ways.org/2010/using-the-webfont-loader-to-make-browsers-behave-the-same" title="24 ways: Using the WebFont Loader to Make Browsers Behave the Same">an excellent piece</a> about how to avoid these different behaviours. I thought it was worth quoting and linking to twice.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2010/how-font-face-loads-in-different-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selectivizr with CSS on a sub-domain</title>
		<link>http://bigredtin.com/2010/selectivizr-with-css-on-a-cdn/</link>
		<comments>http://bigredtin.com/2010/selectivizr-with-css-on-a-cdn/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 17:29:10 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CDN]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[Selectivizr]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=886</guid>
		<description><![CDATA[Updating the <a title="Soupgiant" href="http://soupgiant.com">Soupgiant</a> base WordPress theme recently (among other things we were porting it to <abbr>HTML5</abbr>), we needed to decide which <a title="shims and/or polyfills" href="http://remysharp.com/what-is-a-polyfill/">shims and/or polyfills</a> to use. We starterd with  <a title="on Remy Sharp's blog" href="http://remysharp.com/2009/01/07/html5-enabling-script/">Remy Sharp's HTML5 enabling script</a> but another to consider was <a title="Selectivizr" href="http://selectivizr.com/">Selectivizr</a> to improve <abbr title="Internet Explorer">IE</abbr>'s support of <abbr title="Cascading Style Sheets, Version 3">CSS3</abbr> selectors.]]></description>
			<content:encoded><![CDATA[<p>Updating the <a title="Soupgiant" href="http://soupgiant.com">Soupgiant</a> base WordPress theme recently (among other things we were porting it to <abbr>HTML5</abbr>), we needed to decide which <a title="shims and/or polyfills" href="http://remysharp.com/what-is-a-polyfill/">shims and/or polyfills</a> to use. We starterd with  <a title="on Remy Sharp's blog" href="http://remysharp.com/2009/01/07/html5-enabling-script/">Remy Sharp&#8217;s HTML5 enabling script</a> but another to consider was <a title="Selectivizr" href="http://selectivizr.com/">Selectivizr</a> to improve <abbr title="Internet Explorer">IE</abbr>&#8216;s support of <abbr title="Cascading Style Sheets, Version 3">CSS3</abbr> selectors.</p>
<p>One of the disadvantages of using Selectivizr is it rules out using a <abbr title="content distribution network ">CDN</abbr> for one&#8217;s style sheets. To quote their site:</p>
<blockquote><p>Style sheets MUST be hosted on the same domain as the page due to browser security restrictions. Likewise,  style sheets loaded using the <code>file:</code> protocol will not work.</p></blockquote>
<p>Normally, particularly for low traffic sites, this wouldn&#8217;t be of great concern. As we share style sheets across sites (both Big Red Tin &amp; <a title="our Business site" href="http://soupgiant.com/">Soupgiant</a> use the same <abbr>CSS</abbr>) and use the <abbr>CDN</abbr> feature of <a title="the WordPress Plugin" href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a> on our hosted WordPress sites, it could cause problems down the track.</p>
<p>After umming and ahhing for a couple of days, the following solution involving <a title="defined on 'quircksmode'" href="http://www.quirksmode.org/css/condcom.html">conditional comments</a>, occurred to us:</p>
<pre>&lt;!--[if gte IE 9]&gt;&lt;!--&gt;
&lt;link rel="stylesheet" href="http://cdn.example.com/styles.css" type="text/css"&gt;
&lt;!--&lt;![endif]--&gt;

&lt;!--[if lte IE 8]&gt;
&lt;link rel="stylesheet" href="/styles.css" type="text/css"&gt;
&lt;![endif]--&gt;</pre>
<p>With a few lines of conditional comments, browsers supporting the relevant selectors natively can take advantage of the performance boost from a <abbr>CDN</abbr> while developers can take advantage of the advanced selector support provided by Selectivizr for IE&lt;9 users.</p>
<p>We&#8217;ve set up a quick <a title="demonstration" href="http://code.bigredtin.com/selectivizr/">demonstration</a> in which three paragraphs have different <abbr title="Accessible Rich Internet Applications">ARIA</abbr> roles &#8211; featured, unfeatured and neverfeatured &#8211; different styles are applied to each paragraph using [role=something]. The demo renders fully in: IE 6-9beta, Firefox (Win &amp; Mac), Chrome (Mac), Safari (Mac), and Opera (Mac).</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2010/selectivizr-with-css-on-a-cdn/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A half-baked (CSS) idea</title>
		<link>http://bigredtin.com/2010/a-half-baked-css-idea/</link>
		<comments>http://bigredtin.com/2010/a-half-baked-css-idea/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 19:22:46 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[data-URIs]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://bigredtin.com/?p=836</guid>
		<description><![CDATA[<a title="Spritebaker" href="http://www.spritebaker.com/">Spritebaker</a> has done the rounds a fair bit in web development circles over the past few weeks. It’s a great idea, done well. The only problem is it has the strange effect of making it seem like the page is actually taking longer to load. I take a look at a possible solution.]]></description>
			<content:encoded><![CDATA[<p><a title="Spritebaker" href="http://www.spritebaker.com/">Spritebaker</a> has been doing the rounds a fair bit in web development circles over the past few weeks, for the simple reason that it&#8217;s a great idea, done well. The best desciption comes from the site itself:</p>
<blockquote><p>It parses your css and returns a copy with all external media “baked” right into it as Base64 encoded datasets. The number of time consuming http-requests on your website is decreased significantly, resulting in a massive speed-boost.</p></blockquote>
<p>While baking images into your CSS to lower HTTP requests reduces the rendering time of your site overall, the downside is that CSS files <a title="block the initial rendering" href="http://code.google.com/speed/page-speed/docs/rendering.html#PutCSSInHead">block the initial rendering</a> of your site. While an unbaked site may render and be built up as external images load, a baked site will not render until both the CSS and baked images have loaded. This has the strange effect of making it seem like the page is actually taking <em>longer</em> to load.</p>
<p>I&#8217;ve thrown together a quick example of an <a title="unbaked page" href="http://code.bigredtin.com/spritebaker/unbaked.html">unbaked page</a> and its <a title="baked equivalent" href="http://code.bigredtin.com/spritebaker/baked.html">baked equivalent</a>. In this example, the unbaked page begins rendering earlier than its baked counterpart but finishes later.</p>
<p>In an attempt to kick off rendering earlier, I tried what I&#8217;ve named a half-baked idea: splitting the <em>standard</em> CSS into one file and the baked images into another. My hope was that browsers would render the standard CSS while the other was still loading. As you can see on the <a title="example page" href="http://code.bigredtin.com/spritebaker/halfbaked.html">example page</a>,  this failed.</p>
<p>With CSS only solutions delaying rendering of the page, it&#8217;s time to pull JavaScript out of our toolbox. Anyone whose read my article on <a title="delaying loading of print CSS" href="http://bigredtin.com/behind-the-websites/delay-loading-of-print-css/">delaying loading of print CSS</a> will find the solution eerily familiar. The CSS files are still split into the standard files and the file containing the baked-in images, the one with the baked in images is wrapped in &lt;noscript&gt; tags in the HTML head.</p>
<pre><code>&lt;link rel="stylesheet" href="halfbaked-1.css" type="text/css" /&gt;
&lt;noscript&gt;&lt;link rel="stylesheet" href="jshalfbaked-2.css" type="text/css" /&gt;&lt;/noscript&gt;</code></pre>
<p>This prevents the second/baked stylesheet from loading during the initial rendering of the page. Without this file blocking rendering, <a title="this version of the example" href="http://code.bigredtin.com/spritebaker/jsbaked.html">this version of the example</a> begins rendering as quickly as the first, unbaked, example.</p>
<p>The second/baked stylesheet needs to be added using the JavaScript below:</p>
<pre><code>&lt;script type="text/javascript"&gt;
window.onload = function(){
  var cssNode = document.createElement('link');
  cssNode.type = 'text/css';
  cssNode.rel = 'stylesheet';
  cssNode.href = 'jshalfbaked-2.css';
  cssNode.media = 'all';
  document.getElementsByTagName("head")[0].appendChild(cssNode);
}
&lt;/script&gt;</code></pre>
<p>Using the method above for baking images into your CSS will give you the best of both worlds, your page will render quickly with a basic structure before a single HTTP request is used to load all of your images.</p>
<p>I used <a title="Web Page Test" href="http://www.webpagetest.org">Web Page Test</a> to measure the first-run load times using IE9 Beta, averaged over 10 tests. On the test pages, with only a few images, the advantage of a baked stylesheet isn&#8217;t apparent, on a site with more images it would quickly become so.</p>
<table>
<thead>
<tr>
<th>Version</th>
<th>Starts Render</th>
<th>Fully Loaded</th>
</tr>
</thead>
<tbody>
<tr>
<td><a title="Unbaked" href="http://www.webpagetest.org/result/100919_5CCK/">Unbaked</a></td>
<td>0.490s</td>
<td>1.652s</td>
</tr>
<tr>
<td><a title="Baked" href="http://www.webpagetest.org/result/100919_5CCM/">Baked</a></td>
<td>1.862s</td>
<td>1.836s</td>
</tr>
<tr>
<td><a title="Half baked" href="http://www.webpagetest.org/result/100919_5CCN/">Half baked</a></td>
<td>2.138s</td>
<td>2.114s</td>
</tr>
<tr>
<td><a title="JS baked" href="http://www.webpagetest.org/result/100919_5CCP/">JS baked</a></td>
<td>0.499s</td>
<td>1.993s</td>
</tr>
</tbody>
<tbody></tbody>
</table>
<p>As the <a title="Spritebaker Info page" href="http://www.spritebaker.com/info">Spritebaker info page</a> says, IE versions prior to IE8 don&#8217;t understand data-URIs, so you&#8217;ll need to use a generous sprinkling of conditional comments to load images the old fashioned way in these browsers.</p>
<p>The examples above were tested on IE9 Beta, Chrome 6.0, Safari 5.0, Opera 10.10 and Firefox 3.6.9. Individual results may vary.</p>
<p>We&#8217;d love to hear of your experiences with baking stylesheets, or other techniques you use to speed up apparent rendering of your page, especially if it slows the total load/rendering time.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2010/a-half-baked-css-idea/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Delay Print Stylesheets Plugin</title>
		<link>http://bigredtin.com/2010/delay-print-css-plugin/</link>
		<comments>http://bigredtin.com/2010/delay-print-css-plugin/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 02:17:29 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bigredtin.pressgiant.net/?p=739</guid>
		<description><![CDATA[A few weeks ago I wrote a post in which I adapted an idea from a zOompf article to delay the loading of print stylesheets until after a web page has fully rendered. I've decided to convert the code from the original post into a plugin and add it to the WordPress plugin directory.]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a post in which I <a title="adapted an idea from a zOompf article" href="http://bigredtin.com/behind-the-websites/delay-loading-of-print-css/">adapted an idea from a zOompf article</a> to delay the loading of print stylesheets until after a web page has fully rendered. I finished that post with the following point/question:</p>
<blockquote><p>Another question to ask is whether all this is actually worth the effort – even when reduced through automation. On Big Red Tin, the print.css is 595 bytes, the delay in rendering is negligible.</p></blockquote>
<p>Chris and Jeff at <a title="Digging into WordPress" href="http://digwp.com">Digging into WordPress</a> picked up the article and posted it on their site. In turn it was picked up elsewhere and became the surprise hit of the summer at Big Red Tin. Not bad when one is shivering through a bitter Melbourne winter.</p>
<p>As a result of the interest, I decided to convert the code from the original post into a plugin and add it to the WordPress plugin directory.</p>
<h4>Further Testing</h4>
<p>As I warned in the original article, I&#8217;d tested the code in very limited circumstances and found it had worked. Fine for a code sample but not enough for a sub version-1.0-release plugin. Additional testing showed:</p>
<ol>
<li>Stylesheets intended for IE, through conditional comments, were loading in all browsers</li>
<li>When loading multiple stylesheets, the correct order was not maintained in all browsers</li>
</ol>
<p>If jQuery was available I wanted to use it for JavaScript event management otherwise I&#8217;d use purpose-written JavaScript. There&#8217;s no point, after all, of worrying about the rendering delay caused by 600-1000 bytes only to load a 71KB (or 24KB <a title="gzipped" href="http://developer.yahoo.net/blog/archives/2007/07/high_performanc_3.html">gzipped</a>) file in its place.</p>
<p>Other things I wanted to do included:</p>
<ol>
<li>Put the PHP in a class to reduce the risk of clashing function/class names</li>
<li>Put the JavaScript in its own namespace</li>
<li>Keep the output code as small as possible</li>
</ol>
<p>To support conditional comments for IE required adding each stylesheet within a separate &lt;script&gt; tag, using this method the output HTML takes the following form:</p>
<pre><code>&lt;script&gt;
  // add global print.css
&lt;/script&gt;
&lt;!--[if IE 6]&gt;
  &lt;script type='text/javascript'&gt;
    // add ie6 specific print.css
  &lt;/script&gt;
&lt;![endif]--&gt;</code></pre>
<p>This violates my aim to keep output as small as possible but footprint has to take second place to bug-free. I could have translated the code to use <a title="JavaScript conditional comments" href="http://en.wikipedia.org/wiki/Conditional_comment#Conditional_Comment_in_JScript">JavaScript conditional comments</a> by translating the IE version to the JavaScript engine it uses but this could lead to future-proofing problems.</p>
<p>To maintain the order of stylesheets, I added each event to an array of functions and then used a single event to loop through the array of functions. If jQuery is used, I add multiple events because jQuery runs events on a first in first out basis.</p>
<p>Putting the PHP in a class and the JavaScript in its own namespace is fairly self-explanatory. <a href="http://bit.ly/bBUXCh">Google is your friend</a> if you wish to read up further on this.</p>
<p>Minimising the footprint was also a simple step. I wrote the JavaScript out in full with friendly variable names. Once I was happy with the code, I ran the code through <a href="http://refresh-sf.com/yui/">the YUI JavaScript compressor</a>, commented out the original JavaScript in the plugin file and output the compressed version in its place.</p>
<p>The JavaScript is output inline (within the HTML) to avoid additional HTTP requests. I was in two minds about this because browser caching is lost in the process. So it may change in a later version.</p>
<p>I&#8217;ve worked out another way to keep the footprint small. Rather than creating a function to pass the stylesheet&#8217;s URL and ID to <code>brt_print.add(url, id)</code>, I wrote out the full function for each style sheet. I&#8217;ll fix that in the next release.</p>
<p>You can <a title="download" href="http://wordpress.org/extend/plugins/delay-print-css/download/">download</a> the <a title="Delay Print CSS Plugin" href="http://http://wordpress.org/extend/plugins/delay-print-css/">Delay Print CSS Plugin</a> from the WordPress plugin repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2010/delay-print-css-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

