<?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; HTML</title>
	<atom:link href="http://csswizardry.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://csswizardry.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 16 May 2012 12:57:59 +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>The single responsibility principle applied to CSS</title>
		<link>http://csswizardry.com/2012/04/the-single-responsibility-principle-applied-to-css/</link>
		<comments>http://csswizardry.com/2012/04/the-single-responsibility-principle-applied-to-css/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 22:57:37 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[OOCSS]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3614</guid>
		<description><![CDATA[Having just spoken at the Front-Trends conference in Warsaw, I’ve decided to expand on something which my talk mentioned a lot: classes.
My talk covered how to build big, scalable front-ends and one of the key factors involved in doing so is sensible and generous use of abstracted classes. One thing that really helps you achieve [...]]]></description>
			<content:encoded><![CDATA[<p>Having just spoken at <a href="http://2012.front-trends.com/">the Front-Trends conference in Warsaw</a>, I’ve decided to expand on something which my talk mentioned a lot: classes.</p>
<p>My talk covered how to build big, scalable front-ends and one of the key factors involved in doing so is sensible and generous use of abstracted classes. One thing that really helps you achieve this is the application of the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">single responsibility principle</a>, a method used mainly in OO programming.</p>
<p><span id="more-3614"></span></p>
<p>Loosely, the single responsibility principle states that every module or chunk of code (a function etc) should do one job well and one job only. The benefits of this are mainly in the way of maintainability and extensibility.</p>
<p>If we don’t adhere to the SRP then we are likely to end up with code which does more than it should, this means that altering one part of that code could negatively impact a seemingly unrelated part of the same snippet. It also makes our code a lot less flexible in that we find our code is trying to do too much; it is too specific in its job to be portable and reusable. Abstracting chunks of functionality into several responsibilities means we can reuse a lot more of our code and recombine it over and over with other similarly abstracted chunks.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Wikipedia article</a> makes a much better job of explaining than I can so I would recommend giving that a quick read (it’s only short).</p>
<p>Also, you will find that a lot of us do this already, and perhaps without even realising. A class of <code>.wrapper</code> is a good example of the SRP at play; by having a single, reusable class whose sole job it is to group content we make our code a lot easier to work with. We don’t need to apply lots of widths to lots of elements; we use one extra <code>div</code> and delegate the width-constraining responsibility to that.</p>
<p>We do this because it makes sense, but we don’t do it often enough; if we start actually thinking like this all the time we find we can vastly improve our code&#8230;</p>
<p>The SRP is normally applied in programming circles but I have definitely found it is <em>incredibly</em> useful when making lean, scalable front-ends. Here’s a quick example of un-abstracted code that <strong>doesn’t</strong> follow the SRP:</p>
<pre><code><span class=code-comment>&lt;!-- HTML --&gt;</span>
&lt;a href=/product class=<mark>promo</mark>&gt;Buy now!&lt;/a&gt;

<span class=code-comment>/* CSS */</span>
.promo{
    display:block;
    padding:20px;
    margin-bottom:20px;
    background-color:#09f;
    color:#fff;
    tex-shadow:0 0 1px rgba(0,0,0,0.25);
    border-radius:4px;
}</code></pre>
<p>Here we have a class for a promotional box of content. Here we are doing <strong>two</strong> things—we are defining box model and structure <em>and</em> we are defining cosmetics (colouring etc).</p>
<p>We can refactor this code to adhere to the SRP by splitting those two chunks of functionality into two classes:</p>
<pre><code> <span class=code-comment>&lt;!-- HTML --&gt;</span>
&lt;a href=product class="<mark>island</mark> promo"&gt;Buy now!&lt;/a&gt;

<span class=code-comment>/* CSS */</span>
.island{
    display:block;
    padding:20px;
    margin-bottom:20px;
}

.promo{
    background-color:#09f;
    color:#fff;
    tex-shadow:0 0 1px rgba(0,0,0,0.25);
    border-radius:4px;
}</code></pre>
<p>We now have two classes which each carry a single responsibility; <code>.island</code> boxes off content and <code>.promo</code> applies our promotional styling. This now means that we can do things like this, which previously we couldn’t:</p>
<pre><code> <span class=code-comment>&lt;!-- HTML --&gt;</span>
&lt;h2&gt;Buy now with promo code: &lt;span class=<mark>promo</mark>&gt;0MG4WE50ME&lt;/span&gt;&lt;/h2&gt;</code></pre>
<p>Previously we couldn’t have managed this as the <code>.promo</code> class also carried a lot of box model; by abstracting our code into single responsibilities we can pick and choose what we want to use and where a lot more easily.</p>
<p>We can take this much, much further; now we also have a generic class for boxing off content! Where we once might have had:</p>
<pre><code><span class=code-comment>&lt;!-- HTML --&gt;</span>
&lt;div id=header&gt;
&lt;/div&gt;

&lt;div id=content&gt;
&lt;/div&gt;

&lt;div id=sub-content&gt;
&lt;/div&gt;

&lt;div id=footer&gt;
&lt;/div&gt;

<span class=code-comment>/* CSS */</span>
#header{
    padding:20px;
    margin-bottom:20px;
    background-color:#121416;
    color:#fff;
}

#content{
    width:640px;
    float:left;
    margin-right:20px;
    padding:20px;
    margin-bottom:20px;
}

