<?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; Semantics</title>
	<atom:link href="http://csswizardry.com/tag/semantics/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>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>
		<item>
		<title>More logo markup tips</title>
		<link>http://csswizardry.com/2011/08/more-logo-markup-tips/</link>
		<comments>http://csswizardry.com/2011/08/more-logo-markup-tips/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 20:31:49 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Logo]]></category>
		<category><![CDATA[Semantics]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=2988</guid>
		<description><![CDATA[In my previous article we determined that your logo is not a &#60;h1&#62; and is in fact an image (&#60;img /&#62;) in its own right. Now let&#8217;s cover some nice little tips and snippets for making the most of your markup and creating a nicer UX around it.
The techniques I&#8217;m going to cover can be [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous article we determined that <a href="http://csswizardry.com/2010/10/your-logo-is-an-image-not-a-h1/">your logo is not a <code>&lt;h1&gt;</code></a> and is in fact an image (<code>&lt;img /&gt;</code>) in its own right. Now let&#8217;s cover some nice little tips and snippets for making the most of your markup and creating a nicer UX around it.</p>
<p>The techniques I&#8217;m going to cover can be found on my recently launched hub site <a href="http://hry.rbrts.me">hry.rbrts.me</a>, but for the sake of clarity I have <a href="http://jsfiddle.net/csswizardry/h7zrY/">isolated them in a jsFiddle here</a>.</p>
<p>So, if we know a logo needs to be an <code>&lt;img /&gt;</code> that&#8217;s easy enough, but what if we want hover styles on this image? Simple.</p>
<p>We&#8217;ll be wrapping the logo in an <code>&lt;a&gt;</code> so as to link back to the homepage, a common and good practice:</p>
<pre><code>&lt;a href=&quot;/&quot; id=&quot;logo&quot;&gt;
  &lt;img src=&quot;/img/logo.png&quot; alt=&quot;Company logo&quot;&gt;
&lt;/a&gt;</code></pre>
<p>What we can do here is utilise this <code>&lt;a&gt;</code> and apply a sprited background image to it to provide our on/off hover states, thus:</p>
<pre><code>#logo{
  display:block;
  width:100px; /* Width of logo */
  height:100px; /* Height of logo */
  background:url(/img/css/sprite.png);
}</code></pre>
<p>So now we have a background on the <code>&lt;a&gt;</code> surrounding our <code>&lt;img /&gt;</code> that we now need to git rid of.</p>
<p>We could do this by using a simple <code>display:none;</code> or more accessibly using:</p>
<pre><code>#logo img{
  position:absolute;
  left:-9999px;
}</code></pre>
<p>Now we can no longer see the <code>&lt;img /&gt;</code> but we <em>can</em> see the background on the <code>&lt;a&gt;</code> behind it.</p>
<p>Now all we need is to move the sprite on <code>:hover</code>, thus:</p>
<pre><code>#logo:hover{
  background-position:0 -100px;
}</code></pre>
<p>So here we have a semantically sound logo, using (as we should be) an <code>&lt;img /&gt;</code> with the added benefit of being able to use sprites to give the logo hover effects.</p>
<h2>There&#8217;s more&#8230;</h2>
<p>There&#8217;s another little thing I&#8217;ve started doing which I really like. We have an image in the page semantically, but not functionally. Right clicking the logo won&#8217;t yield a <i>view image</i> context menu, instead it&#8217;ll just focus on the <code>&lt;a&gt;</code>.</p>
<p>What I like to do, which is a nice little touch, is to unhide the <code>&lt;img /&gt;</code> (i.e. get rid of the absolute positioning above) and instead just hide it with <code>opacity:0;</code> (or <code>filter:alpha(opacity = 0);</code> for IE). This means that the user can still right click the logo and be interacting with an image, but they still get your nice sprites on hover.</p>
<p>So we have an <code>&lt;a&gt;</code> with a background sprite which contains an invisible image that a user can still interact with; <a href="http://hry.rbrts.me">see it in situ</a> or look at <a href="http://jsfiddle.net/csswizardry/h7zrY/">an isolated case</a>. Try hovering and right clicking&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/08/more-logo-markup-tips/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Namespacing fragment identifiers</title>
		<link>http://csswizardry.com/2011/06/namespacing-fragment-identifiers/</link>
		<comments>http://csswizardry.com/2011/06/namespacing-fragment-identifiers/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 18:28:14 +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=2902</guid>
		<description><![CDATA[I just stumbled upon something amazing. HTML allows colons (:) and periods (.) in ID tokens.
At first I thought this was awesome because, well, how cool is that?! But then I realised that neither of these are any use in CSS:
#foo:bar{ /* Looks for an element with an ID of foo and a pseudo-selector(class/element) of [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled upon something amazing. <a href="http://www.w3.org/TR/html401/types.html#type-name">HTML allows colons (:) and periods (.) in ID tokens.</a></p>
<p>At first I thought this was awesome because, well, how cool is that?! But then I realised that neither of these are any use in CSS:</p>
<pre><code>#foo:bar{ <span class="code-comment">/* Looks for an element with an ID of foo and a pseudo-selector(class/element) of bar */</span> }
#foo.bar{ <span class="code-comment">/* Looks for an element with an ID of foo and a class of bar */</span> }
</code></pre>
<p>So, whilst these are perfectly valid in HTML, <del datetime="2011-06-21T10:09:13+00:00">they&#8217;re useless in CSS</del> <ins datetime="2011-06-21T10:09:13+00:00">they <em>can</em> be <a href="http://csswizardry.com/2011/06/namespacing-fragment-identifiers/#addendum:escaping">styled with CSS</a></ins>. Kinda sucks, huh? But! If we know they&#8217;re okay in HTML and totally pointless in CSS, can we use that to our advantage?</p>
<p>Answer: yes!</p>
<h2>Fragment identifiers</h2>
<p>This is just the fancy name for when you link to an element with an ID on it, e.g. <code>&lt;a href="#content"&gt;Skip to content&lt;/a&gt;</code>.</p>
<p>I regularly use fragment identifiers when writing long articles with certain sections in them. The best and most relevant example I have is <a href="http://coding.smashingmagazine.com/2011/03/14/technical-web-typography-guidelines-and-techniques/">my epic on web type on Smashing Magazine</a>.</p>
<p>Here I have a list of links to sections in the article, but you should notice I prefix each ID (and therefore its corresponding link&#8217;s <code>href</code>) with <code>#tt-</code>. This is so that I know that my sections will (almost definitely) not be picked up by Smashing&#8217;s CSS. If I had a section called <code>#face</code> and, for whatever crazy reason, Vitaly had a huge photo of himself with an ID of <code>#face</code> there would have been conflicts.</p>
<p>This was a situation where I needed IDs for <em>no</em> styling whatsoever, but rather to be used as fragment identifiers. And, to circumvent any of these potential hiccups, I namespaced all my fragment identifiers with <code>#tt-</code>, standing for <i>technical type</i>.</p>
<p>Here enters my little discovery&#8230;</p>
<p>If we want an ID that won&#8217;t be styled with CSS because we only want to link to it then we can use a colon or a period in there to:</p>
<ol>
<li>Ensure that CSS <em>cannot</em> touch the element even if it wanted to.</li>
<li>Namespace the fragment identifier to show that it is meant as a link hook and give it some more human-friendly semantics.</li>
</ol>
<h2><a href="http://dl.dropbox.com/u/2629908/sandbox/namespacing/index.html">Demo</a></h2>
<p>I&#8217;ve made <a href="http://dl.dropbox.com/u/2629908/sandbox/namespacing/index.html">a demo page of this</a> to a) prove that it works and b) show you how it works in situ.</p>
<p><a href="http://validator.w3.org/check?verbose=1&amp;uri=http%3A%2F%2Fdl.dropbox.com%2Fu%2F2629908%2Fsandbox%2Fnamespacing%2Findex.html">Run it through the validator</a>, see, it works!</p>
<p>I&#8217;ve also tested it in IE7+, Chrome and Firefox Mac and Win.</p>
<h2>Problems?</h2>
<p>Not that I can think of right away, but bear in mind that these elements cannot be styled via that ID.</p>
<p>For the most part the elements will be styled on an element-level basis (e.g. <code>table{}</code>, <code>pre{}</code> and so on) so styling them explicitly should not be too important.</p>
<p>If you do find you need to style them individually you could:</p>
<ul>
<li>Use a class.</li>
<li>Revert to the tried and tested non-colon-or-period syntax.</li>
</ul>
<h2>A standard</h2>
<p>I&#8217;ve never ever seen this anywhere before but I am already thinking it will be incredibly useful to me and any others who write documentation, articles or anything else with sections.</p>
<p>I propose a (loose) standard whereby you namespace your fragment identifiers with relevant information, so if you&#8217;re linking to a table in a document give the table an ID of <code>#table:sales-figures</code>, a figure showing a technical drawing an ID of <code>#figure:engine-section</code>, a section of an article an ID of <code>#section:intro</code> and so on.</p>
<p>I have created <a href="https://github.com/csswizardry/namespacing-fragment-identifiers/blob/master/spec.html">a GitHub repo with an initial list of potential namespacing values</a> there could be. I encourage and appreciate your contributions!</p>
<p>Any thoughts and feedback on this would be great!</p>
<h2 id="addendum:escaping"><ins datetime="2011-06-21T08:45:00+00:00">Addendum</ins></h2>
<p>Ben &#8216;<a href="https://twitter.com/#!/cowboy">Cowboy</a>&#8216; Alman <a href="http://csswizardry.com/2011/06/namespacing-fragment-identifiers/#comment-61782">points out</a> that <a href="http://jsfiddle.net/csswizardry/ZYhhS/">escaping the colon will allow you to style the ID via CSS, as will escaping the period</a>:</p>
<pre><code>#foo\:bar{ <span class="code-comment">/* Works! */</span> }
#foo\.bar{ <span class="code-comment">/* Works! */</span> }
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/06/namespacing-fragment-identifiers/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Annotated &lt;figure&gt;s in HTML5 and CSS</title>
		<link>http://csswizardry.com/2011/06/annotated-figures-in-html5-and-css/</link>
		<comments>http://csswizardry.com/2011/06/annotated-figures-in-html5-and-css/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 18:57:01 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=2790</guid>
		<description><![CDATA[I&#8217;ve never really been one for CSS experiments. They&#8217;re cool and all, but I prefer solving real problems with good ol&#8217; CSS and markup. This is what this next thing was born from and I&#8217;m really pleased with the outcome! It&#8217;s image maps, meet annotations, meet HTML5&#8217;s &#60;figure&#62; element.
Basically, we all know HTML5 has given [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve never really been one for CSS experiments. They&#8217;re cool and all, but I prefer solving real problems with good ol&#8217; CSS and markup. This is what this next thing was born from and I&#8217;m really pleased with the outcome! It&#8217;s <a href="http://dl.dropbox.com/u/2629908/sandbox/annotations/index.html">image maps, meet annotations, meet HTML5&#8217;s <code>&lt;figure&gt;</code> element</a>.</p>
<p>Basically, we all know HTML5 has given us some pretty awesome new elements to toy with and some of the more humble ones are <code>&lt;figure&gt;</code> and <code>&lt;figcaption&gt;</code>:</p>
<pre><code>&lt;figure&gt;
  &lt;img src=&quot;/img.jpg&quot; alt=&quot;&quot; /&gt;
  &lt;figcaption&gt;Caption for above image&lt;/figcaption&gt;
&lt;/figure&gt;</code></pre>
<p>In this post I&#8217;ll show you how to turn that into <a href="http://dl.dropbox.com/u/2629908/sandbox/annotations/index.html">an image-map style annotated image</a> using really really semantic markup.</p>
<hr />
<h2><a href="http://dl.dropbox.com/u/2629908/sandbox/annotations/index.html">Demo</a></h2>
<p>You&#8217;re probably familiar with Flickr&#8217;s notes which are shown upon hovering an image. Well functionally this is exactly like that (I&#8217;ve never actually looked at their markup but I imagine it&#8217;s nigh on identical). Where this differs is that it uses some super-rich and semantic markup and it can be used as a CSS plugin! Simply paste the CSS into your site&#8217;s stylesheet and start using HTML5 <code>&lt;figure&gt;</code> annotations.</p>
<h2>The code</h2>
<p>This technique is a really good example of layers of code. Perfect HTML that works absolutely great on its own, totally semantic and well structured. It doesn&#8217;t need the CSS at all to function, the CSS just enhances it.</p>
<h3>The HTML</h3>
<p>The HTML is lovely and simple. Before we go any further <a href="http://dl.dropbox.com/u/2629908/sandbox/annotations/index.html">go back to the demo page</a> and disable styles. Seeing this without styles <em>should</em> show you just how semantic and sensible the markup really is. It&#8217;s a perfect HTML layer that doesn&#8217;t even <em>need</em> CSS to make sense or work.</p>
<p>I&#8217;ve not included the whole page as all we really want to look at is this:</p>
<pre><code>&lt;figure class=&quot;annotated&quot;&gt;

  &lt;img src=&quot;img/photo.jpg&quot; alt=&quot;Photograph of me on my bike&quot; /&gt;

  &lt;figcaption&gt;

    &lt;b&gt;Things to note:&lt;/b&gt;

    &lt;ul&gt;
      &lt;!-- Positions of the list-items. These need defining inline. --&gt;
      &lt;li style=&quot;top:255px; left:150px;&quot;&gt;Helmet.&lt;/li&gt;
      &lt;li style=&quot;top:420px; left:140px;&quot;&gt;Ruptured ligaments in my ankle.&lt;/li&gt;
      &lt;li style=&quot;top:480px; left:130px;&quot;&gt;Low pressures.&lt;/li&gt;
      &lt;li style=&quot;top:390px; left:325px;&quot;&gt;The trailer I just jumped from.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;i&gt;&lt;a href=&quot;http://www.flickr.com/photos/suzannahaworth/4707464578/&quot;&gt;Photo&lt;/a&gt; by &lt;a href=&quot;http://twitter.com/suzehaworth&quot;&gt;@suzehaworth&lt;/a&gt;.&lt;/i&gt;

  &lt;/figcaption&gt;

&lt;/figure&gt;</code></pre>
<p>All we have here is a <code>&lt;figure&gt;</code> and <code>&lt;figcaption&gt;</code> with an image, a title and a list. The image is the subject of our figure and the list makes points about it. To associate these points with the image we simply have a <code>&lt;b&gt;</code> which we use to textually make the connection.</p>
<h3>The CSS</h3>
<pre><code><span class="code-comment">/*------------------------------------*\
  ANNOTATIONS
\*------------------------------------*/</span>
<span class="code-comment">/*
Apply a class of annotated to any figure you would like, well, annotated!
*/</span>
.annotated{
  position:relative;
  <span class="code-comment">/*display:inline-block; If you do not need to support IE7 and below uncomment this line and remove the inline width and height styles on the &lt;figure&gt; in your markup. */</span>
}
.annotated img{ <span class="code-comment">/* Set this to stop white-space appearing under the image. */</span>
  display:block;
}
.annotated b{ <span class="code-comment">/* Hide the figcaption's title. */</span>
  position:absolute;
  left:-99999px;
}
.annotated ul{ <span class="code-comment">/* Set up the canvas for the annotations to sit on. */</span>
  list-style:none;
  position:absolute;
  top:0;
  right:0;
  bottom:0;
  left:0;
}
.annotated li{
  display:block;
  padding:0 5px;
  <span class="code-comment">/* Give them a width and a line-height suitable for your kind of images. I chose 50px. */</span>
  width:40px; <span class="code-comment">/* 40px + 5px padding-right  + 5px padding-left = 50px */</span>
  line-height:50px;
  position:absolute;
  text-indent:-99999px; <span class="code-comment">/* Hide the text off-screen. */</span>
  white-space:nowrap; <span class="code-comment">/* Stop the annotations breaking onto several lines. */</span>
  cursor:default;
}
.annotated:hover li{ <span class="code-comment">/* When we hover the figure show us where the annotations are. */</span>
  border:1px solid #fff;
}
.annotated li:hover { <span class="code-comment">/* Show the text on hover. */</span>
  background:#fff;
  background:rgba(255,255,255,0.75);
  z-index:2; <span class="code-comment">/* Bring current annotation above others. */</span>
  <span class="code-comment">/* Remove the width and text-indent to show us our text! */</span>
  width:auto;
  text-indent:0;

  <span class="code-comment">/* A bit o' progressive enhancement */</span>
  -moz-box-shadow:0 0 5px rgba(0,0,0,0.25);
  -webkit-box-shadow:0 0 5px rgba(0,0,0,0.25);
  box-shadow:0 0 5px rgba(0,0,0,0.25);
}</code></pre>
<p>The CSS is fairly well commented but basically what we do is:</p>
<ul>
<li>Hide the <code>&lt;b&gt;</code> title.</li>
<li>Absolutely position and stretch the <code>&lt;ul&gt;</code> over the image.</li>
<li>Give the <code>&lt;li&gt;</code>s a width and (line-)height and hide the text off-screen.</li>
<li>Add borders to the list items when we hover the <code>&lt;figure&gt;</code>.</li>
<li>Remove the width from and give a border to the <code>&lt;li&gt;</code>s on hover, and reveal the text.</li>
</ul>
<h3>A couple of things to note</h3>
<p>Firstly, the list items need positioning with inline styles in the markup. This is far more pragmatic than giving each <code>&lt;li&gt;</code> an ID and doing each one through an external CSS file.</p>
<p>Secondly, and more in depth, <i>how do we get the the <code>&lt;figure&gt;</code> to wrap around and hug the image?</i> We have four options.</p>
<ul style="list-style:lower-roman outside;">
<li>Leave it as-is, like I have here. This means that if you hover to the right of the image you are technically still inside the (block-level) <code>&lt;figure&gt;</code> and this will display the list item borders when your cursor isn&#8217;t actually over the image. This isn&#8217;t too bad, but a little unexpected&#8230;</li>
<li>Float the <code>&lt;figure&gt;</code> left, which will force it to hug up to its largest child. The problem here is that you would have to <code>clear:both;</code> the subsequent element.</li>
<li>Give the <code>&lt;figure&gt;</code> <code>display:inline-block;</code>, but this won&#8217;t work in IE7 and below.</li>
<li>The final and, in my opinion, most pragmatic solution would be to simply add an inline width and height to the <code>&lt;figure&gt;</code> which is identical to the dimensions of your image, thus: <code>&lt;figure style=&quot;width:427px;height:640px;&quot;&gt;</code>.</li>
</ul>
<p>Decide which of those will suit your project best and put it to work. Simply pasting the CSS into your stylesheet and obeying the markup structure will allow you to annotate your figures in a much nicer fashion.</p>
<p>I have just put <a href="https://github.com/csswizardry/annotate">this on GitHub</a> in a CSS plugin type fashion. Please feel free to download and poke through the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/06/annotated-figures-in-html5-and-css/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Coding up a semantic, lean timeline</title>
		<link>http://csswizardry.com/2011/03/coding-up-a-semantic-lean-timeline/</link>
		<comments>http://csswizardry.com/2011/03/coding-up-a-semantic-lean-timeline/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 18:54:26 +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=2624</guid>
		<description><![CDATA[I absolutely love coding up the more semantic aspects of a build. Usually forms and tables, it&#8217;s these massively semantic (read; lots of elements with very specific jobs) that I really love coming up against. They&#8217;re not all that challenging, but they&#8217;re very fun (to me at least&#8212;is that sad?!)
After Séan shared the Financial Times&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>I absolutely love coding up the more semantic aspects of a build. Usually forms and tables, it&#8217;s these massively semantic (read; lots of elements with very specific jobs) that I really love coming up against. They&#8217;re not all that challenging, but they&#8217;re very fun (to me at least&mdash;is that sad?!)</p>
<p>After <a href="http://twitter.com/walshybhoy">Séan</a> shared <a href="http://aboutus.ft.com/corporate-information/history/">the Financial Times&#8217; timeline</a> I got to wondering how I&#8217;d code my own (albeit massively more simple) timeline.</p>
<p>This is what I came up with: <a href="http://dl.dropbox.com/u/2629908/timeline/index.html">HTML/CSS timeline</a>.</p>
<h2>The markup</h2>
<p>The markup is amazingly simple. Semantically I used an <code>&lt;ol&gt;</code>. This was quite an obvious choice as this is an ordered list of events. I used one <code>id=&quot;&quot;</code> and some supporting <code>datetime</code> attributes where known <ins datetime="2011-03-16T14:24:44+00:00">(some exact dates are unknown, therefore not included (hopefully you&#8217;ll know your exact dates!))</ins>, and then that&#8217;s it:</p>
<pre><code>&lt;ol id=&quot;timeline&quot;&gt;

  &lt;li&gt;
    &lt;time datetime=&quot;1990-07-04&quot;&gt;July 1990&lt;/time&gt;
    &lt;p&gt;Born&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time&gt;September 1994&lt;/time&gt;
    &lt;p&gt;Started first school&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time&gt;September 1999&lt;/time&gt;
    &lt;p&gt;Started middle school&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time&gt;September 2003&lt;/time&gt;
    &lt;p&gt;Started high school&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time&gt;September 2006&lt;/time&gt;
    &lt;p&gt;Started 6th Form&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time datetime=&quot;2007-11-19&quot;&gt;November 2007&lt;/time&gt;
    &lt;p&gt;Registered csswizardry.com&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time datetime=&quot;2008-07-14&quot;&gt;July 2008&lt;/time&gt;
    &lt;p&gt;Joined Sense Internet as Web Developer&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time datetime=&quot;2009-03-16&quot;&gt;March 2009&lt;/time&gt;
    &lt;p&gt;Joined Twitter&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time datetime=&quot;2010-01-11&quot;&gt;January 2010&lt;/time&gt;
    &lt;p&gt;Joined Venturelab as Web Developer&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time&gt;January 2011&lt;/time&gt;
    &lt;p&gt;Became a member of the Smashing Magazine Experts Panel&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;time datetime=&quot;2011-03-21&quot;&gt;March 2011&lt;/time&gt;
    &lt;p&gt;Joined Sky as Senior UI Developer&lt;/p&gt;
  &lt;/li&gt;

&lt;/ol&gt;</code></pre>
<p>I was initially marking the dates up as <code>&lt;b&gt;</code>s but as <a href="http://twitter.com/Renniks/">Mark</a> pointed out <a href="http://twitter.com/Renniks/status/47336115753070592">I could use the new HTML5 <code>&lt;time&gt;</code> element</a>.</p>
<h2>The CSS</h2>
<p>As far as basic styling goes, I won&#8217;t insult your intelligence; I merely set some type styles and background colours on the list items.</p>
<p>The really interesting bits are the odd/even styling, the &#8217;spine&#8217;, the dot and arrow &#8216;images&#8217; and the branches off the centre of the timeline. I put images in quotes because they&#8217;re not actually images at all, they&#8217;re <code>:before</code> and <code>:after</code> pseudo-elements.</p>
<h3>The spine</h3>
<p>The spine running down the timeline is actually an image and is applied as a background using the fantastic <a href="http://dummyimage.com/">Dummy Image</a>:</p>
<pre><code>#timeline{
  <mark>background:url(http://dummyimage.com/1x1/f43059/f43059.gif) top center repeat-y;</mark>
  width:820px;
  padding:50px 0;
  margin:0 auto 50px auto;
  overflow:hidden;
  list-style:none;
  position:relative;
}</code></pre>
<h3>The arrow and dot</h3>
<p>The arrow and dot, as mentioned above, are actually pseudo-elements. Their CSS is:</p>
<pre><code>#timeline:before, <span class="code-comment">/* The dot */</span>
#timeline:after{ <span class="code-comment">/* The arrow */</span>
  content:" ";
  width:10px;
  height:10px;
  display:block;
  background:#f43059;
  position:absolute;
  top:0;
  left:50%;
  margin-left:-5px;

  -moz-border-radius:20px;
  -webkit-border-radius:20px;
  border-radius:20px;
}
#timeline:after{
  margin-left:-7px;
  background:none;
  border:7px solid #f43059;
  border-color:#f43059 transparent transparent transparent;
  width:0;
  height:0;
  top:auto;
  bottom:-7px;

  -moz-border-radius:0;
  -webkit-border-radius:0;
  border-radius:0;
}
</code></pre>
<p>Here we&#8217;ve created two empty pseudo-elements that are shaped like an arrow and a dot and then absolutely position them at the top and bottom of the ordered list. They sit over the top of the spine, giving the illusion of all being connected.</p>
<p>It&#8217;s worth saying that I&#8217;m not actually a fan of <a href="http://jonrohan.me/guide/css/creating-triangles-in-css/">the border-arrow behaviour</a>, but this <em>is</em> an experimental piece.</p>
<h3>The branches</h3>
<p>The branches that span between the list items and the spine are, again, pseudo elements. They are 70px wide and 1px high and have a gradient background which transitions from the colour of the spine to the colour of the list items. The CSS powering those is:</p>
<pre><code>#timeline li:before,
#timeline li:after{
  content:" ";
  width:70px;
  height:1px;
  background:#f43059;
  position:absolute;
  left:100%;
  top:50%;
  background:-moz-linear-gradient(0,#d8d566,#f43059);
  background:-webkit-gradient(linear,left top,right top,from(#d8d566),to(#f43059));
}</code></pre>
<p>So by now we&#8217;ve added start and end points, a spine and branches to our timeline with no extra markup whatsoever. Lean!</p>
<h3>Odd/even styling</h3>
<p>The odd/even styling of each list item is achieved, as you might expect, using <code>nth-of-type()</code> selectors. What we do is move every even list item over the right of the <code>&lt;ol&gt;</code> and move its branch to attach to the spine accordingly:</p>
<pre><code>#timeline li:nth-of-type(even){
  float:right;
  text-align:left;
}
#timeline li:nth-of-type(even):after{ <span class="code-comment">/* Move branches */</span>
  background:-moz-linear-gradient(0,#f43059,#d8d566);
  background:-webkit-gradient(linear,left top,right top,from(#f43059),to(#d8d566));
  left:auto;
  right:100%;
}</code></pre>
<h2>CSS feature detection?</h2>
<p>This next bit I found quite cool, though a little unorthodox. I set the <code>&lt;li&gt;</code>s to have a negative <code>margin-top</code> so that they had a slightly overlapped effect on the timeline, so either side is not below the previous one, rather <em>next to</em> and <em>slightly</em> along-side it.</p>
<p>The problem I had here is that, in browsers that don&#8217;t support <code>nth-of-type()</code> selectors, the list items bunched up, each one slightly covering the previous one.</p>
<p>What I did was use this:</p>
<pre><code>#timeline li:nth-of-type(odd),
#timeline li:nth-of-type(even){
  margin:-10px 0 0 0;
}</code></pre>
<p>Which basically says <i>if the browser supports <code>nth-of-type()</code> selectors then give the list items a negative <code>margin-top</code>.</i></p>
<p>Any browsers that don&#8217;t support <code>nth-of-type()</code> selectors get the previously defined margin value for the list items, set here:</p>
<pre><code>#timeline li{
  position:relative;
  clear:both;
  float:left;
  width:318px;
  padding:10px;
  background:#fef8c4;
  border:1px solid #d8d566;
  text-align:right;
  <mark>margin:0 0 10px 0;</mark>

  -moz-border-radius:2px;
  -webkit-border-radius:2px;
  border-radius:2px;
  -moz-box-shadow:0 1px #fff inset;
  -webkit-box-shadow:0 1px #fff inset;
  box-shadow:0 1px #fff inset;
}</code></pre>
<p>I guess you could call that a small kind of feature detection&#8230;?</p>
<p>However, whatever you call it, it means that IE8 users still get a pretty good experience, a linear, one column timeline with no <code>nth-of-type()</code> styling:</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2011/03/ie8.jpg" alt="Timeline screenshot in IE8" class="full" /></p>
<p>IE7 however doesn&#8217;t support pseudo-elements or <code>nth-of-type()</code> selectors, so they just get a single column list with no branches or dots/arrows but they do get a lonely spine&#8230;</p>
<h2>Final word</h2>
<p>So <a href="http://dl.dropbox.com/u/2629908/timeline/index.html" title="Timeline demo">there we have it</a>, a super lean, semantic and progressively styled timeline in HTML and CSS and one image. No doubt you could make a completely imageless solution, but I&#8217;m personally not one for this &#8216;never use images&#8217; phase that the industry seems to be going through…</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/03/coding-up-a-semantic-lean-timeline/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>HTML(5) and text-level semantics</title>
		<link>http://csswizardry.com/2011/01/html5-and-text-level-semantics/</link>
		<comments>http://csswizardry.com/2011/01/html5-and-text-level-semantics/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 11:22:16 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Semantics]]></category>
		<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=2187</guid>
		<description><![CDATA[As an absolute type nut and militant web standards advocate, one of the most exciting things that HTML5 brings for me is not the new structural elements like &#60;header&#62;, &#60;aside&#62; et al (although they are pretty awesome) but rather the text-level semantics it brings with the addition and redefinition of certain elements.
The best way to [...]]]></description>
			<content:encoded><![CDATA[<p>As an absolute type nut and militant web standards advocate, one of the most exciting things that HTML5 brings for me is not the new structural elements like <code>&lt;header&gt;</code>, <code>&lt;aside&gt;</code> et al (although they <em>are</em> pretty awesome) but rather the text-level semantics it brings with the addition and redefinition of certain elements.</p>
<p>The best way to explain them is probably to take a look at the following excerpt:</p>
<p><span id="more-2187"></span></p>
<hr />
<p>Hi there, I&#8217;m Harry Roberts, I am a web developer at <a href="http://sky.com/">BSkyB</a>. I specialise in web standards, accessibility, <del datetime="2011-01-23T10:07:25+00:00">Ruby,</del> design and build, mobile development, typography and more. I have been in the industry for <s>three</s> four years.</p>
<p><ins datetime="2011-01-23T10:07:25+00:00"><strong>Please note:</strong> I am not a programmer.</ins></p>
<p><img src="http://csswizardry.com/wp-content/uploads/2009/12/harry-roberts.jpg" alt="A photo of me" class="full" /><small><b>Above:</b> A photo of me.</small></p>
<p>I write at my personal blog <a href="/"><cite>CSS Wizardry</cite></a> and tweet at <a href="http://twitter.com/csswizardry">@csswizardry</a>. I love the uppercase <i>R</i> in Helvetica. My motto on web development is <q>&#8216;Always code like you’re working in a team, even when you’re not.&#8217;</q> I absolutely <em>love</em> the web.</p>
<p>I am also an advocate of clearing floats the clean way. Please note the <code>width</code> and <code>overflow</code> properties in the code below:</p>
<pre><code>.wrapper{
  <mark>width:940px;</mark>
  margin:0 auto;
  padding:10px;
  <mark>overflow:hidden;</mark>
}</code></pre>
<hr />
<p>This is, admittedly, a very forced bit of writing, but I had to write in such a way as to properly, and in context, use a large set of semantic text-level elements. These are, in order of appearance:</p>
<ol>
<li><a href="#del-el">The <code>&lt;del&gt;</code> element</a></li>
<li><a href="#s-el">The <code>&lt;s&gt;</code> element</a></li>
<li><a href="#ins-el">The <code>&lt;ins&gt;</code> element</a></li>
<li><a href="#strong-el">The <code>&lt;strong&gt;</code> element</a></li>
<li><a href="#small-el">The <code>&lt;small&gt;</code> element</a></li>
<li><a href="#b-el">The <code>&lt;b&gt;</code> element</a></li>
<li><a href="#cite-el">The <code>&lt;cite&gt;</code> element</a></li>
<li><a href="#i-el">The <code>&lt;i&gt;</code> element</a></li>
<li><a href="#q-el">The <code>&lt;q&gt;</code> element</a></li>
<li><a href="#em-el">The <code>&lt;em&gt;</code> element</a></li>
<li><a href="#code-el">The <code>&lt;code&gt;</code> element</a></li>
<li><a href="#mark-el">The <code>&lt;mark&gt;</code> element</a></li>
</ol>
<hr />
<h2 id="del-el">The <code>&lt;del&gt;</code> element</h2>
<pre><code>...I specialise in web standards, accessibility, <mark>&lt;del datetime=&quot;2011-01-23T10:07:25+00:00&quot;&gt;Ruby,&lt;/del&gt;</mark> design and build, mobile development, typography</code></pre>
<p>The <code>&lt;del&gt;</code> element indicates a removal from a document; this shows that the text inside it has no place in the document. You could actually physically remove the text, but you can&mdash;for the sake of transparency&mdash; leave it in and show that it does not belong. It also has an attribute to show when it was deleted.</p>
<p>In this case, I do not know Ruby and as such it has no place in the text. I used the <code>&lt;del&gt;</code> element to show this.</p>
<h2 id="s-el">The <code>&lt;s&gt;</code> element</h2>
<pre><code>I have been in the industry for <mark>&lt;s&gt;three&lt;/s&gt;</mark> four years.</code></pre>
<p>This element is <em>very</em> similar to the <code>&lt;del&gt;</code> element and their differences are <em>very</em> subtle. Where the <code>&lt;del&gt;</code> shows incorrect information that should not be in the document, the <code>&lt;s&gt;</code> element represents information that is no longer accurate or relevant (e.g. out of date). Here, it used to be true that I had been industry for three years, but that has been replaced by four. The information is not incorrect per se, merely no longer relevant.</p>
<h2 id="ins-el">The <code>&lt;ins&gt;</code> element</h2>
<pre><code><mark>&lt;ins datetime=&quot;2011-01-23T10:07:25+00:00&quot;&gt;&lt;strong&gt;Please note:&lt;/strong&gt; I am not a programmer.&lt;/ins&gt;</mark></code></pre>
<p>The <code>&lt;ins&gt;</code> element represents text that has been inserted into the document after it has been published. Here I am inserting content as a result of the Ruby mistake earlier. Here I am inserting text to explain why the previous text was removed. Note the same attributes as used on the <code>&lt;del&gt;</code> element.</p>
<p>This isn&#8217;t its only use, however. I frequently use the <code>&lt;ins&gt;</code> element in articles to show addenda and updates.</p>
<h2 id="strong-el">The <code>&lt;strong&gt;</code> element</h2>
<pre><code>&lt;ins datetime=&quot;2011-01-23T10:07:25+00:00&quot;&gt;<mark>&lt;strong&gt;Please note:&lt;/strong&gt;</mark> I am not a programmer.&lt;/ins&gt;</code></pre>
<p>We should all be familiar with the <code>&lt;strong&gt;</code> element. It represents strong importance; where the content is more important than its surroundings. Here is is important because I am saying it is important that you know that I am not a programmer as was accidentally stated above.</p>
<h2 id="small-el">The <code>&lt;small&gt;</code> element</h2>
<pre><code><mark>&lt;small&gt;&lt;b&gt;Above:&lt;/b&gt; A photo of me.&lt;/small&gt;</mark></code></pre>
<p>The <code>&lt;small&gt;</code> element has been redefined to represent small print and side comments. Here it is used to describe the picture above it. It&#8217;s usage is, luckily, fairly obvious. Any time you have supporting information for a larger piece, mark it up as a <code>&lt;small&gt;</code>.</p>
<h2 id="b-el">The <code>&lt;b&gt;</code> element</h2>
<pre><code>&lt;small&gt;<mark>&lt;b&gt;Above:&lt;/b&gt;</mark> A photo of me.&lt;/small&gt;</code></pre>
<p>The once loathed <code>&lt;b&gt;</code> element has been redefined in HTML5 to represent any text whose appearance is offset from its surroundings, often by means of bolding. There are occasions when you&#8217;d want bold text but without any extra importance, such as <code>&lt;strong&gt;</code> would add. I also use the <code>&lt;b&gt;</code> element for marking up the origins of quotes, e.g.:</p>
<pre><code>&lt;blockquote&gt;
  &lt;p&gt;&amp;ldquo;
    A lie gets halfway around the world before the truth has a chance to get its pants on.&amp;rdquo;
    <mark>&lt;b&gt;Sir Winston Churchill&lt;/b&gt;</mark>
  &lt;/p&gt;
&lt;/blockquote&gt;</code></pre>
<h2 id="cite-el">The <code>&lt;cite&gt;</code> element</h2>
<pre><code>I write at my personal blog &lt;a href=&quot;/&quot;&gt;<mark>&lt;cite&gt;CSS Wizardry&lt;/cite&gt;</mark>&lt;/a&gt; and</code></pre>
<p>The <code>&lt;cite&gt;</code> element is used to represent a mention of or reference to a body of work, such as a book, an article, a painting and more. It is not, according to the HTML spec, used for marking up the names of sources of quotes (as above, I use the <code>&lt;b&gt;</code> element).</p>
<p>So whenever you reference a name of a film or song or website or sculpture or article, mark it up with the <code>&lt;cite&gt;</code> element.</p>
<h2 id="i-el">The <code>&lt;i&gt;</code> element</h2>
<pre><code>I love the uppercase <mark>&lt;i&gt;R&lt;/i&gt;</mark> in Helvetica.</code></pre>
<p>The newly redefined  <code>&lt;i&gt;</code> element is another slightly confusing one. The usage is any piece of text that may be spoken with a slightly different inflection but bears <strong>no</strong> extra importance. The best way to tell whether you need the <code>&lt;i&gt;</code> element or not is to say it aloud.</p>
<p>Here I&#8217;m marking up a single letter, because if I were to speak that sentence aloud the <i>R</i> <em>would</em> have a slightly different tone applied. The <code>&lt;i&gt;</code> element can also be applied to full words and phrases.</p>
<h2 id="q-el">The <code>&lt;q&gt;</code> element</h2>
<pre><code>My motto on web development is <mark>&lt;q&gt;&amp;lsquo;Always code like you&amp;rsquo;re working in a team, even when you&amp;rsquo;re not.&amp;rsquo;&lt;/q&gt;</mark></code></pre>
<p>The <code>&lt;q&gt;</code> element is simply used to mark up inline quotations; quotes that are in the context of surrounding copy.</p>
<h2 id="em-el">The <code>&lt;em&gt;</code> element</h2>
<pre><code>I absolutely <mark>&lt;em&gt;love&lt;/em&gt;</mark> the web.</code></pre>
<p>Again, the <code>&lt;em&gt;</code> element is one we should all be familiar with. It denotes stressed importance. If you read the example aloud you can see how the <code>&lt;em&gt;</code> element adds inflection on the word <i>love</i> <strong>with importance</strong>.</p>
<h2 id="code-el">The <code>&lt;code&gt;</code> element</h2>
<pre><code>Please note the <mark>&lt;code&gt;width&lt;/code&gt;</mark> and <mark>&lt;code&gt;overflow&lt;/code&gt;</mark> properties in the code below:</code></pre>
<p>The <code>&lt;code&gt;</code> element is very self-explanatory, it simply represents pieces of code.</p>
<p><strong>N.B.</strong> There is a much larger array of elements used to denote code, inputs and outputs too detailed to go into here. Please refer to the HTML spec for these.</p>
<h2 id="mark-el">The <code>&lt;mark&gt;</code> element</h2>
<pre><code>&lt;pre&gt;&lt;code&gt;.wrapper{
  <mark>&lt;mark&gt;width:940px;&lt;/mark&gt;</mark>
  margin:0 auto;
  padding:10px;
  <mark>&lt;mark&gt;overflow:hidden;&lt;/mark&gt;</mark>
}&lt;/code&gt;&lt;/pre&gt;</code></pre>
<p>The <code>&lt;mark&gt;</code> element is a really nice new element introduced in HTML5. Its purpose is simply to highlight. You could highlight each occurrence of a search term in a search-results page <a href="http://html5doctor.com/search/?q=mark">as <cite>HTML5 Doctor</cite> do</a> or&mdash;as I like to do&mdash;highlight specific references to code that is in a larger block. This allows me to give the code context, but also highlight the relevant snippet that I am talking about.</p>
<hr />
<p>So there we have an array of highly semantic and really nifty text-level elements to use in your work; some old, some new, some modified but <em>all</em> useful.</p>
<p>There are more than I&#8217;ve outlined here, I may revisit the blog post and add them, but the ones I&#8217;ve covered are the ones <em>I</em> find most commonly occurring. In the meantime, why not give <a href="http://www.whatwg.org/html/">the HTML spec a quick read</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/01/html5-and-text-level-semantics/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Mark up a semantic, accessible, progressively enhanced, mobile optimised progress bar (bonus: style the numbers in an ordered list!)</title>
		<link>http://csswizardry.com/2010/11/mark-up-a-semantic-accessible-progressively-enhanced-mobile-optimised-progress-bar-bonus-style-the-numbers-in-an-ordered-list/</link>
		<comments>http://csswizardry.com/2010/11/mark-up-a-semantic-accessible-progressively-enhanced-mobile-optimised-progress-bar-bonus-style-the-numbers-in-an-ordered-list/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 18:27:32 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Markup]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Progressive Enhancement]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=1711</guid>
		<description><![CDATA[How about that for an over-the-top title? But it&#8217;s true, that&#8217;s what we&#8217;re going to be doing. It&#8217;s been a while since my last post, unfortunately, so I thought I&#8217;d make up for it with this sizeable offering in which we will learn a lot of really great techniques in order to make something as [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>H</span>ow</span> about that for an over-the-top title? But it&#8217;s true, that&#8217;s what we&#8217;re going to be doing. It&#8217;s been a while since my last post, unfortunately, so I thought I&#8217;d make up for it with this sizeable offering in which we will learn a lot of really great techniques in order to make something as simple as a progress bar. By which I mean a breadcrumb-esque meter of steps, such as you might find on a checkout process; we are making <a href="/demos/progress-bar/">this</a>:</p>
<p><a href="/demos/progress-bar/" style="background:none;"><img src="http://csswizardry.com/wp-content/uploads/2010/11/progress.jpg" alt="Screenshot of the final product." class="full" /></a></p>
<p><span id="more-1711"></span></p>
<p>And in doing so we will cover:</p>
<ul>
<li><a href="#section-design-build">Design and build a semantic, accessible and sensible progress bar.</a></li>
<li><a href="#section-body-id">Utilise the much underused method of styling page-specific elements based on their IDs.</a></li>
<li><a href="#section-numbers">Style the numbers in an ordered list!</a></li>
<li><a href="#section-progressive">Progressively enhance it with some CSS3.</a></li>
<li><a href="#section-mobile">Optimise it for mobile.</a></li>
</ul>
<p class="marginalia"><strong>N.B.</strong> This article isn&#8217;t so much about a progress bar, but more an illustration that best practices and more advanced techniques can be applied to even the most insignificant aspects of a build to create something awesome!</p>
<h2 id="section-design-build">Design and build</h2>
<p>Let us assume the brief is this:</p>
<p>We require a numbered progress bar to indicate user location (past, current and future) during a checkout path on the OurService&trade; website. It must:</p>
<ul>
<li>Be fully accessible.</li>
<li>Provide a section title with supporting information.</li>
<li>Highlight the user&#8217;s current location in the process.</li>
<li>Be navigable.</li>
<li>Work on mobile devices.</li>
</ul>
<p>The design, let&#8217;s assume, is predefined. It looks as above, purely because it has to. The design is not the major focus of this article, the code and techniques are.</p>
<blockquote><p>&#8220;Code what you consume, not what you see.&#8221;</p>
</blockquote>
<h3>Design</h3>
<p>The progress bar shall be a linear, left to right series of linked labels. Current location shall be indicated by a change in colour, progression onto the next step shall be indicated by an arrow.</p>
<h3>Build</h3>
<p class="marginalia">For the purposes of this tutorial we shall assume the current page is the payment page.</p>
<p>One school of though I find invaluable when it comes to sensible and semantic builds is <q>code what you consume, not what you see</q>. This is a very broad generalisation but works for the most part. Code content independently of (and before you consider) coding any styles. Web development basics, but fundamental to web standards and progressive enhancement.</p>
<p>So, what are we consuming? It&#8217;s an ordered list of steps which indicate location in a process.</p>
<p>Okay so first off we know we need an <code>&lt;ol&gt;</code> as this list has fixed and definite order. We also require titles and supporting copy for each item. As the titles and supporting copy require separation from one another we are going to wrap the titles in a <code>&lt;span&gt;</code>; a generic inline container. This leaves us with:</p>
<pre><code>&lt;body id=&quot;payment-page&quot;&gt;

  &lt;ol id=&quot;progress&quot;&gt;

    &lt;li class=&quot;details-step&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;
        &lt;span&gt;Your details&lt;/span&gt;
        Name, email, address.
      &lt;/a&gt;
    &lt;/li&gt;

    &lt;li class=&quot;account-step&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;
        &lt;span&gt;Create account&lt;/span&gt;
        Username and custom URL.
      &lt;/a&gt;
    &lt;/li&gt;

    &lt;li class=&quot;products-step&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;
        &lt;span&gt;Product options&lt;/span&gt;
        Choose your package.
      &lt;/a&gt;
    &lt;/li&gt;

    &lt;li class=&quot;payment-step&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;
        &lt;strong&gt;
          &lt;span&gt;Payment&lt;/span&gt;
          PayPal, or credit card.
        &lt;/strong&gt;
      &lt;/a&gt;
    &lt;/li&gt;

    &lt;li class=&quot;go-step&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;
        &lt;span&gt;Go!&lt;/span&gt;
        Start using OurService&trade;
      &lt;/a&gt;
    &lt;/li&gt;

  &lt;/ol&gt;

&lt;/body&gt;</code></pre>
<p>There are a few things in this code which I&#8217;ve not yet mentioned, one is the ID on the <code>&lt;body&gt;</code>, another being the class on each <code>&lt;li&gt;</code> and the last being the <code>&lt;strong&gt;</code> wrapped around the payment page&#8217;s text. I shall explain these next.</p>
<h4 id="section-body-id"><code>&lt;body&gt;</code> ID and list item classes</h4>
<p>A combination of an ID on the <code>&lt;body&gt;</code> and a class on a list item can allow you to know what the current page is. The CSS <code>#payment-page .payment-step{}</code> will target the payment section of the progress bar when it is on the payment page in the process. Similarly, <code>#go-page .go-step{}</code> will target the go item on the go page. I wrote <a href="http://www.venturelab.co.uk/devblog/2010/06/body-idsmaking-life-easier-for-yourself/">a much more in-depth article</a> on this over at <a href="http://www.venturelab.co.uk/">Venturelab</a>.</p>
<h4>The <code>&lt;strong&gt;</code> around the payment step&#8217;s text</h4>
<p class="marginalia">If you&#8217;re determining current page programatically, one could argue inserting a <code>class=&quot;current&quot;</code> on the relevant item. This is doable, but avoiding such a class name is far nicer.</p>
<p>As stated earlier we are assuming the current page to be the payment page. Now, we can style the current step on any page using CSS, as outlined above, however how would a user with styles disabled be able to tell what the current page is? How can we highlight this for those users?</p>
<p>Well the solution would be to programatically wrap a <code>&lt;strong&gt;</code> around the text on that page, undo the bolding effects with CSS for browsers with styles enabled, and allow people viewing unstyled content to see that the bolded item is the current page. This gives us:</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2010/11/progress-unstyled.jpg" alt="Unstyled progress bar" class="left outdent" /></p>
<p>As you can see, users with styles disabled can clearly see the current link is the bolded one, this makes the progress bar that little bit more  accessible to those who might need it.</p>
<p>So there we have it, the markup that powers the whole thing.</p>
<div class="hr">
<hr /></div>
<h2>Styling</h2>
<p>Now to style this thing up. First off we&#8217;ll look at the very basic CSS, and that alone:</p>
<pre><code><span class="code-comment">/*------------------------------------*\
  MAIN
\*------------------------------------*/</span>
html{
  height:101%;
}
body{
  font-family:Calibri, Arial, Verdana, sans-serif;
  background:#fff;
  color:#88979e;
  width:940px;
  padding:10px;
  margin:0 auto;
}

<span class="code-comment">/*------------------------------------*\
  PROGRESS
\*------------------------------------*/</span>
#progress{
  list-style:none; <span class="code-comment">/* Remove the bullets */</span>
  float:left; <span class="code-comment">/* Make its width equal to the combined width of the items inside it */</span>
  margin-bottom:20px;
}
#progress li{
  float:left; <span class="code-comment">/* Stack them all up left */</span>
  font-size:0.75em; <span class="code-comment">/* Make the entire item smaller */</span>
  font-style:italic; <span class="code-comment">/* Make the entire item italic */</span>
}
#progress a{
  display:block;
  text-decoration:none;
  padding:10px 25px 10px 10px; <span class="code-comment">/* Padding to accomodate background image */</span>
  background:#7b8d77;
  color:#fff;
}
#progress span{
  font-size:1.333em; <span class="code-comment">/* Bring the size of the title only back up */</span>
  font-weight:bold;
  display:block;
  font-style:normal; <span class="code-comment">/* Undo the italics */</span>
}
#progress strong{
  font-weight:normal; <span class="code-comment">/* Remove the bolding for CSS enabled browsers */</span>
}
#progress a:hover{
  text-decoration:none;
}
#progress a:hover span{
  text-decoration:underline; <span class="code-comment">/* Underline the title on hover */</span>
}
#details-page .details-step a,
#account-page .account-step a,
#products-page .products-step a,
#payment-page .payment-step a{
  background:url(../img/css/splitter.gif) right center no-repeat #a49d4d; <span class="code-comment">/* Arrow image on the current step */</span>
}
#go-page .go-step a{
  background:#a49d4d; <span class="code-comment">/* Arrow image not needed on final step, colour only */</span>
}</code></pre>
<p>All of the above is very obvious, it is essentially just like creating a normal navigational menu, and gives us this:</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2010/11/progress-basic.jpg" alt="Basic progress bar" class="full" /></p>
<h2 id="section-numbers">Styling numbers in ordered lists</h2>
<p>Next up we style the numbers in the ordered list by using the very very useful and much unknown CSS counter module. Because you have such limited control over the appearance of your bullets in (ordered) lists they can be a pain to style. This pain is alleviated somewhat when using an unordered list as you can simply use a background image. It is an altogether different story when you&#8217;re using an ordered list as the bullet needs to change with each list item.</p>
<p>What we do here is use CSS to do a very prog-like job; we get it to loop through each item in a parent container and then increment a user-defined value each time it encounters a specified child. Sounds Greek? <a href="http://www.impressivewebs.com/css-counter-increment/" title="Excellent article on CSS counters">Read this</a>.</p>
<p>Once we have this number available to us we use the CSS <code>:before</code> pseudo-element and the <code>content:;</code> property to insert the number before each item. How cool is that?!</p>
<pre><code><span class="code-comment">/*------------------------------------*\
  PROGRESS
\*------------------------------------*/</span>
#progress{
  list-style:none;
  float:left;
  margin-bottom:20px;
  counter-reset:step; <span class="code-comment">/* Set up name of increment on parent */</span>
}
#progress li{
  float:left;
  font-size:0.75em;
  font-style:italic;
}
#progress a{
  display:block;
  text-decoration:none;
  padding:10px 25px 10px 30px; <span class="code-comment">/* Padding changed to 30px to accomodate number */</span>
  background:#7b8d77;
  color:#fff;
  position:relative; <span class="code-comment">/* Relative position to allow absolute positioning later on */</span>
}
#progress span{
  font-size:1.333em;
  font-weight:bold;
  display:block;
  font-style:normal;
}
#progress strong{
  font-weight:normal
}
#progress a:hover{
  text-decoration:none;
}
#progress a:hover span{
  text-decoration:underline;
}
#progress li a:before{
  counter-increment:step; <span class="code-comment">/* Increment the step on each occurance of this (pesudo) element */</span>
  content:counter(step); <span class="code-comment">/* Write out value of the increment */</span>
  text-align:center;
  font-weight:bold;
  position:absolute; <span class="code-comment">/* Position number */</span>
  top:50%;
  left:5px;
  margin-top:-8px;
}
#details-page .details-step a,
#account-page .account-step a,
#products-page .products-step a,
#payment-page .payment-step a{
  background:url(../img/css/splitter.gif) right center no-repeat #a49d4d;
}
#go-page .go-step a{
  background:#a49d4d;
}</code></pre>
<p>This then gives us this:</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2010/11/no-css3-progress.jpg" alt="Non-CSS3 progress bar" class="full"  /></p>
<div class="hr">
<hr /></div>
<h2 id="section-progressive">Progressively enhancing</h2>
<p>Now for the CSS3 progressive bits:</p>
<pre><code><span class="code-comment">/*------------------------------------*\
  PROGRESS
\*------------------------------------*/</span>
#progress{
  background:#7b8d77; <span class="code-comment">/* Give the ol a background to prevent white showing through behind the items' round corners (change value to #f00 to see what I mean) */</span>
}
#progress{
  -moz-border-radius:5px;<span class="code-comment">/* Round all corners of the progress bar */</span>
  -webkit-border-radius:5px;
  border-radius:5px;
}
#progress a{
  text-shadow:1px 1px 1px rgba(0,0,0,0.25); <span class="code-comment">/* A small text-shadow */</span>
  -moz-border-radius:5px 0 0 5px; <span class="code-comment">/* Round the top- and bottom-left corners */</span>
  -webkit-border-radius:5px 0 0 5px;
  border-radius:5px 0 0 5px;
}
#details-page .details-step a,
#account-page .account-step a,
#products-page .products-step a,
#payment-page .payment-step a{
  background:url(../img/css/splitter.gif) right center no-repeat #a49d4d;
}
#progress .go-step a{
  -moz-border-radius:5px; <span class="code-comment">/* Round all corners of the final step */</span>
  -webkit-border-radius:5px;
  border-radius:5px;
}</code></pre>
<p>The full, combined CSS for the progress bar so far is:</p>
<pre><code><span class="code-comment">/*------------------------------------*\
  MAIN
\*------------------------------------*/</span>
html{
  height:101%;
}
body{
  font-family:Calibri, Arial, Verdana, sans-serif;
  background:#fff;
  color:#88979e;
  width:940px;
  padding:10px;
  margin:0 auto;
}

