<?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>CSS Wizardry &#187; CSS</title>
	<atom:link href="http://csswizardry.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://csswizardry.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:25:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>On HTML and CSS best practices</title>
		<link>http://csswizardry.com/2011/12/on-html-and-css-best-practices/</link>
		<comments>http://csswizardry.com/2011/12/on-html-and-css-best-practices/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 12:15:26 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3457</guid>
		<description><![CDATA[Best practices are exactly that; best. Not &#8216;better&#8217;, not &#8216;good when&#8230;&#8217; or &#8216;best if&#8230;&#8217;, just best. They&#8217;re always the best, no matter what.
This is something I learned whilst undertaking the single biggest project of my career so far; the complete (and not-yet-live) rebuild of one of BSkyB&#8217;s most trafficked websites. For years I&#8217;d been working [...]]]></description>
			<content:encoded><![CDATA[<p>Best practices are exactly that; <em>best</em>. Not &#8216;better&#8217;, not &#8216;good when&hellip;&#8217; or &#8216;best if&hellip;&#8217;, just best. They&#8217;re always the best, no matter what.</p>
<p>This is something I learned whilst undertaking the single biggest project of my career so far; the complete (and not-yet-live) rebuild of one of BSkyB&#8217;s most trafficked websites. For years I&#8217;d been working on medium-sized projects where I strove to use as few classes as possible, my CSS was so elegant and hand-crafted and everything used the cascade. I thought it was beautiful.</p>
<p>I found my old approach isn&#8217;t best practice when working on a big site, therefore it&#8217;s not best practice at all&hellip; You can scale down the big site mentality to smaller builds, you can&#8217;t scale up small site mentality to bigger ones. With this in mind, how you&#8217;d build bigger sites is best practice, how you tend to build smaller sites is <em>typically</em> (though, as ever, not always) based on fallacy and myth.</p>
<p><span id="more-3457"></span></p>
<p>I recently rebuilt my friend <a href="http://sampenrose.co.uk/">Sam&#8217;s design portfolio site</a>. Typically I&#8217;d have used IDs everywhere, not used any OO and not really paid much attention to the length or efficiency of my CSS selectors. This would have worked but only because the site is small. Any attempts by Sam to scale the site up, add pages, move components or alter the layout would have been hampered by these methods. Instead I decided to apply big-site mentality and dropped any IDs, used an OO approach and made sure every component is reusable. <a href="https://github.com/csswizardry/sampenrose.co.uk">The resulting code</a> is incredibly flexible, very efficient and still looks nice.</p>
<ul>
<li>OOCSS is <em>always</em> best practice.</li>
<li>DRY is <em>always</em> best practice.</li>
<li>Efficiency is <em>always</em> best practice.</li>
<li>Maintainability is <em>always</em> best practice.</li>
<li>Flexibility is <em>always</em> best practice.</li>
</ul>
<p>It doesn&#8217;t matter if you&#8217;re building the next Facebook or if it&#8217;s just a site for the builder down the road; best practice is always best. You might not notice an inefficient selector on a small site, but it doesn&#8217;t mean that it&#8217;s not still inefficient. Just because you don&#8217;t notice something it doesn&#8217;t mean it&#8217;s not still happening.</p>
<p>Build every site like it&#8217;s a 1000 page behemoth because then it can scale; it may never need to, but it <em>can</em>. Building every site like it&#8217;s a piece of art, using convoluted selectors and rigid, ID ridden code, it can never scale, even if you want it to.</p>
<p>Your code might look like the <a href="http://en.wikipedia.org/wiki/Sistine_Chapel">Sistine Chapel</a>, but if it&#8217;s a chore to maintain, or you find you can&#8217;t pick up a component and drop it anywhere with zero worry, then it&#8217;s not powerful. Code is about power before prettiness. You might feel dirty at first, but when you realise how nicely things fall into place using proper best practices you&#8217;ll see the benefits.</p>
<p>The only person who cares how pretty your code is is you. Your users want fast UIs, your clients want reliable builds and you and your team want code that is easy to maintain 6 months and a dozen client mind-changes down the line.</p>
<p><strong>Best always means best, it has no caveats or conditions.</strong></p>
<h2>Further reading</h2>
<ul>
<li><a href="http://www.lukew.com/ff/entry.asp?1379"><cite>Our Best Practices are Killing Us</cite></a> by Nicole Sullivan</li>
<li><a href="http://oocss.org/">OOCSS.org</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/12/on-html-and-css-best-practices/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Measuring and sizing UIs, 2011-style</title>
		<link>http://csswizardry.com/2011/12/measuring-and-sizing-uis-2011-style/</link>
		<comments>http://csswizardry.com/2011/12/measuring-and-sizing-uis-2011-style/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 13:10:21 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Sizing]]></category>
		<category><![CDATA[Typography]]></category>
		<category><![CDATA[Units]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3420</guid>
		<description><![CDATA[For years we used pixels to lay out web pages. Then, not so long ago, we were dabbling with ems to make our pages elastic. Now, in 2011, most of us are adopting a responsive approach and using fluid grids and percentages.
These methods seem to have all happened sequentially, with us each time dropping the [...]]]></description>
			<content:encoded><![CDATA[<p>For years we used pixels to lay out web pages. Then, not so long ago, we were dabbling with ems to make our pages <i>elastic</i>. Now, in 2011, most of us are adopting a responsive approach and using fluid grids and percentages.</p>
<p>These methods seem to have all happened sequentially, with us each time dropping the last. I&#8217;ve decided, though, that the best builds use aspects of all previous methods; fixed, elastic and fluid.</p>
<p><span id="more-3420"></span></p>
<h2>Using percentages&hellip;</h2>
<p>Let&#8217;s forget responsive design for a second. Responsive design is a three-tiered approach but here we&#8217;re only interested in fluid layouts (N.B. not even necessarily fluid grids). A fluid layout, as you all know, is one that is size-agnostic; it acts like a liquid, occupying a constant percentage of a varying space.</p>
<p>Now, fluid grids are a little tricky as they&#8217;re based around full grid systems. Luckily I&#8217;ve created a simple <a href="http://csswizardry.com/fluid-grids/">fluid grid calculator</a> to work these behemoths out, but in more simple terms it&#8217;s remarkably easy to set a fluid layout even if that was never the intention.</p>
<p>If your designer sends you a two-column design then all you need to do is work out <strong>not</strong> how big the respective columns are, but instead work out <em>how much bigger one is than the other</em>. That is to say; stop thinking &#8216;this content area is 600px and the sidebar is 300px&#8217; and <em>start</em> thinking &#8216;this content area is twice as big as the sidebar&#8217;. Percentages work well whether you&#8217;re going responsive or not!</p>
<p>Design is about proportions, not absolutes, and in ignoring actual pixel measurements in favour of relative ones you can ensure that designs are not tethered to numbers, but to proportions.</p>
<p>So the next PSD you get sent that is not meant to be responsive, just try this method out and at least make it fluid. If your sidebar is 220px wide and your content area is 640px then take that as meaning &#8216;the content area is 2.909 times bigger than the sidebar&#8217;.</p>
<h3>&hellip;or using nothing at all</h3>
<p>Even better than using percentages is to use no measurement at all. All components you build (navs, tables, figures, thumbnail galleries, banners, you name it) should never have widths (and never <em>ever</em> have heights) applied to them. They should be constrained only by their parents.</p>
<p>An element without measurements is inherently fluid, but in the best possible way; <em>it will work wherever you put it</em>. Ironically, the most important takeaway from this&mdash;an article about setting measurements&mdash;is simply &#8216;don&#8217;t&#8217;. Every time you can avoid setting a measurement, you should.</p>
<h2>Using ems</h2>
<p>Ems are an old favourite. They&#8217;re great for setting type, and with ems it&#8217;s <em>all</em> about the type.</p>
<p>As I outline in the next section, I don&#8217;t actually set font-sizes in ems; I use rems which is essentially <i>ems-with-benefits</i>. What I do set in ems is things <em>to do with</em> type; <code>margin-bottom</code>s on paragraphs, lists, headings and the like; paddings on buttons, nav links and promos and other such measurements; borders on promos etc.</p>
<p>What this does is ensure that the &#8216;feel&#8217; of the design is maintained no matter how far a user wishes to scale their text.</p>
<p>Let&#8217;s take an example. A designer has made a PSD with a nav in it. The nav links are blocks with a font-size of 12px (0.75em) and a padding of 5px, <a href="http://jsfiddle.net/csswizardry/NZLwc/">thus</a>.</p>
<p>Now, as I stated previously, a lot of design isn&#8217;t about numbers, it&#8217;s about <em>proportions</em>. It&#8217;s not about 12px and 5px looking best here, it&#8217;s about <em>a link looks best when its padding is just under half its own font-size</em>.</p>
<p>It can be a confusing way of looking at things at first, but once you realise that the 12 and 5 are actually totally irrelevant here and that it&#8217;s about their <em>relation</em> to one another, you should soon get the hang of things.</p>
<p>Let&#8217;s assume the user doubles their font-size, now you have a link that is 24px in size but still has a padding of 5px. That&#8217;s going to look very cramped. This is why we need to set paddings on text in ems, so that they track the font-size. In this case 5px as an em unit of 12px is 0.417, so now <a href="http://jsfiddle.net/csswizardry/NZLwc/2/">our code looks like this</a>. Try scaling up these two examples up and see how the second looks a lot nicer when the padding scales too.</p>
<p>So, whenever you are setting a measurement because it looks good when set against nearby type (think borders, paddings, margins etc) try and forget the absolutes and begin thinking &#8216;this padding needs to be just under half of whatever the font-size needs to be&#8217;.</p>
<p>Not convinced that users scale their text all that much? Well I have no data but I love <a href="https://twitter.com/5minuteargument/status/134682811683717121">this thought provoking analogy</a> from <a href="https://twitter.com/5minuteargument/">@5minuteargument</a>:</p>
<blockquote>
<p>&#8220;I&#8217;m going to start using TV volume as a CSS font analogy: not everyone is listening to your programme at the same volume&hellip;&#8221;</p>
</blockquote>
<p><strong class=hilite>Please note that when I refer to scaling I don&#8217;t mean the browser&#8217;s Ctrl+[+/-] scaling/zooming, I mean a user stylesheet or design alteration that changes the base font-size of the document.</strong></p>
<h3>Line-heights</h3>
<p>There are several ways of setting line-heights. A general rule of thumb is to never set them in pixels as this, as discussed above, won&#8217;t track your font-size. In this case you&#8217;d set them in ems or percentages, so that you never end up with &#8216;a font-size of 12px and a line height of 18px&#8217;, you&#8217;d get &#8216;text whose line-height is 1.5 times its font-size&#8217;.</p>
<p>However, even better than using ems, you just set them unitless. Work out the em value, but drop the em <em>from</em> the value, so <code>line-height:1.5em;</code> would just be <code>line-height:1.5;</code>. Eric Meyer explains this nicely <a href="http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/">over on his site</a>.</p>
<p>To work out unitless line-heights is simple. Use the following equation: the line-height I want &divide; the font-size I have. Want a 20px heading to have a 30px line-height? 30 &divide; 20 = 1.5. A 12px button to have a 24px line-height? 24 &divide; 12 = 2.</p>
<h2>Using rems</h2>
<p>Despite <a href="http://csswizardry.com/2011/05/font-sizing-with-rem-could-be-avoided/">my initial thoughts</a>, I have now started setting type in rems (with a pixel fallback).</p>
<p>This gives us two things, firstly we have what I call &#8216;progressive accessibility&#8217; in that it brings the accessibility benefits of ems but only in more advanced browsers.</p>
<p>Secondly, and more importantly, it gives us the confidence of pixels plus the scaling properties of ems. This is ridiculously cool. What this means is that we avoid the annoying compounding issues that ems can give us (a <code>small</code> in a smaller-than-body-copy promo springs to mind) but we can also keep their feature of scalability; we can alter the (font-)size of an entire document based on a parent rather than having to redeclare each individual elements&#8217; font-size over and over. It really is the best of both worlds.</p>
<p>Take <a href="http://jsfiddle.net/csswizardry/6CEjX/">this example</a>. Try changing the <code>html</code>&#8217;s font-size to 2em, does the page scale up as a whole? Nope. <a href="http://jsfiddle.net/csswizardry/6CEjX/1/">Try this one</a>. See how just changing the <code>html</code> element&#8217;s font-size will make your entire page act accordingly. This is something that pixels can&#8217;t give us&#8230;</p>
<p>Interestingly, <a href="https://github.com/csswizardry/hry.rbrts.me/blob/master/css/style.css#LC152">I also set <code>margin-bottom</code> in rems</a> so as to always maintain a consistent vertical rhythm around my <a href="http://coding.smashingmagazine.com/2011/03/14/technical-web-typography-guidelines-and-techniques/#tt-magic-number">magic number</a>.</p>
<h2>Using pixels</h2>
<p>I&#8217;ve said before today that the pixel&#8217;s day is numbered in the web design world. Most of my work involves ems, rems, percentages or nothing at all. The only time I ever really use pixels is if I have a known and fixed dimension to work to; nearly all the time this is images and icons.</p>
<p>Most pixel based measurements pertain to laying out fixed-size images like avatars or sprited elements who require fixed-size background images applying to them. Nearly everything else is best suited to proportional sizing with ems or to non-sizing with just being left fully fluid.</p>
<p>There really isn&#8217;t much work left for the old pixel in 2011.</p>
<h2>An example</h2>
<p>A fairly decent pre-existing example of the techniques discussed would be my <a href=http://hry.rbrts.me/>hry.rbrts.me</a> hub-site.</p>
<p>If you open that page and fire up your inspector you should see that:</p>
<dl>
<dt>Percentages</dt>
<dd>The <code>body</code> and <code>article</code>s all have their structure set in percentages.</dd>
<dt>Nothing</dt>
<dd>The social icons <em>component</em> is free of dimensions, it&#8217;s fully fluid and will always occupy its parent, wherever you put it.</dd>
<dt>Ems</dt>
<dd>The indentations of <code>ul</code>s, <code>ol</code>s and <code>dd</code>s are all set in ems so that they will scale with the lists&#8217; font-size. The gaps between sections are also set in ems so that if the font-size ever increases, so will the space around sections of text.</dd>
<dt>Line-heights</dt>
<dd>These are all set unitlessly (except the tagline which needs to line up with the logo).</dd>
<dt>Rems</dt>
<dd>Type styles are all set in rems to allow us scaling with control.</dd>
<dt>Pixels</dt>
<dd>Only the social media icons and the logo, which are fixed in size before we even start thinking about CSS, are set in pixels.</dd>
</dl>
<p>If you&#8217;d prefer, you can poke through the nicely formatted and commented CSS <a href=https://github.com/csswizardry/hry.rbrts.me/blob/master/css/style.css>on GitHub</a>.</p>
<h2>Key points</h2>
<p>The key things to take away from this article are:</p>
<ul>
<li><strong>Set structure in percentages.</strong> This includes content areas, sidebars etc.</li>
<li><strong>Set type in rems</strong> with a pixel fallback for older browsers. This gives us a great amount of control with added scalability.</li>
<li><strong>Set type-<em>related</em> items in ems</strong> so that paddings et al scale with the font-size.</li>
<li><strong>Set line-heights in relative units.</strong> Or, even better, with no units at all.</li>
<li><strong>Don&#8217;t set measurements on components at all.</strong> They should remain fully fluid and &#8216;just work&#8217; wherever you drop them.</li>
</ul>
<p>So there are a few tips and guidelines on sizing UIs and designs in 2011. We have a whole host of brilliant methods at our disposal and we can just cherry-pick them whatever they&#8217;re best suited to.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/12/measuring-and-sizing-uis-2011-style/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Create a notched current-state nav</title>
		<link>http://csswizardry.com/2011/11/create-a-notched-current-state-nav/</link>
		<comments>http://csswizardry.com/2011/11/create-a-notched-current-state-nav/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 20:00:57 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3393</guid>
		<description><![CDATA[Ben Everard tweeted last night asking if anyone knew how to build a notched nav, like this. I was in bed at the time, I spotted it about midnight and was on my phone. As soon as I saw this I jumped out of my bed and turned my Mac on. I love stuff like [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://twitter.com/ilmv">Ben Everard</a> <a href="https://twitter.com/ilmv/status/133640383568678912">tweeted last night</a> asking if anyone knew how to build a notched nav, like <a href="http://cl.ly/1h1S3E2G3H1X06193r08">this</a>. I was in bed at the time, I spotted it about midnight and was on my phone. As soon as I saw this I jumped out of my bed and turned my Mac on. I love stuff like this!</p>
<p>Anyway, <a href="http://jsfiddle.net/csswizardry/ZDNu7/21/embedded/result/">this is my solution</a>, and <a href="http://jsfiddle.net/csswizardry/ZDNu7/21">this is its code</a>.</p>
<p><span id="more-3393"></span></p>
<p>Basically there are two main parts to this technique; the punching-the-hole-through-the-nav and the masking-the-hole-to-be-a-triangle. Both techniques couldn&#8217;t be simpler, and we use pseudo elements to do it.</p>
<h2>Punching holes through elements</h2>
<p>This whole technique can only work by taking advantage of the behaviours of fixed background images. The exact same <code>background:;</code> applied to two elements give an odd result if both are also fixed. It gives the effect of a hole having been <a href="http://jsfiddle.net/csswizardry/7BXUf/show/">punched right through your page to the background&#8230;</a></p>
<p>What we do here, then, is create a pseudo element with <code>.nav .current a:before</code> and sit this at the bottom of the current list item. We then apply the fixed background to this <em>as well as</em> the page. This is our punched hole already sorted, <a href=http://jsfiddle.net/csswizardry/ZDNu7/27/>only it&#8217;s square&#8230;</a> we want a triangle.</p>
<h2>Masking the hole</h2>
<p>To mask the hole to appear like a triangle we use another pseudo element and the CSS triangle hack to cover things up.</p>
<p>The triangle hack works by selectively applying borders to zero width/height elements, take a look at <a href=http://jsfiddle.net/csswizardry/ZDNu7/28/>this version with the triangles highlighted</a>. All we need to do here is make some of them the same colour as the nav and <a href=http://jsfiddle.net/csswizardry/ZDNu7/21/>we&#8217;re done</a>!</p>
<p>So, by cleverly using a pseudo element we can spoof a hole through elements and then using a second one we can mask the corners off!</p>
<p>The full, commented CSS:</p>
<pre><code>.nav{
	overflow:hidden; <span class=code-comment>/* To clear floats */</span>
	background:#111;
	margin:0;
	padding:0;
	list-style:none;
}
.nav li{
	float:left;
}
.nav a{
	display:block;
	padding:2em <span class=code-comment>/* <-- This is our magic number, this defines how large our notch can be! */</span> 1em;
	color:#fff;
	text-decoration:none;
}
.nav a:hover{
	text-decoration:underline;
}
.nav .current a{
	position:relative;
	text-decoration:underline;
	cursor:text;
}
.nav .current a:before,
.nav .current a:after{
	content:"";
	display:block;
	width:2em; <span class=code-comment>/* Must match our magic number... */</span>
	height:2em; <span class=code-comment>/* ...our notch will end up being half this size. We define it in ems to scale it up with the text size. */</span>
	position:absolute;
	bottom:0;
	left:50%;
	margin-left:-1em; <span class=code-comment>/* Half of our magic number. */</span>
}
body,
.nav .current a:before{
	background:url(http://farm5.static.flickr.com/4102/4876702379_82fe2bd7a8_b.jpg) top left no-repeat fixed; <span class=code-comment>/* Apply to the notch and the relevant container (this case, body). */</span>
}
.nav .current a:after{
	width:0;
	height:0;
	border:1em solid; <span class=code-comment>/* Half of our magic number. */</span>
	border-color:#111 #111 transparent #111; <span class=code-comment>/* Same colours as our nav's background. */</span>
}</code></pre>
<h3>Drawbacks</h3>
<p>There are drawbacks here; you <em>have</em> to have a fixed background image and you have to have a solid background colour for your nav, but they are reasonable trade-offs, considering this doesn&#8217;t use any extra markup at all <em>and</em> works in IE8+!</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/11/create-a-notched-current-state-nav/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Build-along #1, reflection and reasoning</title>
		<link>http://csswizardry.com/2011/11/build-along-1-reflection-and-reasoning/</link>
		<comments>http://csswizardry.com/2011/11/build-along-1-reflection-and-reasoning/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 16:03:54 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Build-along]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[OOCSS]]></category>
		<category><![CDATA[Progressive Enhancement]]></category>
		<category><![CDATA[Responsive web design]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3355</guid>
		<description><![CDATA[Here are, in no particular order, just a few thoughts about the build-along I did last night. These thoughts cover the thinking and reasoning behind the decisions I made. The build-along was a single, small PSD, but the following should apply to builds of any size. Get into the habit of doing the following on [...]]]></description>
			<content:encoded><![CDATA[<p>Here are, in no particular order, just a few thoughts about <a href="http://csswizardry.com/2011/11/css-wizardry-build-along-1/">the build-along</a> I did last night. These thoughts cover the thinking and reasoning behind the decisions I made. The build-along was a single, small PSD, but the following should apply to builds of any size. Get into the habit of doing the following on tiny sites and you&#8217;ll be well equipped to build that next Facebook meets YouTube with a dash of LinkedIn that that prospective client just emailed you about&#8230;</p>
<p>Here is <a href=http://dl.dropbox.com/u/2629908/build-along/index.html>the final build</a> and its code is on <a href=https://github.com/csswizardry/build-along-1>GitHub</a>.</p>
<p><span id="more-3355"></span></p>
<h2>HTML first</h2>
<p>I built this HTML-first. No CSS other than the UA&#8217;s <em>whatsoever</em>. No images, no styles, no JS, no classes, no containers, nothing. I started with pure text-level and content semantics. No <code>div</code>s, no <code>span</code>s, nothing that would in any way aid styling. Nail your pure, raw HTML first before even <em>thinking</em> about CSS. This ensures you&#8217;re thinking fully about the most important aspect of any site; its content.</p>
<h2>No IDs</h2>
<p>The build uses no IDs for styling. This was quite an odd shift for me to make, and I made it <a href=http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/>a number of weeks back</a>. The main drawback of using IDs is that they introduce a specificity wild card not unlike using <code>!important</code> (though obviously not as horrible). By not using them it means that I can&#8217;t really get tripped up by overly specific selectors as easily as I could if I <em>was</em> using IDs. I&#8217;ve not removed the chance completely, but really easily and quickly lessened it.</p>
<h2>&#8216;Ugly&#8217; classes to do lots of heavy lifting</h2>
<p>There are quite a few classes that some might deem ugly; the media and grid classes instantly spring to mind. The thing here is that <strong>classes aren&#8217;t semantic or insemantic</strong>, they&#8217;re merely sensible or insensible. If a <code>div</code> is 6 columns wide then a class of <code>.grid-6</code> is totally sensible, if it needs to change then change it. If you ever redesign you&#8217;ll be touching the markup anyway; I&#8217;m convinced the pure CSS redesign (in a commercial world) is a myth.</p>
<p>These classes also bring performance benefits, once a class gets called once it becomes free to use again; a performance freebie. If you use <code>grid-6</code> once on a page, every subsequent usage is totally free, from a performance point of view.</p>
<h2>Portable sprite icons</h2>
<p>The <code>.s</code> class is a theoretically horrible class, but as we outlined above, nothing (except micro-formats and similar) reads or even cares what you name your classes. <a href="http://jsfiddle.net/csswizardry/YdhEU/">You can name a class anything you wish and a browser has to honour it</a>, just pick wisely!</p>
<p>So, the <code>.s</code> class is one good example. Whenever you want to use an icon background image you ideally want to sprite it, but in fluid elements this isn&#8217;t possible. Enter a <i>spriting element</i>.</p>
<p>This is just an empty element that gets the sprite applied to it in its own fixed width/height box.</p>
<p>Chris Coyier uses <a href="http://css-tricks.com/13224-pseudo-spriting/">pseudo elements for this</a> which is great as it&#8217;s really clean, but the major drawback for me here is that they&#8217;re not very portable. A pseudo element is tied explicitly to an element in the CSS, so you can&#8217;t just drop the icon wherever you wish. Using an empty element means you <em>can</em> drop an icon wherever you wish. It&#8217;s six-of-one and half-a-dozen of the other; cleanliness versus portability; pick which one you&#8217;d rather have.</p>
<p>I can imagine that 75% reading this still think it&#8217;s a horrible, but we need to remember that an empty element affects <em>nothing</em>. It&#8217;s empty so it has no content, if it has no content then screen readers don&#8217;t encounter anything in it.</p>
<p>You&#8217;re probably also thinking that it&#8217;s heavily presentational, but there&#8217;s really no difference between:</p>
<pre><code>&lt;i class="s star"&gt;&lt;/i&gt;
</code></pre>
<p>And:</p>
<pre><code>&lt;img src=star.png alt=""&gt;
</code></pre>
<p>The first is just out-and-out better in that it allows you to sprite that image up!</p>
<p><ins datetime="2011-11-05T16:49:52+00:00" id="addendum:using-i-element">I was asked why an <code>i</code> and not a <code>span</code>. I&#8217;m almost ashamed of the answer but it&#8217;s purely because <code>i</code> is shorter, it&#8217;s as simple as that. I know that a <code>span</code> is probably better suited as it&#8217;s devoid of semantics but as there&#8217;s no content in the <code>i</code> nothing is affected by semantics anyway. Feel free to use whatever element you prefer though, like I said, my reasoning is kind of shameful!</ins></p>
<h2>Mobile first, lay the foundations</h2>
<p>I did this build mobile first, sort out the content, the type, the general <em>feel</em> of the site first, then used <code>min-width</code> media queries to build <strong>up</strong> the desktop version.</p>
<p>Incidentally I don&#8217;t use <a href=https://github.com/scottjehl/Respond>respond.js</a> or similar to get media queries working in IE et al, they get the mobile version. The layout of the site is not that important because <strong>a PSD is a clue, not a contract</strong>. A PSD tells you how a site should generally appear; the type, the colours, any brand treatments, that kind of stuff.</p>
<p>If you spend enough time on the mobile version that should be good enough to serve as the baseline, anything on top is a bonus for browsers that support media queries.</p>
<h2>Grid systems just make life easier</h2>
<p>In a similar vein to the above, grid systems are typically frowned upon as being insemantic, but the joy is that, as we covered, classes are neither semantic or in semantic. Plus&mdash;even better than that&mdash;a <code>div</code> is devoid of any semantics, it&#8217;s a generic container element. Adding these to your markup comes free-of-charge. Using a grid system allows developers to quickly construct consistent, robust and efficient layouts in seconds. </p>
<h2>&#8216;Extraneous&#8217; divs actually make builds far more robust and extensible</h2>
<p>You should <em>never</em> add markup where avoidable, but that doesn&#8217;t mean you should avoid it at all costs. Sometimes adding an extra <code>div</code> will make components a lot less brittle, rather than relying on unpredictable style rules and overly slim markup, sometimes it&#8217;s just far better to add another <code>div</code> to ensure a more robust build.</p>
<p>Take for example <a href="http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/">the media object</a>. You could probably build that construct using far less HTML, but then would it be as extensible? You could just assume there will only ever be an <code>img</code> floated left with a <code>p</code> to the right of it, but if you do that and a client asks for a list with that <code>p</code> and a caption under the <code>img</code> you&#8217;re in a bit of a pickle; if you just start out with a <code>div</code> on each side to start with then you have the ability to build whatever the client throws at you, and it will always be predictable.</p>
<p>So, add extra markup where it saves you headaches. I&#8217;m more impressed by powerful and extensible code than I am with lean and brittle solutions, and I can guarantee which the client will prefer&#8230;</p>
<h2>Don&#8217;t measure stuff</h2>
<p>Throughout this build I only measured one thing; the grid system. I honestly think that, in web design, the pixel&#8217;s days are numbered. Build everything without a care as to its dimensions. Everything in the build can be moved around and dropped anywhere else without you needing to worry if it&#8217;ll fit. All your components should always be fully fluid and only constrained by their parent, in this case the grid system.</p>
<p>Here&#8217;s a challenge, next time your designer sends you a PSD designed on, say, the <a href="http://960.gs">960GS</a>, resize your browser to 800px wide and build it like that. That&#8217;ll really put your fluid, responsive skills to the test!</p>
<h2>Be resourceful</h2>
<p>During this build I copied and pasted <em>loads</em> of code. I used <a href="https://github.com/csswizardry/vanilla">my vanilla boilerplate</a>, I copied and pasted <a href="http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/">the media object</a>, <a href="csswizardry.com/2011/09/the-nav-abstraction/">the nav abstraction</a>, <a href="csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/">the carousel</a>. If it already exists somewhere then reuse it! There are no prizes for writing more lines of code; be resourceful.</p>
<h2>Take away?</h2>
<p>Even on tiny sites, powerful markup is far more quick, robust, extensible and sensible than convoluted, brittle stuff. No one reads your classes except other developers. Users appreciate fast UIs, clients appreciate stable and robust sites and you, the developer, like to save time, be efficient and only solve problems once.</p>
<p>What may at first seem like an ugly class or bloated markup is actually a really quick, predictable and reusable construct.</p>
<p>Websites make us money, so let&#8217;s make them as quickly as possible and in the most predictable, future proof way we can.</p>
<h2>Finally</h2>
<p>There is a video of the build to go with this, but I need your opinions, do you want the full, several hour epic or do you want it sped up to, say, double speed? I&#8217;m going to get that processed as soon as possible.</p>
<h2><ins datetime="2011-11-07T11:12:59+00:00" id="addendum:video">Update</ins></h2>
<p>As promised, I recorded the whole thing warts and all. You might be interested to know a few things non-code related about the build-along.</p>
<ul>
<li>The whole lot was done on an 11&Prime; MacBook Air with no external mouse or keyboard.</li>
<li>My good friend Jake, who is wanting to learn a little about web development, was next to me the whole time.</li>
<li>I cooked and ate my (now famous (in tiny, tiny circles)) chili during the build-along.</li>
<li>Refreshment was courtesy of <a href="http://twitpic.com/78e9yd">Matusalem and Fentimans</a>.</li>
<li>The songs you saw on my Spotify are not necessarily wholly representative of my taste in music ;)</li>
</ul>
<p>The normal, non-sped-up recording is now on YouTube. <a href="http://www.youtube.com/watch?v=dH-KgnepMUw&#038;hd=1">Part 1</a>, <a href="http://www.youtube.com/watch?v=9NToqlCJzfQ&#038;hd=1">Part 2</a>. The sped-up version is proving a little more troublesome; crunching over 4 hours of video on an 11&Prime; Air is taking a while&#8230;</p>
<h3><ins datetime="2011-11-07T13:19:59+00:00" id="addendum:fast-video">Sped-up video</ins></h3>
<p>To view the faster video right away, simply opt in to <a href="http://www.youtube.com/html5">YouTube&#8217;s HTML5 Trial</a>, open the YouTube URLs above in Chrome and then select the playback speed options that now appear on the player.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/11/build-along-1-reflection-and-reasoning/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>CSS Wizardry build-along #1</title>
		<link>http://csswizardry.com/2011/11/css-wizardry-build-along-1/</link>
		<comments>http://csswizardry.com/2011/11/css-wizardry-build-along-1/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 19:59:14 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Build-along]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3315</guid>
		<description><![CDATA[Okay, so here we are, about to kick off the build-along. Make sure you are following me on Twitter at around 7pm UK time on the 4 November as I&#8217;m hoping to start the build-along around then. Thanks to Levi Flair for this PSD:


Thanks to everyone who sent a design in! I feel bad that [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so here we are, about to kick off the build-along. Make sure you are <a href="http://twitter.com/csswizardry">following me on Twitter</a> at around <a href="https://www.google.com/search?q=Time+in+the+UK&#038;ie=utf-8&#038;oe=utf-8&#038;aq=t&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a#pq=time+in+the+uk&#038;hl=en&#038;sugexp=kjrmc&#038;cp=8&#038;gs_id=b&#038;xhr=t&#038;q=Time+in+UK&#038;tok=y6_ahb4u2yl-RL_lp8cxLw&#038;pf=p&#038;sclient=psy-ab&#038;safe=off&#038;client=firefox-a&#038;hs=Q63&#038;rls=org.mozilla:en-US%3Aofficial&#038;source=hp&#038;pbx=1&#038;oq=Time+in++UK&#038;aq=0&#038;aqi=g2g-c1g1&#038;aql=f&#038;gs_sm=&#038;gs_upl=&#038;bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&#038;fp=282a81e04a27f8a1&#038;biw=1024&#038;bih=583"><strong>7pm UK time on the 4 November</strong></a> as I&#8217;m hoping to start the build-along around then. Thanks to <a href="http://www.leviflair.com/">Levi Flair</a> for this PSD:</p>
<p><span id="more-3315"></span></p>
<p><a href="http://csswizardry.com/wp-content/uploads/2011/11/hnpw_home.jpg"><img src="http://csswizardry.com/wp-content/uploads/2011/11/hnpw_home-626x1023.jpg" alt="Build-along PSD screenshot"></a></p>
<p>Thanks to everyone who sent a design in! I feel bad that I can&#8217;t do them all because the quality was really high. Sorry if I didn&#8217;t pick you, a lot more went into the decision than <em>just</em> looks; I needed to consider time-frames, aesthetics, complexity and suitability to the build-along format.</p>
<h2>Follow along</h2>
<dl>
<dt>Live code</dt>
<dd>You can watch the actual build take shape by <a href="http://dl.dropbox.com/u/2629908/build-along/index.html">periodically refreshing this page</a>.</dd>
<dt>Video</dt>
<dd>I&#8217;m actually going to be recording my screen throughout the whole thing, code, Spotify, Twitter, you&#8217;ll see it all. I&#8217;ll be putting this online a few days after (I won&#8217;t be doing a live screen-cast).</dd>
<dt>GitHub</dt>
<dd>I&#8217;m going to commit build milestones to <a href="https://github.com/csswizardry/build-along-1">a GitHub repo</a> periodically so you can see each major step of the build as it happens.</dd>
<dt>Twitter</dt>
<dd><a href="http://twitter.com/csswizardry">Follow me</a> and keep an eye on <a href="https://twitter.com/search/%23buildAlong">the #buildAlong hashtag</a> (please also use this for anything you Tweet about the event).</dd>
</dl>
<p>Feel free to Tweet at me whilst I&#8217;m working. This should be fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/11/css-wizardry-build-along-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Fully fluid, responsive CSS carousel</title>
		<link>http://csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/</link>
		<comments>http://csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 22:46:10 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Progressive Enhancement]]></category>
		<category><![CDATA[Responsive web design]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3288</guid>
		<description><![CDATA[If you follow me on Twitter you&#8217;ll know I&#8217;ve been pretty enthused about this fluid CSS carousel of mine. There are two aspects to it; the fluidity and the CSS functionality.
Demo

The demo features photos of me, taken on various mountains by Suze. Cheers to her for the content.
The fluidity
Making a carousel fluid is actually ridiculously [...]]]></description>
			<content:encoded><![CDATA[<p>If you <a href="http://twitter.com/csswizardry">follow me on Twitter</a> you&#8217;ll know I&#8217;ve been pretty enthused about this <a href="http://dl.dropbox.com/u/2629908/sandbox/fluid-css-carousel/index.html">fluid CSS carousel</a> of mine. There are two aspects to it; the fluidity and the CSS functionality.</p>
<h2><a href="http://dl.dropbox.com/u/2629908/sandbox/fluid-css-carousel/index.html">Demo</a></h2>
<p><span id="more-3288"></span></p>
<p>The demo features photos of me, taken on various mountains by <a href="http://twitter.com/suzehaworth">Suze</a>. Cheers to her for the content.</p>
<h2>The fluidity</h2>
<p>Making a carousel fluid is actually ridiculously simple. Let us assume you have five panels. Remember that number!</p>
<p>A carousel is made up of three basic components:</p>
<ol>
<li>A viewport</li>
<li>A wrapper for the panes</li>
<li>A pane</li>
</ol>
<p>Thus, our markup is:</p>
<pre><code>&lt;div class=carousel&gt;

  &lt;ul class=panes&gt;

    &lt;li&gt;
      &lt;h2&gt;Pane 01 title&lt;/h2&gt;
      &lt;img src=pane-01.jpg alt=""&gt;
    &lt;/li&gt;

    &lt;li&gt;
      &lt;h2&gt;Pane 02 title&lt;/h2&gt;
      &lt;img src=pane-02.jpg alt=""&gt;
    &lt;/li&gt;

    &lt;li&gt;
      &lt;h2&gt;Pane 03 title&lt;/h2&gt;
      &lt;img src=pane-03.jpg alt=""&gt;
    &lt;/li&gt;

    &lt;li&gt;
      &lt;h2&gt;Pane 04 title&lt;/h2&gt;
      &lt;img src=pane-04.jpg alt=""&gt;
    &lt;/li&gt;

    &lt;li&gt;
      &lt;h2&gt;Pane 05 title&lt;/h2&gt;
      &lt;img src=pane-05.jpg alt=""&gt;
    &lt;/li&gt;

  &lt;/ul&gt;

&lt;/div&gt;</code></pre>
<p>Now, the viewport defines what we see, we slide our panes behind it and they poke through, like this:</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2011/10/carousel-anatomy.jpg" alt="Anatomy of a carousel"></p>
<p>The red denotes the viewport (and incidentally a single pane), the blue denotes the whole five panes <em>behind</em> the viewport.</p>
<p>We just slide these behind the viewport to show a certain amount at a time, et voilà; carousel. But, you all know how carousels work, right&#8230;?</p>
<p>To make this fluid is so simple. The viewport needs to fill its container, so this gets <code>width:100%;</code>. Easy.</p>
<p>One pane needs to fit nicely in the viewport, so this needs to occupy 100% of the viewport. With this in mind&#8230;</p>
<p>We have five panes, remember, so the <code>ul</code> needs a width of 500%. Five panes that are each the same width as the viewport gives us a width of <strong>500%</strong>.</p>
<p>Now we know:</p>
<pre><code>.carousel{
  width:100%;
}
.panes{
  width:500%;
}</code></pre>
<p>So if <code>.panes</code> holds five panes, each pane should be 20% its width. This is where it might get a little confusing&#8230;</p>
<p>The viewport is 100% width, the wrapper is five times as big as that and each pane is one fifth the width of the wrapper.</p>
<p>Our code is left at:</p>
<pre><code><span class=code-comment>/*------------------------------------*\
	$CAROUSEL
\*------------------------------------*/</span>
.carousel{
    overflow:hidden;
    <mark>width:100%;</mark>
}
.panes{
    list-style:none;
    position:relative;
    <mark>width:500%;</mark> <span class=code-comment>/* Number of panes * 100% */</span>
    overflow:hidden; <span class=code-comment>/* This is used solely to clear floats, it does not add functionality. */</span>

    -moz-animation:carousel 30s infinite;
    -webkit-animation:carousel 30s infinite;
    animation:carousel 30s infinite;
}
.panes > li{
    position:relative;
    float:left;
    <mark>width:20%;</mark> <span class=code-comment>/* 100 / number of panes */</span>
}
.carousel img{
    display:block;
    width:100%;
    max-width:100%;
}
.carousel h2{
    font-size:1em;
    padding:0.5em;
    position:absolute;
    right:10px;
    bottom:10px;
    left:10px;
    text-align:right;
    color:#fff;
    background-color:rgba(0,0,0,0.75);
}</code></pre>
<p>The basic equation for making a carousel with any number of panes is:</p>
<pre><code>.carousel{
  width:100%;
}
.panes{
  width:<mark>100 * number of panes</mark>%;
}
.panes > li{
  width:<mark>100 / number of panes</mark>%;
}</code></pre>
<p>So, a four-pane carousel would be:</p>
<pre><code>.carousel{
  width:100%;
}
.panes{
  width:<mark>400</mark>%;
}
.panes > li{
  width:<mark>25</mark>%;
}</code></pre>
<p>It really is that simple. That&#8217;s all there is to making a fluid carousel.</p>
<h2>CSS powered</h2>
<p>Okay, in this carousel I decided I was going to power it with CSS. This is super unorthodox so if you&#8217;re yelling <q>WTF</q> at your screen please read on!</p>
<p>It was going to be (and actually is) used on my good friend <a href="http://sampenrose.co.uk/">Sam Penrose&#8217;s new design portfolio</a>, so knowing we had free reign and a little chance to experiment I decided to opt for a pure CSS solution.</p>
<p>This is simple in theory but the maths gets <em>so</em> tricky.</p>
<p>All we do is animate <code>.panels</code> from right to left then back again. We animate for a bit, we pause, we animate again, pause again and so on until it&#8217;s done. Then we loop it infinitely.</p>
<p>The CSS is:</p>
<pre><code>@keyframes carousel{
    0%    { left:0; }
    11%   { left:0; }
    12.5% { left:-100%; }
    23.5% { left:-100%; }
    25%   { left:-200%; }
    36%   { left:-200%; }
    37.5% { left:-300%; }
    48.5% { left:-300%; }
    50%   { left:-400%; }
    61%   { left:-400%; }
    62.5% { left:-300%; }
    73.5% { left:-300%; }
    75%   { left:-200%; }
    86%   { left:-200%; }
    87.5% { left:-100%; }
    98.5% { left:-100%; }
    100%  { left:0; }
}</code></pre>
<p>The numbers are so tricky to work with and if anyone can come up with a decent equation to describe it I would be so happy. I&#8217;ve got <a href="http://twitter.com/makeusabrew">Nick</a> on the job, but I&#8217;ve not worked it out yet; I can&#8217;t quite grasp the relation between five panes and the numbers above in a way that I could do some quick maths to work out the animations for a four-pane carousel.</p>
<p>The problem is that you have to know how many full moves and pauses are needed for a full iteration of the carousel (before it starts on its infinite loop), and then how to evenly space these numbers between 0 and 100%. My animations last for 1.5% and pause for 11%, these numbers are perfect for adding up to 100%.</p>
<h2><ins datetime="2011-11-01T09:27:11+00:00">Update</ins></h2>
<p>Massive thanks to Clay who&#8217;s worked out that the number of steps is 4<var>n</var>-3 and that the total time between start of one animation and the next is 100 / 2(<var>n</var>-1) (where <var>n</var> is the number of panes). See <a href="http://csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/#comment-95396">his full comment</a>.</p>
<p>But, the code above will sort you out a perfect animation for a five panes so feel free to nab it! I&#8217;ll update if and when I crack some maths!</p>
<h3>Wait, CSS?!</h3>
<p>Using CSS for this is really, really unorthodox so comes with some massive caveats.</p>
<p>Do not use CSS to animate this carousel if:</p>
<ol>
<li>You require the contents of every pane to be visually accessible to the user.</li>
<li>You require full browser support.</li>
<li>You do not require interactions (like stopping the animation or clicking between panes).</li>
</ol>
<p>If you are going to use this CSS-only method then ensure that:</p>
<ol>
<li>The user can still use the site fully without the contents of the panes.</li>
<li>You are okay with older browsers not animating and just displaying the first pane.</li>
<li>You do not want or require users to be able to interact with the carousel.</li>
</ol>
<p>If you can&#8217;t use CSS then combine the fluidity above with plain ol&#8217; trusty JS.</p>
<p>I will happily say that the fluidity is the most important, useful and impressive thing about this technique. Until I, or anyone, can get you a decent equation to substitute your numbers into, the CSS animations are too cumbersome and restrictive to be of large-scale use to most people.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>The CSS Wizardry build-along is go!</title>
		<link>http://csswizardry.com/2011/10/the-css-wizardry-build-along-is-go/</link>
		<comments>http://csswizardry.com/2011/10/the-css-wizardry-build-along-is-go/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 17:22:22 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Build-along]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3267</guid>
		<description><![CDATA[Okay, so you decided it wouldn&#8217;t be boring and that I&#8217;m not big-headed in thinking that people might actually want to watch me coding, so I&#8217;m quite excited to announce that the build-along will be going ahead!
Entry is now closed. Thanks all who sent in a PSD, watch this space for a launch article.
Obviously there [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so you decided it wouldn&#8217;t be boring and that I&#8217;m not big-headed in thinking that people might actually want to watch me coding, so I&#8217;m quite excited to announce that <a href="http://csswizardry.com/2011/10/build-along-testing-the-water/">the build-along</a> will be going ahead!</p>
<p class=hilite>Entry is now closed. Thanks all who sent in a PSD, watch this space for a launch article.</p>
<p>Obviously there need to be some terms and conditions. Apologies if these seem a little harsh(ly worded) but they are as follows:</p>
<ul>
<li><strong>PSDs only.</strong> Sorry, I don&#8217;t work with Fireworks enough to make me quick enough for this type of exercise.</li>
<li>The PSD I choose is my choice. I am only doing one and it&#8217;ll most likely be one that&#8217;s fun but not mountains of work; I need to be able to do it in a night.</li>
<li><strong>CSS and HTML only.</strong> No Javascript as I don&#8217;t know Javascript; you would not want me even attempting it!</li>
<li>The code I provide will be <em>final</em>. Progressive enhancement will be used, it won&#8217;t look the same in every browser, you won&#8217;t get to make any change requests or ask for bug fixes after the fact. Naturally I&#8217;m going to do a good job, you won&#8217;t end up with any messy code, but as this is entirely free I can&#8217;t take instruction.</li>
<li>If you&#8217;re, for whatever reason, unhappy with the outcome I&#8217;m afraid you&#8217;re stuck with it&#8230; Whether the final page goes into production or not is entirely up to you.</li>
<li>The PSD must be all above board; I won&#8217;t be building you a new adult dating site ;)</li>
<li>This one is entirely your responsibility but I strongly advise you are fully transparent if your PSD will be sold on to a client. I have no qualms with you making a profit on my work but make sure your client is cool with it, especially when their site design will be being made totally public.</li>
</ul>
<p>I&#8217;m keen to keep this as informal as possible, but the format will take:</p>
<ol>
<li>If you want me to build your PSD please email a <strong>full-size JPG</strong> of your design by <strong>Wednesday 2 November 2011</strong> to harry at csswizardry dot com <strong>with the subject line <i>Build-along</i></strong>. This subject line is vital as I&#8217;m going to set up a Gmail rule to group stuff. Any non-conforming emails might get overlooked.</li>
<li>I&#8217;ll look at the JPGs and choose one to build. I&#8217;ll announce the person I choose in a blog post and also email them directly, at which point they reply with their actual PSD file. If your PSD didn&#8217;t get chosen then I will not email you I&#8217;m afraid; that&#8217;d take forever!</li>
<li>The PSD must be properly constructed. I don&#8217;t want to be battling with any <i>Layer 12 Copy 4 v2</i> stuff!</li>
<li>Make sure you provide any font-files or Typekit etc information if your design uses them.</li>
<li>I&#8217;m most likely going to be building the PSD on <strong>Friday 4 November 2011</strong>. The reason for this is that if it keeps me up into the early hours then I&#8217;d rather that was on a weekend rather than a work-night. This does mean that if you want to follow along then you&#8217;ll have to be in on a Friday evening, no pub!</li>
<li>I&#8217;ll announce the URL in a blog post and Twitter, you can follow along live.</li>
<li>The code <em>will</em> be getting committed to GitHub, too, so make sure you&#8217;re okay with that!</li>
</ol>
<p>This all seems a bit formal, I realise, but it really won&#8217;t be. I just need to make sure I have all the stuff in the right place at the right time!</p>
<p>Pop any questions in the comments and I&#8217;ll update the post as necessary. Please hashtag <em>any and all</em> tweets about the event with <b>#buildAlong</b>.</p>
<p>So, in summary:</p>
<ol>
<li>Get a nice, neat, tidy PSD together.</li>
<li>Send me a <strong>JPG</strong> of it as per the exact email rules.</li>
<li>I&#8217;ll announce whose PSD I&#8217;ll be building in a blog post.</li>
<li>Be around at about 7pm UTC (Dublin, Edinburgh, Lisbon, London) on Friday 4th November to watch along as I code.</li>
<li>You will get a HTML/CSS single page template emailed back to you once it&#8217;s done.</li>
</ol>
<p>Right, get emailing me!</p>
<h2 id="update:psd-shortage"><ins datetime="2011-10-31T14:50:48+00:00">Update</ins></h2>
<p>While there are loads of you interested in watching this event, no one has sent in a PSD. Not one! Mention this to friends, your boss, your designer, anyone. Without a PSD the build-along can&#8217;t run :(</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/10/the-css-wizardry-build-along-is-go/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Build-along (testing the water)</title>
		<link>http://csswizardry.com/2011/10/build-along-testing-the-water/</link>
		<comments>http://csswizardry.com/2011/10/build-along-testing-the-water/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 18:47:50 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Build-along]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3257</guid>
		<description><![CDATA[N.B. The build along went ahead.
I&#8217;ve been toying around with this idea the last few weeks. I&#8217;ve decided to do a quick testing-the-water blog post to gauge interest and see whether anyone else would be into the idea. The story goes thus&#8230;
A few weeks ago I was building a page for my good friend and [...]]]></description>
			<content:encoded><![CDATA[<p class=hilite><strong>N.B.</strong> The build along <a href=http://csswizardry.com/2011/11/build-along-1-reflection-and-reasoning/>went ahead</a>.</p>
<p>I&#8217;ve been toying around with this idea the last few weeks. I&#8217;ve decided to do a quick <i>testing-the-water</i> blog post to gauge interest and see whether anyone else would be into the idea. The story goes thus&#8230;</p>
<p>A few weeks ago I was building a page for my good friend and awesome chap <a href="http://twitter.com/makeusabrew">Nick Payne</a>&mdash;the page had been designed by another swell fella, <a href="http://twitter.com/anatomic">Ian Thomas</a>. We&#8217;re all pretty good friends and all excel in different areas, Ian designed Nick&#8217;s site and, <a href="http://csswizardry.com/2011/09/do-designers-need-to-code/">as designers <em>don&#8217;t</em> need to code</a>, I built it. Nick sorted all the back-end and is building it onto <a href="http://jaoss.org"><abbr title="Just Another Open Source System">JAOSS</abbr></a>.</p>
<p><ins datetime="2011-10-26T08:18:11+00:00"><strong>N.B.</strong> Ian can and does actually code, but for this project we all wanted a slice of the action so, in this case, he didn&#8217;t&#8230;</ins></p>
<p>Anyway, I always build static HTML files in my <a href="http://db.tt/9mQuY9k">Dropbox</a> <i>public</i> directory as people can have a quick look at it if I need to share it, plus I can test it on a variety of browsers on different devices. I gave Nick the URL early on and told him I was about to get to work&#8230;</p>
<p>An hour or so later I got a text from Nick saying that he was loving seeing the progress with every refresh, which I also thought was pretty cool.</p>
<p>Enter my idea&#8230; a live build-along!</p>
<p>The idea I&#8217;m toying with is that people (it could be pretty much anyone) get in touch (somehow) with PSDs they need building; a PSD that they were going to get their staff in their agency to do, or that they were going to give out to a freelancer, anything, and I will pick one and build it for free on the provision I can build it in my public directory and that people can watch along as I code away.</p>
<p>There are obviously some massive requirements:</p>
<ul>
<li>People would actually want to watch me code a page up; I feel I may be being terribly big-headed in assuming people might actually want to watch me code.</li>
<li>The PSD is all above board, doesn&#8217;t break any <abbr title="Non-Disclosure Agreement">NDA</abbr>s etc.</li>
<li>Whoever gets &#8216;picked&#8217; doesn&#8217;t mind their work being made wholly public from the outset.</li>
</ul>
<p>The outcomes would be:</p>
<ul>
<li>Someone gets a free template (one page) built.</li>
<li>People who wouldn&#8217;t die of boredom get to follow along as I build a page (I seriously think the idea of seeing how someone tackles a build would be really cool, it&#8217;d be like watching TV and yelling along: <q>&#8216;Clear your floats!!!&#8217;</q>)</li>
</ul>
<p>So basically:</p>
<ol>
<li>People submit PSDs.</li>
<li>I choose one.</li>
<li>I pick an evening to build it.</li>
<li>I share the URL on Twitter and in a blog post.</li>
<li>People can keep the tab open and keep dipping in-and-out as I build, watching the progress.</li>
<li>For people not in the right time-zone I could potentially record the screen.</li>
<li>I finish and hand back a fully coded single-page.</li>
</ol>
<p>Naturally there would be some informal terms and conditions that I&#8217;d iron out nearer the time but for now, anyone interested?</p>
<p>Lemme know!<br />
<i>Harry</i></p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/10/build-along-testing-the-water/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Reset restarted</title>
		<link>http://csswizardry.com/2011/10/reset-restarted/</link>
		<comments>http://csswizardry.com/2011/10/reset-restarted/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 20:17:39 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Reset]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3231</guid>
		<description><![CDATA[Everyone knows the trusty CSS reset; that oh-so-useful tool that saves us many a headache. We love it so much in fact that we tend to use it on every project&#8212;but therein lies the problem&#8230;
When I discovered the CSS reset I almost cried with joy; the sheer amount of headaches, bug fixes&#8212;and thus time&#8212;it saved [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone knows the trusty CSS reset; that oh-so-useful tool that saves us many a headache. We love it so much in fact that we tend to use it on every project&mdash;but therein lies the problem&hellip;</p>
<p>When I discovered the CSS reset I almost cried with joy; the sheer amount of headaches, bug fixes&mdash;and thus time&mdash;it saved me was astounding. I vowed from that day on that I&#8217;d always use it, wherever I go. I&#8217;ve now realised that was a little silly&hellip;</p>
<p>I&#8217;ve realised that each time I blindly copy paste my reset, I do so without thinking, I&#8217;ve never really stopped to think about what&#8217;s in it, or what it all does.</p>
<p>Some time ago I removed the frankly ridiculous lists rest:</p>
<pre><code>ul,ol{ list-style:none; }</code></pre>
<p>I have no idea how this ever got into a reset. I mean sure, it resets it&mdash;and Meyer does tell you to use the reset with care&mdash;but to remove the bullets from lists is more than a little daft if you ask me. Lists without bullets are the exception rather than the rule, so remove them <em>only</em> when you don&#8217;t want them, otherwise you end up with code like this:</p>
<pre><code>ul,ol{ list-style:none; }

.nav li{
    display:inline
}

.plain-old-regular-list{
    list-style:disc outside;
}</code></pre>
<p>Whereas this is actually way more sensible:</p>
<pre><code>.nav{
    list-style:none;
}
.nav li{
    display:inline
}</code></pre>
<p>Anyway, that aside, I&#8217;ve recently realised that my reset was getting stupid, and it&#8217;s embarrassing to admit that I had stylesheets like this:</p>
<pre><code><span class=code-comment>/* RESET */</span>
h1,h2,h3,h4,h5,h6{
  font-weight:normal;
}
em,strong{
  font-style:normal;
  font-weight:normal;
}

...

<span class=code-comment>/* TYPE */</span>
h1,h2,h3,h4,h5,h6{
  font-weight:bold;
}
em{
  font-style:italic;
}
strong{
  font-weight:bold;
}</code></pre>
<p>I know, face palm, right?</p>
<p>So I started to slowly slim my reset down to some sensible defaults and I removed things that I found myself constantly overwriting or deleting and finally, tonight, I skimmed over the HTML spec&#8217;s text level elements and I restarted my reset using sensible default styles based on the elements&#8217; semantics.</p>
<p>The reset is below, but <strong>do not treat this one as the final version!</strong></p>
<pre><code><span class=code-comment>/*------------------------------------*\
    RESET
\*------------------------------------*/
/*
A more considered reset; more of a restart...
*/</span>
html,body,div,span,applet,object,iframe,
h1,h2,h3,h4,h5,h6,p,blockquote,pre,hr,
a,abbr,address,cite,code,
del,dfn,em,img,ins,kbd,q,s,samp,
small,strong,sub,sup,tt,var,
b,u,i,
dl,dt,dd,ol,ul,li,
fieldset,form,label,legend,
table,caption,tbody,tfoot,thead,tr,th,td,
article,aside,canvas,details,figcaption,figure,
footer,header,hgroup,menu,nav,section,summary,
time,mark,audio,video{
	margin:0;
	padding:0;
}
article,aside,details,figcaption,figure,footer,
header,hgroup,menu,nav,section{
	display:block;
}
h1,h2,h3,h4,h5,h6{
	font-size:100%;
}
table{
	border-collapse:collapse;
	border-spacing:0;
}
strong,b,mark{
	font-weight:bold;
	font-style:inherit;
}
em,i,cite,q,address,dfn,var{
	font-style:italic;
	font-weight:inherit;
}
abbr[title],dfn[title]{
	cursor:help;
	border-bottom:1px dotted;
}
ins{
	border-bottom:1px solid;
}
a,u,ins{
	text-decoration:none;
}
del,s{
	text-decoration:line-through;
}
pre,code,samp,kbd{
	font-family:monospace;
}
small{
	font-size:0.75em;
}
img{
	border:none;
	font-style:italic;
}
input,
select,
textarea{
	font:inherit;
}</code></pre>
<p>Find the always-up-to-date reset in <a href="https://github.com/csswizardry/vanilla"><cite>vanilla</cite> on GitHub</a>.</p>
<p>Things I&#8217;ve removed:</p>
<ul>
<li>Deprecated elements like <code>big</code>, <code>center</code>, <code>acronym</code> etc.</li>
<li>Aforementioned lists reset.</li>
<li>Removal of borders from fieldsets (this needs defining on a per-design basis).</li>
<li>Font weights and styles have been redefined rather than removed.</li>
<li>Removed the underlines from the redefined <code>u</code> element as well as from the <code>a</code> by default as per my article <a href="http://csswizardry.com/2011/05/on-negative-hovers/"><cite>On negative hovers</cite></a>.</li>
</ul>
<p>Things I&#8217;ve added:</p>
<ul>
<li>Default stylings for text-level elements.</li>
<li>Default styles for several new and/or redefined HTML5 elements (e.g. <code>mark</code> and <code>u</code>).</li>
<li><a href="http://csswizardry.com/2011/06/styling-alt-text-on-images/">Text styles on images</a></li>
<li>Make form elements inherit type properly.</li>
</ul>
<p>Even if you don&#8217;t chose to use my reset (though it&#8217;d be great if you did) the one thing I urge you to take from this article is <strong>think about your reset</strong>. If you find yourself constantly overwriting rules from it then you ought to remove them. And remember; your reset can change per-build! You don&#8217;t always have to use the same one, just alter it where necessary for each design.</p>
<p>For example, let&#8217;s say that most of the time you opt to not have bordered <code>fieldset</code>s; if this is the case then it is safe to keep that section in your reset. But if, for whatever reason, a design <em>does</em> include them then simply <em>remove</em> that part. This makes far more sense than styling a <code>fieldset</code> twice; once in your reset to remove a border and once in your CSS to reapply it.</p>
<p>Reconsider your reset; the one I&#8217;ve authored is a pretty comprehensive one that will remove all quirky bits and pieces and leave you with nice&mdash;rather than stark&mdash;defaults. If you opt not to adopt mine then give your own some loving. <strong>Restart your reset!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/10/reset-restarted/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>The ‘island’ object</title>
		<link>http://csswizardry.com/2011/10/the-island-object/</link>
		<comments>http://csswizardry.com/2011/10/the-island-object/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 13:03:43 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DRY]]></category>
		<category><![CDATA[OOCSS]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3218</guid>
		<description><![CDATA[One thing I&#8217;ve been doing a lot of lately, since starting at Sky, is writing abstractions. OOCSS is nothing new, but its basic premise is that you can build really simple objects using a base class and then extend that object with more classes to add more styling to make a simple construct progressively more [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I&#8217;ve been doing a lot of lately, since starting at <a href="http://bskyb.com">Sky</a>, is writing abstractions. <a href="http://www.oocss.org">OOCSS</a> is nothing new, but its basic premise is that you can build really simple objects using a base class and then extend that object with more classes to add more styling to make a simple construct progressively more complex and specific.</p>
<p>One abstract I love is by <a href="https://twitter.com/stubbornella">Nicole Sullivan</a> (one of the best front-end devs in the world ever); the <a href="http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/">media object</a>. Another I wrote is the more simple <a href="http://csswizardry.com/2011/09/the-nav-abstraction/">nav abstraction</a>.</p>
<p>Today I&#8217;m going to share one that&#8217;s simpler still; the <i>island object</i>&#8230;</p>
<p>This super simple object is basically a single class used to box off content, leaving it closed on all sides like, well, an island.</p>
<p>Often you&#8217;d find yourself with markup and CSS a little like this:</p>
<pre><code>&lt;div class=content&gt;

  &lt;div class=promo&gt;
      ...
  &lt;/div&gt;

&lt;/div&gt;

&lt;div class=sub-content&gt;

  &lt;div class=twitter&gt;
    ...
  &lt;/div&gt;

&lt;/div&gt;

.content{
  width:460px;
  float:left;
  padding:20px;
  margin-bottom:20px;
  background-color:#fff;
}
.sub-content{
  width:160px;
  float:left;
  padding:20px;
  margin-bottom:20px;
  background-color:#333;
  color:#fff;
}
.promo{
  padding:20px;
  margin-bottom:20px;
  border:1px solid #ff8;
  background-color:#ffc;
  color:#333;
}
.twitter{
  padding:20px;
  margin-bottom:20px;
  color:#fff;
  background-color:#00a0d1;
}</code></pre>
<p>Here we see that these are all standalone blocks of boxed off content, but they all share certain things in common. These are essentially all islands of content that are individually adapted to look different.</p>
<p>Instead of repeating these declarations over and over we can make an abstraction to create padded, boxed off areas.</p>
<p>Now, we could use <code>.box</code> as a class but this implies square; we could have a redesign where we use rounded corners or even wacky, wavy background images which, although <em>are</em> boxed off, aren&#8217;t presentationally boxes. We don&#8217;t like presentational classes if we can help it.</p>
<p>Enter the <code>.island</code> class. Now our markup and CSS would be:</p>
<pre><code>&lt;div class=&quot;island content&quot;&gt;

  &lt;div class=&quot;island promo&quot;&gt;
      ...
  &lt;/div&gt;

&lt;/div&gt;

&lt;div class=&quot;island sub-content&quot;&gt;

  &lt;div class=&quot;island twitter&quot;&gt;
    ...
  &lt;/div&gt;

&lt;/div&gt;

.island{
  padding:20px;
  margin-bottom:20px;
}
  .island &gt; :last-child{
    margin-bottom:0; <span class=code-comment>/* Remove the margin from the last child of a boxed off area so that we don't end up with compounded margin/padding spacings. */</span>
  }

.content{
  width:460px;
  float:left;
  background-color:#fff;
}
.sub-content{
  width:160px;
  float:left;
  background-color:#333;
  color:#fff;
}
.promo{
  border:1px solid #ff8;
  background-color:#ffc;
  color:#333;
}
.twitter{
  color:#fff;
  background-color:#00a0d1;
}</code></pre>
<p>This does make the HTML a tad larger, but the <code>.island</code> class is a powerful one that can quickly and rapidly create new areas of content without having to redeclare styles over and over.</p>
<p>Extending the island object with more specific styles means that you can have components that look vastly different but that are built upon the same basic construct. This also means that if you decide you design needs a little more white-space you can up the <code>.island</code> padding to, say, 24px in one go and all content blocks will inherit this new style.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/10/the-island-object/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