#sub-content{
    width:280px;
    float:left;
    padding:20px;
    margin-bottom:20px;
}

#footer{
    padding:20px;
    margin-bottom:20px;
    background-color:#e4e4e4;
    color:#333;
}</code></pre>
<p>We would now have:</p>
<pre><code><span class=code-comment>&lt;!-- HTML --&gt;</span>
&lt;div class="<mark>island</mark> header"&gt;
&lt;/div&gt;

&lt;div class="<mark>island</mark> content"&gt;

    &lt;h2&gt;Buy now with promo code &lt;span class=<mark>promo</mark>&gt;0MG4WE50ME&lt;/span&gt;&lt;/h2&gt;

&lt;/div&gt;

&lt;div class="<mark>island</mark> sub-content"&gt;

    &lt;a href=product class="<mark>island</mark> <mark>promo</mark>"&gt;Buy now!&lt;/a&gt;

&lt;/div&gt;

&lt;div class="<mark>island</mark> footer"&gt;
&lt;/div&gt;

<span class=code-comment>/* CSS */</span>
.island{
    display:block;
    padding:20px;
    margin-bottom:20px;
}

.promo{
    background-color:#09f;
    color:#fff;
    tex-shadow:0 0 1px rgba(0,0,0,0.25);
    border-radius:4px;
}

.header{
    background-color:#121416;
    color:#fff;
}

.content{
    width:640px;
    float:left;
    margin-right:20px;
}

.sub-content{
    width:280px;
    float:left;
}

.footer{
    background-color:#e4e4e4;
    color:#333;
}</code></pre>
<p>Because we abstracted our code out we now have a really portable class for simply boxing off content!</p>
<p><strong>N.B.</strong> You should also abstract your layout to a grid system, taking the floats and widths off the page components and leaving that responsibility to the grids.</p>
<p>Just some of the benefits of working like this are:</p>
<ol>
<li>Your CSS is a lot DRYer.</li>
<li>You can make far-reaching changes to your designs by simply modifying a base abstraction only once.</li>
<li>You can make safer changes because you know that when editing a class you are only ever altering <em>one</em> responsibility.</li>
<li>You can combine responsibilities to make a variety of components from a lot of abstracted classes.</li>
</ol>
<p>Now we can take it further <em>still</em>.</p>
<p>Because we have a nice <code>.island</code> class whose sole responsibility is to box off content then we can now do things like this:</p>
<pre><code><span class=code-comment>&lt;!-- HTML --&gt;</span>
&lt;div class="island content"&gt;
    ...
    &lt;form&gt;
        &lt;p class="island <mark>error</mark>"&gt;Please provide your name.&lt;/p&gt;
        ...
        &lt;label class=<mark>error</mark>&gt;Name:&lt;/label&gt;
        ...
    &lt;/form&gt;
    ...
&lt;/div&gt;

<span class=code-comment>/* CSS */</span>
.island{
    display:block;
    padding:20px;
    margin-bottom:20px;
}

