<?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>Jeepstone &#187; ordered list</title>
	<atom:link href="http://www.jeepstone.co.uk/tag/ordered-list/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeepstone.co.uk</link>
	<description>The home of Pete Jones</description>
	<lastBuildDate>Wed, 17 Aug 2011 15:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>CSS Nested Ordered Lists</title>
		<link>http://www.jeepstone.co.uk/2008/12/10/css-nested-ordered-lists/</link>
		<comments>http://www.jeepstone.co.uk/2008/12/10/css-nested-ordered-lists/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 14:31:05 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[nested]]></category>
		<category><![CDATA[ordered list]]></category>

		<guid isPermaLink="false">http://www.jeepstone.co.uk/?p=28</guid>
		<description><![CDATA[It seems very silly that with all of the power of CSS and the push for semantic HTML, that the ordered list in HTML has fairly basic functionality, or rather, it&#8217;s missing something that is useful on most websites that are built these days. Let&#8217;s take our standard Terms and Conditions. Normally this is broken [...]]]></description>
			<content:encoded><![CDATA[<p>It seems very silly that with all of the power of CSS and the push for semantic HTML, that the ordered list in HTML has fairly basic functionality, or rather, it&#8217;s missing something that is useful on most websites that are built these days.<span id="more-28"></span></p>
<p>Let&#8217;s take our standard Terms and Conditions. Normally this is broken down, contract-style, into Section 1 then Sub Section 1.4 etc. Now in HTML we represent this as:<code><br />
&lt;ol&gt;<br />
&lt;li&gt;Why are HTML Ordered lists rubbish?<br />
&lt;ol&gt;<br />
&lt;li&gt;Bad HTML<br />
&lt;ol&gt;<br />
&lt;li&gt;This could be badly nested HTML&lt;/li&gt;<br />
&lt;li&gt;or have other problems such as<br />
&lt;ol&gt;<br />
&lt;li&gt;poorly typed&lt;/li&gt;<br />
&lt;li&gt;cake in the keyboard&lt;/li&gt;<br />
&lt;li&gt;developer is drunk&lt;/li&gt;<br />
&lt;/ol&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt;or maybe even just tiredness&lt;/li&gt;<br />
&lt;/ol&gt;<br />
&lt;/li&gt;<br />
&lt;/ol&gt;<br />
&lt;/li&gt;<br />
&lt;/ol&gt;</code></p>
<p>This is nice and proper HTML but the numerals are just single figures rather than being 1.3.2.</p>
<h2>CSS 2.1 to the rescue</h2>
<p>Thankfully there is a solution (for some browsers) in the form of CSS 2.1. In CSS 2.1, you can define <a href="http://www.w3.org/TR/CSS21/generate.html">counters</a>. These allow us to store the current level and populate it as we loop through the nested lists. With a bit of jiggery pokery, we can then output the number before the list item.</p>
<p><code><br />
ol {<br />
counter-reset: item;<br />
}<br />
ol li:before {<br />
content: counters(item, ".") ". ";<br />
counter-increment: item;<br />
}<br />
</code></p>
<p>Now when you render this in Firefox/Safari you get nicely numbered list items.</p>
<h2>Drawbacks</h2>
<p>There are some drawbacks. It appears that IE (how did we know that was coming?) breaks at the statement. This means that anything appearing after it will not work, so put it at the end of your stylesheet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeepstone.co.uk/2008/12/10/css-nested-ordered-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

