<?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; Images</title>
	<atom:link href="http://csswizardry.com/tag/images/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>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>
	</channel>
</rss>
