<?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>Sun, 05 Sep 2010 18:05:35 +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>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>7</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>
		<item>
		<title>A reconsideration&#8212;in defence of &lt;b&gt; and &lt;i&gt; (or: people fear what they don&#8217;t understand)</title>
		<link>http://csswizardry.com/2010/01/a-reconsiderationin-defence-of-b-and-i-or-people-fear-what-they-dont-understand/</link>
		<comments>http://csswizardry.com/2010/01/a-reconsiderationin-defence-of-b-and-i-or-people-fear-what-they-dont-understand/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 23:06:10 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Semantics]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=306</guid>
		<description><![CDATA[The other day, I got to thinking about the HTML elements &#60;b&#62; and &#60;i&#62;, and wondered if they were still viably usable in production code. I&#8217;ve personally never used them before but I was aware that they existed and were still very much valid XHTML markup (even in the Strict DOCTYPE!). Wondering whether I&#8217;d avoided [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>T</span>he</span> other day, I got to thinking about the HTML elements <code>&lt;b&gt;</code> and <code>&lt;i&gt;</code>, and wondered if they were still <em>viably</em> usable in production code. I&#8217;ve personally never used them before but I was aware that they existed and were still very much valid XHTML markup (even in the Strict <code>DOCTYPE!</code>). Wondering whether I&#8217;d avoided two elements for three years unnecessarily, I did some digging.</p>
<h2>What the facts state</h2>
<p><code>&lt;b&gt;</code> and <code>&lt;i&gt;</code> <em>are</em> still valid, and as XHTML is just an XML serialisation of HTML, pretty much all the elements apparent in the HTML spec are true of the XHTML spec too&mdash;it is, pretty much, just the way in which these elements are written that makes them different in XHTML.</p>
<h2>Twitter</h2>
<p>With the help of <a href="http://twitter.com/smashingmag" title="Smashing Magazine on Twitter">@smashingmag</a> I turned to <a href="http://twitter.com/csswizardry">Twitter</a> and my knowledgeable followers and asked the question:</p>
<blockquote><p>&ldquo;Using &lt;i&gt; and &lt;b&gt; in (valid) XHTML (strict)… your thoughts on this would be much appreciated. #upcomingBlogPost Cheers all!&rdquo; <strong><a href="http://twitter.com/csswizardry" title="Harry Roberts on Twitter">@csswizardry</a></strong></p>
</blockquote>
<p><span id="more-306"></span></p>
<p>Most of the answers I got said petty much the same thing: use <code>strong</code> and <code>em</code> &#8230; <code>b</code> and <code>i</code> are deprecated. While this is largely true, there are some myths that need dispelling.</p>
<ul>
<li><code>strong</code> and <code>em</code> are <em>not</em> the same as bold and italics. strong is strong emphasis and em is emphasis. <strong>It is purely through convention that these two elements happen to adopt either bold or italicised appearances.</strong></li>
<li><code>b</code> and <code>i</code> are <em>not</em> deprecated in any way in HTML or XHTML. <strong>They are still in existence, still valid and still (in the right places) usable.</strong></li>
</ul>
<h3>Some replies</h3>
<p>A few choice replies I received which are, on the whole, representative of everyone&#8217;s thoughts:</p>
<blockquote><p>&ldquo;strong and em make more sense, especially when taking screen readers into account. <strong><a href="http://twitter.com/CreativeNotice" title="CreativeNotice on Twitter">@CreativeNotice</a></strong></p>
</blockquote>
<p>Or so you&#8217;d think, <a href="#fallacy">see below&#8230;</a></p>
<div class="hr">
<hr /></div>
<blockquote><p>&ldquo;I prefer &lt;strong&gt; &lt;/em&gt; because of semantics . You want to put emphasis, not just make text italic.&rdquo; <strong><a href="http://twitter.com/wehelpdesign" title="WeHelpDesign on Twitter">@WeHelpDesign</a></strong></p>
</blockquote>
<p>True, if you <em>do</em> just want emphasis that is&#8230;</p>
<div class="hr">
<hr /></div>
<blockquote><p>&ldquo;Using &lt;i&gt; and &lt;b&gt; is just fine if it&#8217;s for visual bling without real semantic background.&rdquo; <strong><a href="http://twitter.com/levito" title="Veit Lehmann on Twitter">@levito</a></strong></p>
</blockquote>
<p>Ah, this is more like it!</p>
<div class="hr">
<hr /></div>
<blockquote><p>&ldquo;&lt;b&gt; and &lt;i&gt; tags describe presentation, not structural semantics. Rather style &lt;em&gt; and &lt;strong&gt; tags.&rdquo; <strong><a href="http://twitter.com/hornergraphic" title="Stephen Horner on Twitter">@hornergraphic</a></strong></p>
</blockquote>
<p>A view that is seemingly shared by almost everyone else who responded.</p>
<div class="hr">
<hr /></div>
<h3>What about strong and em?</h3>
<p>The vast majority of people who replied were in favour of <code>strong</code> and <code>em</code> over <code>b</code> and <code>i</code>. Presuming all respondents were assuming the question was &#8216;What are your thoughts on using <code>b</code> and <code>i</code> to represent strong emphasis and emphasis, and thus replace <code>strong</code> and <code>em</code>?&#8217; then they&#8217;d have all been spot on correct. However, <code>b</code> and <code>i</code> and <code>strong</code> and <code>em</code> are  totally separate things. <code>b</code> and <code>i</code> assume no semantic value, meaning literally bold and italic respectively. <code>strong</code> and <code>em</code> however have nothing to do with bold or italics. As previously mentioned, it is through convention only that the default styling for each is so.</p>
<p><code>strong</code> and <code>em</code> are &lsquo;spoken word&rsquo; type elements, where they represent a change in tone only. This means that their styling is in no way linked to their naming, it is just that us, as people, are familiar with italicised prose sounding more stressed&mdash;or emphasised&mdash;than surrounding text. This is where the importance of aforementioned semantics and screenreaders come in. Or is it&#8230;?</p>
<h4 id="fallacy">The screenreader fallacy</h4>
<p class="marginalia">Screenreaders <em>don&#8217;t</em> use <code>strong</code> and <code>em</code>!</p>
<p>The common belief is that <code>strong</code> and <code>em</code>&#8217;s semantic meaning is used by screenreaders to alter tonality when reading content aloud, thus letting the user know that the copy is in fact meant to be understood in a different manner to any neighbouring text. This was something I too believed until the wonderfully knowledgeable <a href="http://twitter.com/pekingspring">@pekingspring</a> pointed me toward <a href="http://www.paciellogroup.com/blog/?p=41" title="An article covering the way screenreaders handle emphasised text">this article</a> by <a href="http://twitter.com/stevefaulkner">@stevefaulkner</a>&mdash;it turns out screenreaders <em>don&#8217;t</em> use <code>strong</code> and <code>em</code> to alter tonality!</p>
<p>This means that screenreaders see no semantic value in the <code>strong</code> and <code>em</code> element. However, they should be used <em>unconditionally</em> where a change in tone is implied, whether a screenreader will understand this or not.</p>
<h3>Where to use &lt;b&gt; and &lt;i&gt; then?</h3>
<p>One of my first thoughts was where to use these elements if indeed they are still usable. My initial idea was the use of <code>i</code> for markup up things that have to be italicised but the italics aren&#8217;t indicative of any tone. To quote the <cite>Penguin Guide to Punctuation</cite>:</p>
<blockquote><p>&ldquo;Another use of italics &#8230; is to cite titles of complete works&#8230;&rdquo;</p>
</blockquote>
<p>Initially I thought this was the ideal use for the <code>i</code> element&mdash;something that had to be in italics, yet implied no tone of voice. It was such a good fit! However, <a href="http://twitter.com/pekingspring">@pekingspring</a> came to my aid again and reminded me that the <code>cite</code> element is for this exact purpose. That was that idea gone.</p>
<p>Another possible usage for the <code>i</code> element was gleaned from the <cite><a href="http://typographyapp.com/">Typography Manual</a></cite> iPhone app, which states:</p>
<blockquote><p>&ldquo;Italics should be used for single letters in a sentence referred to as letters. [for] example &lsquo;The letter <i>j</i> appears too large.&rsquo;&rdquo;</p>
</blockquote>
<p>An idea I had for using <code>b</code> was somewhat linked to the <code>cite</code> element anyway. A common mistake is to markup the &#8216;author&#8217; of a quote in <code>cite</code> tags. This is of course incorrect, but what <em>do</em> you use? It&#8217;s not really a paragraph, so what is it? I did consider the <code>b</code> element for this, but I feel that such a piece of information does need a more semantic element to represent it.</p>
<p>Friend and colleague <a href="http://twitter.com/simonwiffen">@simonwiffen</a> has a very nicely written example usage for each, which I personally think are spot on. The following chunk of text is lifted directly from an internal document written by <a href="http://twitter.com/simonwiffen">@simonwiffen</a>:</p>
<div class="hr">
<hr /></div>
<p><strong>1.4.3 Strong, emphasis, bold and italic</strong></p>
<p><code>&lt;strong&gt;</code> (strong emphasis) and <code>&lt;em&gt;</code> (emphasis) should be used as opposed to <code>&lt;b&gt;</code> (bold) and <code>&lt;i&gt;</code> (italic) unless the bold or italic is required without any semantic context (for example in a product name).</p>
<p><strong>Examples</strong></p>
<p>Remember <strong>you must</strong> check this box</p>
<pre><code>&lt;p&gt;Remember &lt;strong&gt;you must&lt;/strong&gt; check this box.&lt;/p&gt;</code></pre>
<p>You should <em>really</em> try to validate your pages</p>
<pre><code>&lt;p&gt;You should &lt;em&gt;really&lt;/em&gt; try to validate your pages&lt;/p&gt;</code></pre>
<p>Read more about <b>Splash<i>down</i>!&trade;</b> below</p>
<pre><code>&lt;p&gt;Read more about &lt;b&gt;Splash&lt;i&gt;down&lt;/i&gt;!&trade;&lt;/b&gt; below&lt;/p&gt;</code></pre>
<div class="hr">
<hr /></div>
<p>Succinct and, in my opinion, pretty hard to argue with.</p>
<h4>HTML5 has it sussed</h4>
<p class="marginalia">I won&#8217;t be using HTML5 for a long while yet, but that&#8217;s another story altogether&#8230;</p>
<p>Ideally I&#8217;d like to retrofit the HTML5 specification&#8217;s definitions of each for use right now in XHTML, however I&#8217;m not sure I&#8217;d be comfortable going ahead with doing such a thing, coding to one spec whilst picking my favourite bits of another.</p>
<h5>The &lt;b&gt; element in HTML5</h5>
<blockquote><p>&ldquo;The b element represents  a span of text to be stylistically offset from the normal prose without conveying any extra importance, such as key words in a document abstract, product names in a review, or other spans of text whose typical typographic presentation is boldened.&rdquo;</p>
<p><cite><a href="http://dev.w3.org/html5/spec/Overview.html#the-b-element">HTML5</a></cite></p></blockquote>
<h5>The &lt;i&gt; element in HTML5</h5>
<blockquote><p>&ldquo;The i  element represents  a span of text in an alternate voice or mood, or otherwise offset from the normal prose, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, a ship name, or some other prose whose typical typographic presentation is italicized.&rdquo;</p>
<p><cite><a href="http://dev.w3.org/html5/spec/Overview.html#the-i-element">HTML5</a></cite></p></blockquote>
<h3>A go-between in the meantime?</h3>
<p>There will always be the argument that instead of using <code>b</code> and <code>i</code> you could or should use something like &lt;span class=&quot;italics&quot;&gt; or &lt;span class=&quot;bold&quot;&gt; so as to avoid using insemantic elements, however a class name like that is more insemantic than an in-spec HTML element. Not to mention the fact that a <code>span</code> with a <code>class</code> applied is far more cumbersome than a &#8216;pre-made&#8217; piece of HTML.</p>
<h3>The resolve?</h3>
<p>So which is worse?</p>
<ul>
<li>Using <code>i</code> to mark up emphasised text</li>
<li>Using <code>em</code> to mark up italicised and non-emphasised text</li>
<li>Using <code>i</code> to mark up purely italicised text</li>
<li>Using <code>&lt;span class="italics"&gt;</code> to mark up italicised text</li>
</ul>
<p class="marginalia">Special thanks to the following for help with this article: <a href="http://twitter.com/smashingmag" title="Smashing Magazine on Twitter">@smashingmag</a>, <a href="http://twitter.com/pekingspring">@pekingspring</a>, <a href="http://twitter.com/stevefaulkner">@stevefaulkner</a>, <a href="http://twitter.com/simonwiffen">@simonwiffen</a> and all <a href="http://twitter.com/csswizardry/followers">my Twitter followers</a>.</p>
<p>I think that the fact that <code>b</code> and <code>i</code> are still in the spec, are valid (even in strict) and are being carried over to HTML5 (albeit slightly redefined) indicates that there is still a very real place for them in web development right now. The frequency with which they&#8217;ll be used is slim at best, but they should not be ruled out, and at the very least not misunderstood. I&#8217;m not going to make the leap myself just yet, but they are there, they are usable, and one day I might just use them.</p>
<p>What are you going to do?</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2010/01/a-reconsiderationin-defence-of-b-and-i-or-people-fear-what-they-dont-understand/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>A suitable alternative&#8212;on proper use of alt attributes</title>
		<link>http://csswizardry.com/2010/01/a-suitable-alternativeon-proper-use-of-alt-attributes/</link>
		<comments>http://csswizardry.com/2010/01/a-suitable-alternativeon-proper-use-of-alt-attributes/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 16:03:03 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=318</guid>
		<description><![CDATA[Images in HTML come with a mandatory attribute used to textually describe the information displayed visually through the image. The alt attribute (not tag) is used by screenreaders etc to tell users who can&#8217;t view the actual image what it represents. It is also used in any circumstance where images can&#8217;t be loaded (slow connections, [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>I</span>mages</span> in HTML come with a mandatory attribute used to <em>textually</em> describe the information displayed <em>visually</em> through the image. The <code>alt</code> attribute (<a href="http://csswizardry.com/eta" title="A link to a diagram showing the differences between elements, tags and attributes">not tag</a>) is used by screenreaders etc to tell users who can&#8217;t view the actual image what it represents. It is also used in any circumstance where images can&#8217;t be loaded (slow connections, broken URIs etc).</p>
<p><span id="more-318"></span></p>
<h2>When not to use it</h2>
<p class="marginalia">You should never <em>not</em> use an <code>alt</code> attribute, rather leave it empty, thus: <code>alt=""</code></p>
<p>The only time you can really get away with <em>not</em> having a complete <code>alt</code> attribute is if the image holds no context or information that the user needs to be aware of. This is usually the case when the image is purely decorational, though it may be argued that the image should therefore be added through CSS in the spirit of separating style and content. By that token it is fairly safe to say that there should never be an instance in which you leave an <code>alt</code> attribute empty.</p>
<h2>You&#8217;re using it, but not quite right&#8230;</h2>
<p>The next best scenario is that you are using images correctly, for their correct purpose and are using <code>alt</code> attributes, but they don&#8217;t really do as much as they should. A lot of the time I come across images that have less than ideal <code>alt</code> attributes.</p>
<p><img src="http://csswizardry.com/wp-content/uploads/2010/01/car.jpg" alt="A photograph of an abandoned car" width="640" height="393" class="full" /></p>
<p class="marginalia">Image sourced via Google Images&mdash;original author unknown.</p>
<p>One example might be the above image of a car. This, while technically correct, is not ideal: <code>&lt;img src="/img/car.jpg" alt="Car" /&gt;</code>. All this tells the user is &#8216;Car&#8217;. It doesn&#8217;t say whether it&#8217;s a picture with the word car in it, or whether it&#8217;s a picture of a car. A much better <code>alt</code> attribute would be <code>alt="A photograph of an abandoned car"</code> (as used in my code).</p>
<h3>Other poor uses</h3>
<p>Another real-world example of poor <code>alt</code> attribute usage is actually on <a href="http://www.cnn.com/">CNN&#8217;s website</a>. On their home page today (26 January, 2010) they have a series of headlines with accompanying images. The code for such a pairing looks like this:</p>
<pre><code>&lt;img height="68" border="0" width="120" alt="Haiti's swanky club &rarr;
now home to misery" src="http://i.cdn.turner.com/cnn/2010/WORLD/ &rarr;
americas/01/26/haiti.camp/tzvids.haiti.aid.cnn.jpg"&gt; &rarr;
&hellip; Haiti's swanky club now home to misery</code></pre>
<p>This is wrong on two counts:</p>
<ol>
<li>A screenreader will read out to the user <q>Haiti&#8217;s swanky club now home to misery &hellip; Haiti&#8217;s swanky club now home to misery</q>. Every image/headline pairing on the page is laid out like this, meaning in every instance a user using a screenreader will hear the headline twice. This will surely soon get annoying.</li>
<li>Secondly, the image was actually of earthquake survivors holding a large bag, nothing to do with clubs and, unfortunately, far from swanky.</li>
</ol>
<h2>Using the attribute properly</h2>
<p>On the <a href="http://www.bbc.co.uk/">BBC&#8217;s home page</a> however (on the same date) they are using <code>alt</code> attributes perfectly. They have an image of a woman wearing a veil, alongside the article&#8217;s headline <q>France report back face veil ban</q>. The image&#8217;s <code>alt</code> attribute: <code>alt="A woman wears a full-length veil in Lyon, 25 January"</code>.</p>
<h2>The biggest no-no of all</h2>
<p>One thing which consistently winds me up is the ridiculously bad practice of stuffing <code>alt</code> attributes with keywords. <code>alt</code> attributes are an accessibility feature, end of. They are <em>not</em> a way of slipping in keywords out of sight, and any attempt to do so is irresponsible and incredibly bad practice. The only time &#8216;keywords&#8217; may be validly placed in <code>alt</code> attributes is if it&#8217;s explicitly related to the image; for example: <code>&lt;img src="/img/product.jpg" alt="A photograph of Mike's Carpets' ProClean&trade; carpet cleaner" /&gt;</code>.</p>
<h2>How to do it properly</h2>
<p>Writing proper <code>alt</code> text is incredibly simple, yet a little more time consuming than the &#8216;Car&#8217; cop-out. All you need to do is write out in full exactly what the image shows. If it&#8217;s an elephant giving a donkey a piggy-back don&#8217;t be lazy and use <code>alt="Elephant and a donkey"</code>. Instead, write out <code>alt="A photograph of an African elephant giving a donkey a piggy back across a swamp"</code>.</p>
<p>Also, for any pages that use similar images repeatedly but are slightly different to one another, make sure your alt attributes reflect these differences. A good example would be <a href="http://csswizardry.com/portfolio/">my portfolio page</a>. Instead of using <code>alt="Screenshot"</code> over and over again I used text like <code>alt="Screenshot of Suzanna Haworth’s website"</code> and <code>alt="Screenshot of RAAMaudio UK Ltd."</code> etc.</p>
<p>This is one of the most basic aspects of web development, but one that too many people are still getting wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2010/01/a-suitable-alternativeon-proper-use-of-alt-attributes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Typographic work planner</title>
		<link>http://csswizardry.com/2009/12/typographic-work-planner/</link>
		<comments>http://csswizardry.com/2009/12/typographic-work-planner/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 11:17:25 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Semantics]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=49</guid>
		<description><![CDATA[No one likes being told what to do, especially if it&#8217;s work related, but nevertheless jobs need done. Why present boring stuff in a boring way? If you&#8217;re going to be told what to do, at least soften the blow by being told nicely. Enter this, a little HTML/CSS typographic work planner. By using some [...]]]></description>
			<content:encoded><![CDATA[<p><span class="opener"><span>N</span>o one</span> likes being told what to do, especially if it&#8217;s work related, but nevertheless jobs need done. Why present boring stuff in a boring way? If you&#8217;re going to be told what to do, at least soften the blow by being told nicely. Enter this, a little HTML/CSS typographic work planner. By using some super-semantic HTML and a dash of CSS you can craft a beautiful looking yet incredibly simple work planner for you and your staff.</p>
<p><a style="background:none;" title="View a working demo of the typographic work planner" href="http://csswizardry.com/demos/typographic-work-planner/"><img class="full" src="http://csswizardry.com/wp-content/uploads/2009/12/table.jpg" alt="Screenshot of the typographic work planner" width="640" height="367" /></a></p>
<p><span id="more-49"></span></p>
<h2>Typographic work planner markup:</h2>
<p>The rich, semantic markup is as follows. Notice the use of the more semantic elements and attributes such as <code>summary=""</code>, <code>colgroup</code>, <code>scope=""</code>, <code>caption</code> and more&#8230;</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8" /&gt;

  &lt;title&gt;Typographic work planner&lt;/title&gt;

  &lt;link rel="stylesheet" type="text/css" href="css/style.css" /&gt;
&lt;/head&gt;
&lt;body id="home"&gt;
  &lt;div id="wrapper"&gt;
    &lt;table summary="An overview of upcoming and recently completed work ?
    by employees"&gt;
      &lt;caption&gt;Work schedule&lt;/caption&gt;
      &lt;colgroup&gt;
        &lt;col id="date" /&gt;
        &lt;col id="user" /&gt;
        &lt;col id="dec" /&gt;
      &lt;/colgroup&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th scope="col"&gt;Date&lt;/th&gt;
          &lt;th scope="col"&gt;User&lt;/th&gt;
          &lt;th scope="col"&gt;Description&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tfoot&gt;
        &lt;tr&gt;
          &lt;td colspan="3"&gt;Sense Internet Ltd work planner&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tfoot&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td class=&quot;date&quot;&gt;20 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Harry Roberts&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Lorem ipsum dolor sit amet, elit. Nunc ?
          rhoncus dui et mauris. Nam augue felis, dapibus ut, condimentum ?
          in, ornare a, est. Proin sem risus, pretium ut, mattis nec.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class=&quot;date&quot;&gt;20 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Joe Whitley&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Suspendisse venenatis. Donec eleifend ?
          dignissim diam. Integer faucibus neque tempor pede. Maecenas at ?
          magna sed lectus adipiscing molestie. Pellentesque habitant morbi ?
          tristique senectus et netuset malesuada fames ac turpis egestas. ?
          Curabitur sodales gravida tellus.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class=&quot;date&quot;&gt;21 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Harry Roberts&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Lorem ipsum dolor sit amet, elit. Nunc ?
          rhoncus dui et mauris. Nam augue felis, dapibus ut, condimentum ?
          in, ornare a, est. Proin sem risus, pretium ut, mattis nec.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class=&quot;date&quot;&gt;21 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Joe Whitley&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Suspendisse venenatis. Donec eleifend ?
          dignissim diam. Integer faucibus neque tempor pede. Maecenas at ?
          magna sed lectus adipiscing molestie. Pellentesque habitant morbi ?
          tristique senectus et netuset malesuada fames ac turpis egestas. ?
          Curabitur sodales gravida tellus.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class=&quot;date&quot;&gt;21 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Sam Penrose&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Lorem ipsum dolor sit amet, elit. Nunc ?
          rhoncus dui et mauris. Nam augue felis, dapibus ut, condimentum ?
          in, ornare a, est. Proin sem risus, pretium ut, mattis nec.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr class="today"&gt;
          &lt;td class=&quot;date&quot;&gt;22 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Joe Whitley&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Suspendisse venenatis. Donec eleifend ?
          dignissim diam. Integer faucibus neque tempor pede. Maecenas at ?
          magna sed lectus adipiscing molestie. Pellentesque habitant morbi ?
          tristique senectus et netuset malesuada fames ac turpis egestas. ?
          Curabitur sodales gravida tellus.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr class="today"&gt;
          &lt;td class=&quot;date&quot;&gt;22 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Sam Penrose&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Lorem ipsum dolor sit amet, elit. Nunc ?
          rhoncus dui et mauris. Nam augue felis, dapibus ut, condimentum ?
          in, ornare a, est. Proin sem risus, pretium ut, mattis nec.&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr class="today"&gt;
          &lt;td class=&quot;date&quot;&gt;22 December, 2009&lt;/td&gt;
          &lt;td class=&quot;user&quot;&gt;Joe Whitley&lt;/td&gt;
          &lt;td class=&quot;desc&quot;&gt;Suspendisse venenatis. Donec eleifend ?
          dignissim diam. Integer faucibus neque tempor pede. Maecenas at ?
          magna sed lectus adipiscing molestie. Pellentesque habitant morbi ?
          tristique senectus et netuset malesuada fames ac turpis egestas. ?
          Curabitur sodales gravida tellus.&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<h3>In detail&#8230;</h3>
<p>There are a few things in the table you may not have seen before, briefly, they are:</p>
<ul>
<li><strong><code>summary=""</code>:</strong> This is an attribute which provides a brief overview of the table and its contents/purpose.</li>
<li><strong><code>caption</code>:</strong> This is a table specific caption, essentially a heading/title explicitly for the table.</li>
<li><strong><code>colgroup</code> and <code>col</code>:</strong> This is an essentially invisible element that just adds semantic meaning to the table. It defines the columns and can—in some browsers—be used to style them.</li>
<li><strong><code>scope="col"</code>:</strong> This is an attribute which tells the browser whether the <code>th</code> is a title for a column or a row. This then obviously makes the other possible attribute value <code>row</code>.</li>
<li><strong><code>tfoot</code>:</strong> This is a table footer and contain pretty much anything you like. It must however appear <em>before</em> the <code>tbody</code>.</li>
</ul>
<h2>Typographic work planner CSS:</h2>
<p>The CSS used to create the work planner is pretty basic, with a dash or progressive enhancement added via some CSS3. <a href="http://csswizardry.com/demos/typographic-work-planner/css/style.css">View the full CSS file with reset etc.</a></p>
<pre><code>table{
  margin-bottom:20px;
}
td,th{
  border-bottom:1px solid #ccc;
}
tbody tr{
  background:#fff;
}
tbody tr:nth-of-type(even){
  background:#ffc;
}
th,tfoot,caption{
  font-family:Helvetica, Arial, Verdana, sans-serif;
  font-size:1.6em;
  font-weight:bold;
}
th,td{
  padding:10px 0;
}
caption{
  font-size:2.4em;
  position:absolute;
  left:-9999px;
}
.date{
  width:160px;
  padding:10px 15px 10px 5px;
  font-family:Georgia, "Times New Roman", Times;
  font-size:1.6em;
  font-style:italic;
}
.user{
  width:460px;
  padding-right:20px;
  font-family:Helvetica, Arial, Verdana, sans-serif;
  font-size:4.8em;
  font-weight:bold;
}
.desc{
  width:280px;
  font-size:1.2em;
}
tbody tr.today{
  background:#ff8;

  text-shadow:1px 1px 1px rgba(0,0,0,0.3);
}
tfoot{
  color:#666;
}
tfoot td{
  padding:10px 5px;
}</code></pre>
<h2><a href="http://csswizardry.com/demos/typographic-work-planner/">Typographic work planner demo</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2009/12/typographic-work-planner/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>