<span class="code-comment">/*------------------------------------*\
  PROGRESS
\*------------------------------------*/</span>
#progress{
  list-style:none;
  background:#7b8d77;
  float:left;
  margin-bottom:20px;
  counter-reset:step;
  -moz-border-radius:5px;
  -webkit-border-radius:5px;
  border-radius:5px;
}
#progress li{
  float:left;
  font-size:0.75em;
  font-style:italic;
}
#progress a{
  display:block;
  text-decoration:none;
  padding:10px 25px 10px 30px;
  background:#7b8d77;
  color:#fff;
  text-shadow:1px 1px 1px rgba(0,0,0,0.25);
  position:relative;
  -moz-border-radius:5px 0 0 5px;
  -webkit-border-radius:5px 0 0 5px;
  border-radius:5px 0 0 5px;
}
#progress span{
  font-size:1.333em;
  font-weight:bold;
  display:block;
  font-style:normal;
}
#progress strong{
  font-weight:normal
}
#progress a:hover{
  text-decoration:none;
}
#progress a:hover span{
  text-decoration:underline;
}

#progress li a:before{
  counter-increment:step;
  content:counter(step);
  text-align:center;
  font-weight:bold;
  position:absolute;
  top:50%;
  left:5px;
  margin-top:-8px;
  padding:2px 6px;
  background:rgba(0,0,0,0.25);

  -moz-border-radius:20px;
  -webkit-border-radius:20px;
  border-radius:20px;
}
#details-page .details-step a,
#account-page .account-step a,
#products-page .products-step a,
#payment-page .payment-step a{
  background:url(../img/css/splitter.gif) right center no-repeat #a49d4d;
}
#go-page .go-step a{
  background:#a49d4d;
}
#progress .go-step a{
  -moz-border-radius:5px;
  -webkit-border-radius:5px;
  border-radius:5px;
}</code></pre>
<p>Which, when coupled with the markup, gives this:</p>
<p><a href="/demos/progress-bar/" style="background:none;"><img src="http://csswizardry.com/wp-content/uploads/2010/11/progress.jpg" alt="Screenshot of the final product." class="full" /></a></p>
<div class="hr">
<hr /></div>
<h3>Recap</h3>
<p>So, let&#8217;s cover what we&#8217;ve done so far. We&#8217;ve:</p>
<ul>
<li>Coded up a semantic progress bar (using an ordered list and correct generic elements).</li>
<li>Made it accessible (addition of the strong around the content for non-CSS browsers).</li>
<li>Styled it all up.</li>
<li>Made use of <a href="http://www.venturelab.co.uk/devblog/2010/06/body-idsmaking-life-easier-for-yourself/">the body ID trick</a> to mark the current page.</li>
<li>Used CSS counters to style the numbers of an ordered list</li>
<li>Progressively enhanced it all to make it a little easier on the eyes.</li>
</ul>
<h2 id="section-mobile">Mobile optimisation</h2>
<p class="marginalia">For more information on mobile/iPhone optimised sites please see <a href="http://csswizardry.com/2010/01/iphone-css-tips-for-building-iphone-websites/" title="iPhone CSS&mdash;tips for building iPhone websites">my associated article</a>.</p>
<p>Next up we need to optimise this thing for mobile. This couldn&#8217;t be simpler. The key to optimising sites for mobile is linearise. Linearise everything.</p>
<p>In your markup, add this line to the <code>&lt;head&gt;</code> section, thus:</p>
<pre><code>&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
  &lt;title&gt;Progress&lt;/title&gt;
  <strong>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;&quot; /&gt;</strong>
  &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/new-style.css&quot; /&gt;