.error{
    background-color:#fce0e2;
    color:#c00;
}
.error.island{
    border:5px solid #c00;
    border-radius:4px;
}</code></pre>
<p>Because we have our chunks of CSS only working on one thing at a time then we can reuse and combine useful things time and time again. I’ve written about this before: <a href="https://plus.google.com/u/0/110483125936065828120/posts/DGPQzUdPi84">Class based builds are like eating at Subway</a>.</p>
<h2>When to use it?</h2>
<p>There’s no definite answer to questions like this but as a general rule try and stick to the SRP any time you think that subsets of a style rule could be split out into more manageable and <strong>reusable</strong> abstractions. Any time you are coding a potentially repeatable design pattern then try and split it out as per the single responsibility principle.</p>
<h3>But!</h3>
<p>It’s important not to take this too far; classes should be abstracted but ideally not presentational. Classes like <code>.round-corners</code> for the sake of SRP are really not all that advisable.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2012/04/the-single-responsibility-principle-applied-to-css/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>My HTML/CSS coding style</title>
		<link>http://csswizardry.com/2012/04/my-html-css-coding-style/</link>
		<comments>http://csswizardry.com/2012/04/my-html-css-coding-style/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 18:58:53 +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=3561</guid>
		<description><![CDATA[Whenever I post jsFiddles, tutorials, articles or do some work here at Sky, I’m very particular about my coding style and am often asked questions about it. A lot of people say ‘code is art’; to me that sentence is a little pretentious but what I do think is that code can be a little [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I post jsFiddles, tutorials, articles or do some work here at Sky, I’m very particular about my coding style and am often asked questions about it. A lot of people say ‘code is art’; to me that sentence is a little pretentious but what I <em>do</em> think is that code can be a little more quirky and original than most people write it. It can be interesting. <a href="https://twitter.com/mathias">Mathias Bynens</a> is constantly tweeting crazy little snippets of quirky, valid JS; he’s also made <a href="http://mothereff.in">some great little tools</a> to help you explore the different avenues available to you when writing awesome, expressive and ‘different’ code.</p>
<p><span id="more-3561"></span></p>
<p>When I write HTML and CSS I have a certain set of rules and guidelines I stick to with regards syntax and formatting. I‘ve decided to write them up here <strong>not</strong> to preach or tell you how to do things, but simply to share how <em>I</em> like to work. If you hate the things I do that’s cool, these are not recommendations. If you like anything I do then great; you can have it. What I <em>would</em> love to see is other people doing the same; please consider writing up your coding styles, nuances and preferences and share them about!</p>
<hr />
<h2>HTML</h2>
<p>With HTML5 we have a lot looser syntax which means more scope for experimentation than we were typically used to with XHTML. With things like <code>&lt;li&gt;</code>s not requiring closing, some attributes not requiring quotes, tags not needing to be lowercase and elements like <code>&lt;hr /&gt;</code>s not needing to be self-closing, there’s a lot to play with! Here’s what I do with my HTML&#8230;</p>
<h3>Unquoted attributes</h3>
<p>Where I don’t need to, I don’t quote attributes. Where I would have had <code>class="wrapper"</code> I now have <code>class=wrapper</code>. Why? Because I can and I like the look of it!</p>
<p>Obviously, sometimes you do need to quote attributes. If you have multiple classes like <code>class=wrapper header-wrapper</code> then you <em>need</em> quotes. Without quotes the browser sees this as: <code>class="wrapper" header-wrapper=""</code>.</p>
<p>To know when you can and when you can’t use quotes then have a tinker with Mathias’ <a href="http://mothereff.in/unquoted-attributes"><cite>Mothereffing unquoted attribute value validator</cite></a>.</p>
<p>There are instances where you <em>could</em> use unquoted attributes but I choose not to. It’s hard to summarise this in a quick rule so I’ll give an example:</p>
<pre><code>&lt;input type=submit class=btn value=Login&gt;</code></pre>
<p>This is perfectly valid usage of unquoted attributes, however, imagine the client calls up the agency and (very rightly) says <q>Hey, the word <i>Login</i> needs to be <i>Log in</i>, can we change that please?</q> The project manager knows the designer is totally flat out busy and doesn&#8217;t have the time for smaller amends at the moment. Because project managers are awesome lovely people (right? Right?!), they decide that they can make this simple change themselves to save the designer a job. They open up the relevant file, see <code>value=Login</code> and simply change it to <code>value=Log in</code>, assuming that’s all there is to it. Now, the PM is likely not a technical person so they won’t necessarily know that this will now need quoting; the designer would have.</p>
<p>So, anywhere where the content of the attribute is subject to arbitrary change, I like to quote the attributes as a backup. Also, any time an attribute is populated dynamically (for example, through a CMS) it is best to quote it just in case; if you aren’t manually and consciously altering the attribute, play it safe and pop some quotes round it&#8230;</p>
<p>Now, I know what you’re thinking: <q>If you sometimes have to use quotes then why not always use quotes? It’s more consistent.</q> Well, you’re half right. It is more consistent on the whole, but by introducing rules I make my own consistency; if you can get away with not using quotes, then do so.</p>
<h3>No self closing tags</h3>
<p>With HTML5 we can write things like <code>&lt;hr /&gt;</code> as <code>&lt;hr&gt;</code>, <code>&lt;img /&gt;</code> as <code>&lt;img&gt;</code> and so on. I choose to omit the <code>/&gt;</code>, so in my HTML you’ll see things like:</p>
<pre><code>&lt;meta name=viewport content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"&gt;
&lt;link rel=stylesheet href=css/style.css&gt;</code></pre>
<p>Unquoted attributes where I can, and no self closing tags.</p>
<h3>Optional closing tags</h3>
<p>In HTML5 (or non-XHTML syntax) you can omit actual, full closing tags from <a href="http://meiert.com/en/blog/20080601/optional-tags-in-html-4/">certain elements</a>! This means that the following is totally valid:</p>
<pre><code>&lt;ul&gt;
    &lt;li&gt;Lorem
    &lt;li&gt;Ipsum
    &lt;li&gt;Dolor
    &lt;li&gt;Sit
    &lt;li&gt;Amet
&lt;/ul&gt;</code></pre>
<p>I <em>don’t</em> write my HTML like this as I’m just not too keen on the look of it&#8230; If you want to though, you certainly can.</p>
<h3>Whitespace</h3>
<p>This one is hard to quantify, but I like to use whitespace to loosely reflect the separation of elements that you might see once rendered. I group and space elements with whitespace as you would expect them to be grouped visually in the rendered page, for example:</p>
<pre><code>&lt;dl&gt;

    &lt;dt&gt;Lorem&lt;/dt&gt;
    &lt;dd&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.&lt;/dt&gt;

    &lt;dt&gt;Ipsum&lt;/dt&gt;
    &lt;dd&gt;Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.&lt;/dt&gt;

    &lt;dt&gt;Dolor&lt;/dt&gt;
    &lt;dd&gt;Morbi in sem quis dui placerat ornare. Pellentesque odio nisi euismod in pharetra.&lt;/dt&gt;

&lt;/dl&gt;
&nbsp;
&nbsp;
&lt;div class=promo&gt;

    &lt;p&gt;&lt;strong&gt;Pellentesque habitant morbi tristique&lt;/strong&gt; senectus et netus et malesuada fames ac turpis egestas.&lt;/p&gt;
    &lt;a href=# class=btn&gt;Lorem&lt;/a&gt;

&lt;/div&gt;</code></pre>
<p>A mixture of no, single and double lines of whitespace help to separate elements, or show their visual relationship to one another. For example, the <code>&lt;dt&gt;</code>s and <code>&lt;dd&gt;</code>s belong with each other, but are separate from other groupings.</p>
<h3>Comments on closing tags</h3>
<p>After every major chunk of HTML, for example, the end of a carousel, or the end of the content <code>&lt;div&gt;</code>, I place a closing-comment, for example:</p>
<pre><code>&lt;div class=content&gt;

    ...

    &lt;div class=carousel&gt;
    ...
    &lt;/div&gt;<span class=code-comment>&lt;!-- /carousel --&gt;</span>

    ...

&lt;/div&gt;<span class=code-comment>&lt;!-- /content --&gt;</span></code></pre>
<p>This is certainly not uncommon practice, but because all closing tags look the same as each other (they can’t carry the classes that the opening tags do) it’s often nice to leave a comment so you know what element you’re dealing with.</p>
<h3>Namespaced fragment identifiers</h3>
<p>I came up with <a href="http://csswizardry.com/2011/06/namespacing-fragment-identifiers/">this idea to namespace fragment identifiers</a> last year. It’s basically, I think, a nice way to add a little more meaning to your fragment identifiers and give a little bit more of a clue as to what they actually link to.</p>
<pre><code>&lt;a href=<mark>#section:fragment-identifiers</mark>&gt;Fragment identifiers&lt;/a&gt;

...

&lt;div id=<mark>section:fragment-identifiers</mark>&gt;...&lt;/div&gt;</code></pre>
<hr />
<h2>CSS</h2>
<p>So far I’ve dealt with how I write HTML, but what about CSS? My CSS is a lot less ‘different’, it’s mainly only formatting and syntax rules here.</p>
<h3>No IDs</h3>
<p>This is more a technical thing, but I have <a href="http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/">a blanket-ban on IDs in CSS</a>. There is literally no point in them, and they only ever cause harm. Everything that needs styling is done so without using IDs.</p>
<h3>Table of contents</h3>
<p>At the top of my CSS files I have a table of contents that maps to the section titles in the document, it looks a little like:</p>
<pre><code><span class=code-comment>/*------------------------------------*\
    CONTENTS
\*------------------------------------*/</span>
<span class=code-comment>/*
NOTES
RESET
SHARED     Share anything we can across elements.
MAIN       HTML, BODY, etc.
*/</span></code></pre>
<h3>Section titles</h3>
<p>I denote each section (layout, type, tables etc) of my CSS thus:</p>
<pre><code><span class=code-comment>/*------------------------------------*\
    $MAIN
\*------------------------------------*/</span></code></pre>
<p>This section heading is also prepended with a <code>$</code>. This is so that&mdash;when I do a find for a section&mdash;I actually do a find for <code>$MAIN</code> and not <code>MAIN</code>. This means that I’m only ever searching within section headings. A search for <code>$MAIN</code> will only ever find me a section with that name whereas a search for <code>MAIN</code> could find me something like:</p>
<pre><code>.s{
    background-image:url(/img/css/sprites/<mark>main</mark>.png);
}</code></pre>
<p>Being able to search just in the scope of headings is very, very useful.</p>
<p>I also leave five carriage returns between each section, for example:</p>
<pre><code><span class=code-comment>/*------------------------------------*\
    $MAIN
\*------------------------------------*/</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span class=code-comment>/*------------------------------------*\
    $TYPE
\*------------------------------------*/</span></code></pre>
<p>This means that when scrolling quickly through my stylesheet I know that any gaps in the code are likely to be new sections.</p>
<h3>The shared section</h3>
<p>I wrote about the shared section briefly on Smashing Magazine in my article <a href=http://coding.smashingmagazine.com/2011/08/26/writing-css-for-others/><cite>Writing CSS for others</cite></a>. This is basically a section in a stylesheet where, instead of declaring one rule over and over, we define it once and attach selectors to it, for example:</p>
<pre><code>a,.brand,h1,h2,h3,h4,h5,h6{
    color:#BADA55;
}
h1,h2,h3,h4,h5,h6,
ul,ol,dl,
p,
table,
form,
pre,
hr{
    margin-bottom:24px;
    margin-bottom:1.5rem;
}</code></pre>
<p>Doing this means that things I want to use over and over are only written once, and I can update all instances in one place. It’s kinda like variables in vanilla CSS&#8230;</p>
<h3>Formatting</h3>
<p>I write multiline CSS with a distinct lack of whitespace that most people seem to hate:</p>
<pre><code>.wrapper{
    margin:0 auto;
    max-width:940px;
    padding:10px;
}</code></pre>
<p>No spaces before braces or after colons.</p>
<h3>Vendor prefixes</h3>
<p>I write vendor prefixes so that the values all line up vertically; this means I can scan them quicker (to check they&#8217;re all identical) and I can alter them all in one go if my editor supports typing in columns:</p>
<pre><code>.island{
    padding:1.5em;
    margin-bottom:1.5em;
    -webkit-border-radius:<mark>4px</mark>;
       -moz-border-radius:<mark>4px</mark>;
            border-radius:<mark>4px</mark>;
}</code></pre>
<h3>Indenting rulesets</h3>
<p>One thing I do like to do is indent my rulesets to mirror the nesting of their corresponding HTML. For example, take this carousel HTML:</p>
<pre><code>&lt;div class=carousel&gt;

    &lt;ul class=panes&gt;

        &lt;li class=pane&gt;

            &lt;h2 class=pane-title&gt;Lorem&lt;/h2&gt;

        &lt;/li&gt;<span class=code-comment>&lt;!-- /pane --&gt;</span>

        &lt;li class=pane&gt;

            &lt;h2 class=pane-title&gt;Ipsum&lt;/h2&gt;

        &lt;/li&gt;<span class=code-comment>&lt;!-- /pane --&gt;</span>

        &lt;li class=pane&gt;

            &lt;h2 class=pane-title&gt;Dolor&lt;/h2&gt;

        &lt;/li&gt;<span class=code-comment>&lt;!-- /pane --&gt;</span>

    &lt;/ul&gt;<span class=code-comment>&lt;!-- /panes --&gt;</span>

&lt;/div&gt;<span class=code-comment>&lt;!-- /carousel --&gt;</span></code></pre>
<p>My CSS for this would be formatted:</p>
<pre><code><span class=code-comment>/*------------------------------------*\
    $CAROUSEL
\*------------------------------------*/</span>
.carousel{
    [styles]
}

    .panes{
        [styles]
    }

        .pane{
            [styles]
        }

            .pane-title{
                [styles]
            }</code></pre>
<p>By doing this, I can see from the CSS roughly how the HTML should look; I don’t need the HTML in front of me in order to work out what lives in what.</p>
<h3>HTML in CSS</h3>
<p>In situations where it <em>would</em> be useful for a developer to know exactly how a chunk of CSS applies to some HTML, I often include a snippet of HTML in a CSS comment, for example:</p>
<pre><code><span class=code-comment>/*------------------------------------*\
    $TOOLTIPS
\*------------------------------------*/</span>
<span class=code-comment>/*
&lt;small class=tooltip&gt;&lt;span&gt;Lorem ipsum dolor&lt;/span&gt;&lt;/small&gt;
*/</span>
.tooltip{
    [styles]
}
    .tooltip &gt; span{
        [styles]
    }</code></pre>
<hr />
<h2>Final word</h2>
<p>For a loose example of the above, poke through <a href=https://github.com/csswizardry/vanilla><cite>vanilla</cite></a> or the <a href=http://hry.rbrts.me>hry.rbrts.me</a> source <a href=https://github.com/csswizardry/hry.rbrts.me>on GitHub</a>.</p>
<p>Just to reiterate, this is my coding <em>style</em>; I’m not making suggestions or laying down rules here. If you like anything then feel free to adopt it yourself, if you hate it then that’s cool (just hope you don’t inherit one of my projects!)</p>
<p>I’d really love if people wrote up and shared their own; there are loads of different ways of writing code and I’d be really interested to see what other people do. There’s a really good opportunity for learning some really neat tips!</p>
<p>If you do write your own, please tweet it at me <strong>with the hashtag <a href="https://twitter.com/#!/search/realtime/%23codestyle">#codestyle</a></strong>, that way everyone can easily keep track of any posts.</p>
<p><strong>Unquoted attributes, no self-closing tags, loads of whitespace, weird CSS indenting and a lot of comments; what&#8217;s yours?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2012/04/my-html-css-coding-style/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<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>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 #111; <span class=code-comment>/* Half of our magic number and same colours as our nav's background. */</span>
	border-bottom-color:transparent;
}</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>5</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>15</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>18</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>Ordered and numbered lists; the differences</title>
		<link>http://csswizardry.com/2011/09/ordered-and-numbered-lists-the-differences/</link>
		<comments>http://csswizardry.com/2011/09/ordered-and-numbered-lists-the-differences/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 16:40:36 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=3191</guid>
		<description><![CDATA[This is a really small blog post about ordered lists and numbered lists and their subtle differences.
Have you ever wanted to say something like &#8216;There are three things to look out for:&#8217; and then follow with a numbered list with the three things in?
I&#8217;m pretty sure we all have, and that we&#8217;d all normally use [...]]]></description>
			<content:encoded><![CDATA[<p>This is a really small blog post about ordered lists and numbered lists and their subtle differences.</p>
<p>Have you ever wanted to say something like &#8216;There are three things to look out for:&#8217; and then follow with a numbered list with the three things in?</p>
<p>I&#8217;m pretty sure we all have, and that we&#8217;d all normally use an <code>&lt;ol&gt;</code> to get the numbers, right? That&#8217;s how you get numbers next to list items after all&#8230;</p>
<p>Well the problem here is that the numbering defines an amount, not an order. The order is <em>usually</em> irrelevant in this scenario.</p>
<p>To make more sense I&#8217;ve drawn up <a href="http://jsfiddle.net/csswizardry/sdrth/">a small fiddle of examples</a> and the reasoning in each.</p>
<p>Here we can see that, although we want numbers, we don&#8217;t always want order.</p>
<p>The trick I&#8217;ve started employing is is to have a <code>.numbered</code> class which I can apply to a <code>&lt;ul&gt;</code> to make it mimic the appearance of an ordered list, without semantically carrying the ordered weight. This is how I do it:</p>
<pre><code>ul,
ol{
  margin-bottom:1.5em;
}
li ul,
li ol{
  margin-bottom:0;
}
ul{
  list-style:square outside;
}
ol,
<mark>.numbered</mark>{
  list-style:decimal outside;
}</code></pre>
<p>There. As simple as that. These are pretty much my default list styles now, and all I&#8217;m really doing is making an unordered list with a class of <i>numbered</i> look the same as an <code>&lt;ol&gt;</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/09/ordered-and-numbered-lists-the-differences/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