&lt;/head&gt;</code></pre>
<p>This tells the user agent that the viewport should be the same as the device&#8217;s own screen-size, that it should be initially set to a scale of 1 (i.e. no scale), its maximum scale is set to 1, and that users can&#8217;t scale themselves.</p>
<p>Now, add the following to the very end of your CSS file:</p>
<pre><code><span class="code-comment">/*------------------------------------*\
	MOBILE
\*------------------------------------*/</span>
@media (max-width: 480px){ <span class="code-comment">/* In any browser narrower that 480px... */</span>
body{
	width:auto; <span class="code-comment">/* Give the body a fluid width... */</span>
	padding:5px; <span class="code-comment">/* And a slight padding */</span>
}
#progress{
	width:auto; <span class="code-comment">/* Give the list a fluid width */</span>
	background:none; <span class="code-comment">/* Remove the list's background... */</span>
	float:none; <span class="code-comment">/* ...and float */</span>
}
#progress li{
	float:none; <span class="code-comment">/* Remove list item float, causing them to stack */</span>
	margin-bottom:1px; <span class="code-comment">/* Space them slightly */</span>
}
#progress a{
	margin:0 10px; <span class="code-comment">/* Indent the left and right of each item by 10px */</span>
	-moz-border-radius:5px; <span class="code-comment">/* Round all corners */</span>
	-webkit-border-radius:5px;
	border-radius:5px;
}
#details-page .details-step a,
#account-page .account-step a,
#products-page .products-step a,
#payment-page .payment-step a,
#go-page .go-step a{
	background:#a49d4d; <span class="code-comment">/* Set the background of the current item */</span>
	margin:0 auto; <span class="code-comment">/* Remove the 10px indent to show that the step is current */</span>
}
}</code></pre>
<p>Now, if you want to test this and don&#8217;t have a smartphone, or haven&#8217;t got this hosted in a live environment, simply resize your browser window right down until you see the change. I tend to use the Firefox Web Developer Toolbar addon to <a href="http://csswizardry.com/wp-content/uploads/2010/11/mobile-optimised-progress.jpg">resize the window to 480&#215;800px</a>.</p>
<p>On the iPhone this now looks like:</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2010/11/iphone-progress.jpg" alt="iPhone optimised progress bar" /></p>
<div class="hr">
<hr /></div>
<h2><a href="http://csswizardry.com/demos/progress-bar/">Demo</a></h2>
<p>For the full working demo head to <a href="http://csswizardry.com/demos/progress-bar/">http://csswizardry.com/demos/progress-bar/</a>. For the complete CSS (with reset) please see <a href="http://csswizardry.com/demos/progress-bar/css/style.css">http://csswizardry.com/demos/progress-bar/css/style.css</a>. Also, try using Firebug to change the <code>&lt;body&gt;</code>&#8217;s ID to <code>go-page</code>.</p>
<div class="hr">
<hr /></div>
<h2>Final words</h2>
<p>As I stated previously, this article isn&#8217;t so much about the progress bar itself. What I hope this article has shown is how something as small and trivial as a progress bar has a wealth of little nooks and crannies in which to immerse yourself. Semantics, accessibility, using <code>&lt;body&gt;</code> IDs to style current states without a <code>class=&quot;current&quot;</code>, how to use CSS counters to style the numbers in an ordered list, how to progressively enhance lean markup, and how to optimise things for mobile in a flash.</p>
<p>All of the above skills are easily and quickly transferable. It might be a progress bar today, but what could it be tomorrow? Skills like the ones covered here give you the potential to make something great, out of something very very simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2010/11/mark-up-a-semantic-accessible-progressively-enhanced-mobile-optimised-progress-bar-bonus-style-the-numbers-in-an-ordered-list/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Your logo is an image, not a &lt;h1&gt;</title>
		<link>http://csswizardry.com/2010/10/your-logo-is-an-image-not-a-h1/</link>
		<comments>http://csswizardry.com/2010/10/your-logo-is-an-image-not-a-h1/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 22:12:14 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Logo]]></category>
		<category><![CDATA[Semantics]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=1545</guid>
		<description><![CDATA[Should you mark your logo up as an image or a &#60;h1&#62;? There has been much debate for a long time now as to how to mark up logos. Should your logo be an inline image (&#60;img /&#62;) or a &#60;h1&#62; with a background style&#8212;using one of many means of image replacement&#8212;to apply the logo [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>S</span>hould</span> you mark your logo up as an image or a <code>&lt;h1&gt;</code>? There has been much debate for a long time now as to how to mark up logos. Should your logo be an inline image (<code>&lt;img /&gt;</code>) or a <code>&lt;h1&gt;</code> with a background style&mdash;using one of <a href="http://www.mezzoblue.com/tests/revised-image-replacement/">many means of image replacement</a>&mdash;to apply the logo to that? This debate has been raging for goodness knows how long, but I&#8217;m going to try and explain in this article why you should mark up logos as inline images, and why that&#8217;s the most sensible option.</p>
<p><span id="more-1545"></span></p>
<h2>A brief example of each</h2>
<p>Using an image:</p>
<pre><code>&lt;a href=&quot;/&quot; title=&quot;Return to the homepage&quot; id=&quot;logo&quot;&gt;
  &lt;img src=&quot;/images/logo.gif&quot; alt=&quot;Nike logo&quot; /&gt;
&lt;/a&gt;</code></pre>
<p>Using a <code>&lt;h1&gt;</code>:</p>
<pre><code>&lt;h1&gt;&lt;a href=&quot;/&quot; title=&quot;Return to the homepage&quot;&gt;Nike&lt;/a&gt;&lt;/h1&gt;

h1 a{
  width:;
  height:;
  display:block;
  text-indent:-9999px;
  background:url(/images/logo.gif);
}</code></pre>
<h2>Your logo is content</h2>
<p>Your logo is content, not style. Style vs. content, in the web standards sense of the term, pertains to information and content that is required to be present/accessible irrespective of the presence of styles (in other words, CSS).</p>
<p>A logo is content. Let&#8217;s use Nike as an example throughout. Regardless of whether Nike&#8217;s site is blue, red or green, their logo will always be &#8216;that&#8217; swoosh. The logo is totally independent of the site&#8217;s surrounding styles as the logo is content.</p>
<p>Imagine you were to visit Nike&#8217;s site in a browser that doesn&#8217;t support styles. It only makes sense that that logo is still there. It&#8217;s Nike&#8217;s brand, and it&#8217;ll be their brand whether their site is styled or not.</p>
<p>So your logo is content; it&#8217;s a visual representation of a brand that is defined long before that company&#8217;s site can be brought into consideration. Nike is admittedly a very big brand, but a brand nonetheless. Transport that way of thinking to any build and it&#8217;s becomes pretty obvious that a logo is indeed content.</p>
<h3>Content = markup</h3>
<p>So if a logo is content, a logo is markup, right? Right. You&#8217;d probably want to mark up your logo as follows:</p>
<pre><code>&lt;a href=&quot;/&quot; title=&quot;Return to the homepage&quot; id=&quot;logo&quot;&gt;
  &lt;img src=&quot;/images/logo.gif&quot; alt=&quot;Nike logo&quot; /&gt;
&lt;/a&gt;</code></pre>
<p>As simple as that. Regardless of styles your content&mdash;and therefore logo&mdash;persist. Use the <code>id=&quot;logo&quot;</code> to style anything such as positioning, and that&#8217;s it.</p>
<h2>Your logo isn&#8217;t a <code>&lt;h1&gt;</code></h2>
<p>So we&#8217;ve proved that a logo is content, but let&#8217;s now prove that it <em>isn&#8217;t</em> a <code>&lt;h1&gt;</code>, a commonly held practice for marking up logos.</p>
<blockquote><p>&#8220;To have the &lt;h1&gt; being the logo would be like having your name being a photo. They both represent the same thing, but are separate entities&#8230;&#8221;</p>
</blockquote>
<p>The <code>&lt;h1&gt;</code> element is defined as being the uppermost, all-encompassing title of a page. Now, for a homepage this is something of a grey area. The chances are that your site is the site which the logo represents, i.e. Nike&#8217;s logo appearing on Nike&#8217;s site. On the homepage the <code>&lt;h1&gt;</code> may well be whatever the logo says; it may well be <code>&lt;h1&gt;Nike&lt;/h1&gt;</code>. This is a case where the logo and the <code>&lt;h1&gt;</code> share the same meaning. <em>But</em>, as discussed, the content of the two is different. The logo is still branding, and the <code>&lt;h1&gt;</code> is still a textual element. To have the <code>&lt;h1&gt;</code> being the logo would be like having your name being a photo. They both represent the same thing, but are separate entities in themselves. A coded example might be:</p>
<pre><code>&lt;a href=&quot;/&quot; title=&quot;Return to the homepage&quot; id=&quot;logo&quot;&gt;
  &lt;img src=&quot;/images/logo.gif&quot; alt=&quot;Nike logo&quot; /&gt;
&lt;/a&gt;
...
&lt;h1&gt;Welcome to Nike's international website&lt;/h1&gt;</code></pre>
<p>Sometimes a homepage doesn&#8217;t even require a <code>&lt;h1&gt;</code> to be visible. The logo alone is enough, but your page still needs that <code>&lt;h1&gt;</code> in the markup somewhere. It needs the logo to be an image but also needs a level one heading. Here you might want to have an &#8216;invisible&#8217; <code>&lt;h1&gt;</code> like I have here on CSS Wizardry. This means that semantically you&#8217;re marking up your logo as an image, as it should be, and providing a <code>&lt;h1&gt;</code> to screen-readers.</p>
<h2>What if you don&#8217;t have a logo?</h2>
<p>Some sites, CSS Wizardry included, don&#8217;t have a logo as such. I use a bit of browser text as a logo, but even though this is textual content I do not mark this up as a <code>&lt;h1&gt;</code>. I mark it up using an <code>&lt;em&gt;</code>. This is still a text-module element, and to my mind is semantically sound.</p>
<h2>Problems with using a <code>&lt;h1&gt;</code> to mark up a logo</h2>
<p>Although I did admit that the logo&#8217;s text might also be the title (<code>&lt;h1&gt;</code>) of the homepage, there&#8217;s a very good reason why you should not mark the logo up as one. What about your &#8216;about page&#8217;? The title of that page is undoubtedly &#8216;About me&#8217;, and the <code>&lt;h1&gt;</code> is a page&#8217;s title. It only stands to reason, then, that the page&#8217;s <code>&lt;h1&gt;</code> reads <code>&lt;h1&gt;About me&lt;/h1&gt;</code>.</p>
<p>If however I had marked up my logo as a <code>&lt;h1&gt;</code>, the about page&#8217;s title would also be the same as the homepage, and a <code>&lt;h2&gt;</code> would have to take place as the page&#8217;s actual title. This is wrong; obviously and unarguably wrong. And, by this token, your contact and portfolio and services pages&#8217; titles would all also be the same. This is the problem with marking logos up as <code>&lt;h1&gt;</code>s.</p>
<h2>More practical reasons</h2>
<p>And if you weren&#8217;t convinced enough already, using an inline image will actually make your life easier.</p>
<p>As previously mentioned, using an inline image allows  the logo to persist regardless of styles. This means that print stylesheets will have a logo embedded in the page as an image which they can print. Most printers, to conserve ink, will not print backgrounds, which means that any logos applied by means of a background image will be lost at print. Not great that your branding will be lost as soon as your site is printed, really.</p>
<p>Furthermore, an inline image can have its dimensions altered. A background image on a <code>&lt;h1&gt;</code> can&#8217;t. You can alter the size of the <code>&lt;h1&gt;</code>, but not its background (unless you&#8217;re using some CSS3 background magic). This means that you cannot easily adapt the logo to different sizes through CSS alone; think about optimising for mobile. A useful CSS snippet for any mobile site is:</p>
<pre><code>img{
  width:100%
  max-width:100%;
}</code></pre>
<p>This means that all images will fill, but not break out of, the mobile screen. If your logo is applied as a background image it&#8217;ll get ignored here. What might happen is that your <code>&lt;h1&gt;</code> will render narrower that its background image&#8217;s dimensions (i.e. the background image is wider in pixels than the device&#8217;s screen is) on a mobile device, giving the impression of clipping the logo off. Conversely, the <code>&lt;h1&gt;</code> might not fill the width of the page leaving it, and therefore its logo background, spanning only a percentage of the page.</p>
<p>You can manipulate a logo as an <code>&lt;img /&gt;</code> far easier than you can as a background.</p>
<h2>Stop applying logos as backgrounds</h2>
<p>This really is semantics and web standards basics. A logo is content, not style. Just because your site is named the same as your logo reads does not make them the same thing. A logo should not be applied as backgrounds, and especially not to <code>&lt;h1&gt;</code>s. Some of the industry&#8217;s &#8216;best&#8217; flaunt this lack of standards openly, and it&#8217;s just plain incorrect.</p>
<p>A logo is an image, a <code>&lt;h1&gt;</code> is a title. Your logo is never a background image, it&#8217;s never secondary content to anything. It is content in its own right and should be treated as such. Your logo is an image.</p>
<p>If you take only one thing from this article, let it be that <strong>your logo is content, therefore an image</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2010/10/your-logo-is-an-image-not-a-h1/feed/</wfw:commentRss>
		<slash:comments>104</slash:comments>
		</item>
		<item>
		<title>Semantics and sensibility</title>
		<link>http://csswizardry.com/2010/08/semantics-and-sensibility/</link>
		<comments>http://csswizardry.com/2010/08/semantics-and-sensibility/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 16:34:46 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Markup]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=1309</guid>
		<description><![CDATA[For a while now, sensible naming conventions and semantics have been confused. Things such as class="left" or class="clear" have been deemed insemantic, whereas in reality, semantics really doesn&#8217;t stretch that far… Let me illustrate with some code examples:
Insemantic code
The following code is just plain wrong, it&#8217;s insemantic, using the wrong elements for the wrong job:
&#60;div [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>F</span>or a while</span> now, sensible naming conventions and semantics have been confused. Things such as <code>class="left"</code> or <code>class="clear"</code> have been deemed insemantic, whereas in reality, semantics really doesn&#8217;t stretch that far… Let me illustrate with some code examples:</p>
<h2>Insemantic code</h2>
<p>The following code is just plain wrong, it&#8217;s insemantic, using the wrong elements for the wrong job:</p>
<pre><code>&lt;div class=&quot;nav-link&quot;&gt;&lt;a href=&quot;/&quot;&gt;Home&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;nav-link&quot;&gt;&lt;a href=&quot;/about/&quot;&gt;About&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;page-title&quot;&gt;About&lt;/div&gt;
&lt;div&gt;This is some page text about some stuff...&lt;/div&gt;</code></pre>
<h2>Insensible code</h2>
<p>This code is perfectly semantic, it just uses some silly classes:</p>
<pre><code>&lt;div class=&quot;border&quot;&gt;
  &lt;h2 class=&quot;red&quot;&gt;This is a heading&lt;/h2&gt;
&lt;/div&gt;</code></pre>
<h2>Semantics concerns itself with elements&#8230;</h2>
<p>&#8230;and not the names assigned to them. Using the correct element for the correct job is as far as semantics goes. Standards concerning naming of those elements is all about <em>sensibility</em>.</p>
<p>Semantics sets a standard from which it is very difficult to stray. Headings are marked up with a <code>&lt;h1&ndash;6&gt;</code>, a list with <code>&lt;ul/ol/dl&gt;</code> and so on. You cannot, however, define a convention for naming the IDs and classes of these. <code>&lt;div id=&quot;contact&quot;&gt;</code>, <code>&lt;div id=&quot;kontact&quot;&gt;</code> and <code>&lt;div id=&quot;contact-info&quot;&gt;</code> all bear different names, but are all equally as semantic. All three are examples of semantic <em>and</em> sensible code.</p>
<p>However, take the following examples: <code>&lt;div id=&quot;bottom&quot;&gt;</code>, <code>&lt;div id=&quot;lower-area&quot;&gt;</code> and <code>&lt;div id=&quot;b&quot;&gt;</code>. These examples exhibit semantic code, but with insensible namings.</p>
<h3>Be sensible, for our sake</h3>
<p>Semantics should be adhered no matter what&mdash;web standards are good. Naming however is totally down to you, you can call your elements whatever you wish. <code>&lt;div id=&quot;a&quot;&gt;</code>, <code>&lt;div id=&quot;b&quot;&gt;</code> and <code>&lt;div id=&quot;c&quot;&gt;</code> are all possible, but not sensible.</p>
<blockquote><p>&ldquo;Always code like you&#8217;re working in a team, even when you&#8217;re not.&rdquo;</p>
</blockquote>
<p>I have actually seen markup like this, and the developer&#8217;s reasoning was <q>&#8216;I like to keep my markup as lean as possible, and I know what <code>a</code>, <code>b</code> and <code>c</code> do&#8217;</q>.</p>
<p>While this is all correct, and passable, it&#8217;s not really very sensible. He might know what <code>a</code>, <code>b</code> and <code>c</code> do, but what about the person who inherits the project? For all his justification of code bloat was somewhat advanced (<em>really</em> decreasing markup size), the impression the next guy to see his code will have will be <q>&#8216;WTF was this guy thinking?!&#8217;</q> Always code like you&#8217;re working in a team, even when you&#8217;re not.</p>
<h2>Final word</h2>
<blockquote><p>&ldquo;An ID/class should be as short as possible but as long as necessary.&mdash;<a href="http://meiert.com/en/blog/20090617/maintainability-guide/">Jens Meiert</a></p>
</blockquote>
<p>Semantics and sensibility are not the same. Anyone who tells you that <code>class=&quot;left&quot;</code> is insemantic is wrong. Be semantic and be sensible. Pick names which are descriptive. An ID/class should be as short as possible but as long as necessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2010/08/semantics-and-sensibility/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Building sites without using IDs or classes</title>
		<link>http://csswizardry.com/2010/04/building-sites-without-using-ids-or-classes/</link>
		<comments>http://csswizardry.com/2010/04/building-sites-without-using-ids-or-classes/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 12:17:09 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=1216</guid>
		<description><![CDATA[This morning, for one reason or another, I decided to have a go at coding up a page without using any IDs or classes in my markup, and therefore none in my CSS. I&#8217;m not sure why I tried it, I guess I just did&#8230; In order to make it a fairly painless job I [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>T</span>his</span> morning, for one reason or another, I decided to have a go at coding up a page without using any IDs or classes in my markup, and therefore none in my CSS. I&#8217;m not sure why I tried it, I guess I just did&#8230; In order to make it a fairly painless job I dove straight into the browser and coded up a simple header, footer, two column layout. <a href="/demos/sites-without-ids-classes/">View the demo</a> and be sure to view the source.</p>
<p><span id="more-1216"></span></p>
<p>Using a combination of more advanced selectors such as sibling and <code>nth-of-type</code> you can target elements based on their position in the markup rather than a given name. The practical upshot of this is that your markup is much leaner and cleaner, removing class and ID names has a notable impact.</p>
<h2>Using advanced selectors</h2>
<p class="marginalia">For a complete list please see <a href="http://www.w3.org/TR/css3-selectors/">http://www.w3.org/TR/css3-selectors/</a></p>
<p>The more advanced selectors take information about an element to determine whether it matches a certain criteria, for example <code>body&gt;div</code> will target a <code>div</code> that is a direct and immediate descendant of the <code>body</code>; <code>p+p</code> will target a paragraph immediately preceded by a paragraph.</p>
<p>On this basis, you could select (for example) your main content <code>div</code> by knowing that it&#8217;s the second <code>div</code> in your content wrapper: <code>body&gt;div div:nth-of-type(2)</code>. Broken down we have:</p>
<ul>
<li><code>body</code>&mdash;sets the root</li>
<li><code>&gt;div</code>&mdash;the first <code>div</code> inside the body (the wrapper <code>div</code>)</li>
<li><code>div:nth-of-type(2)</code>&mdash;the second <code>div</code> in the wrapper (just after the header <code>div</code>).</li>
</ul>
<h2>Why I think this won&#8217;t catch on</h2>
<p class="marginalia">For the time being, let&#8217;s completely disregard that Internet Explorer completely disregards these selectors&#8230;</p>
<p>As you can see from the above example, targeting the single, lone, unique content <code>div</code> has taken two advanced selectors and 27 bytes. The selectors are fixed, the content <code>div</code> will always have to be the second <code>div</code> in the <code>div</code> that is an immediate child of the <code>body</code>. This is incredibly restrictive. Surely <code>#content{&hellip;}</code> is far better than <code>body>div div:nth-of-type(2){&hellip;}</code>&hellip;?</p>
<p>For the sake of ease, instead of rambling about pros and cons, I&#8217;ve simply drawn up a list of advantages and disadvantages:</p>
<h3>Advantages:</h3>
<ul>
<li>Leaner markup.</li>
<li>Promotes more sensible structuring of code.</li>
<li>Promotes semantics.</li>
</ul>
<h3>Disadvantages:</h3>
<ul>
<li>Difficult syntaxes to remember.</li>
<li>Extremely restrictive&mdash;elements are styled based on their location meaning that any moving/restructuring means all styles tied to an element are lost. This leads me on to&#8230;</li>
<li>The CSS is no longer just describing style, it also describes structure. CSS is a styling language, not a markup one.</li>
<li>Arbitrary elements such as images and <code>div</code>s that change depending on page content (blog posts for example) aren&#8217;t fixed enough to be styled based on their structure. This means that any variable content will require IDs and classes anyway, so you might as well us them across the board as opposed to a mix of with and without.</li>
<li>Difficult to understand. I wrote <a href="/demos/sites-without-ids-classes/css/style.css">the CSS for the demo page</a> and I&#8217;m having a hard enough time doing the calculations to work out what does what. Imagine inheriting that!</li>
<li>Jenga. As soon as you alter your markup, the structure dependent CSS will come falling down too, what might be the first child might become the second, making the second child the third and so on, creating a domino effect.</li>
</ul>
<h3>Final word</h3>
<p>While the more advanced CSS(3) selectors are impressive, and incredibly powerful, they aren&#8217;t flexible enough to allow any large dependency upon them. That, and they&#8217;re more awkward to understand than the tried and tested ID/class &#8216;hooks&#8217; we know and use. There are far too many downsides to make cleaner markup a big enough plus-side in my opinion&#8230; Oh, and Internet Explorer doesn&#8217;t seem to honour any of them, but that can&#8217;t have come as much of a surprise.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2010/04/building-sites-without-using-ids-or-classes/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
	</channel>
</rss>

