<?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>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>Borders on responsive images</title>
		<link>http://csswizardry.com/2011/07/borders-on-responsive-images/</link>
		<comments>http://csswizardry.com/2011/07/borders-on-responsive-images/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 14:28:08 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Responsive web design]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=2981</guid>
		<description><![CDATA[This is a quick-tip type post, nothing major but a simple and effective tip for getting responsive borders on responsive images in your responsive designs.
As we know all too well, we can&#8217;t specify borders as percentages. This is a major annoyance if you&#8217;re working (or attempting to work) large borders into a responsive design. It [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick-tip type post, nothing major but a simple and effective tip for getting responsive borders on responsive images in your responsive designs.</p>
<p>As we know all too well, we can&#8217;t specify borders as percentages. This is a major annoyance if you&#8217;re working (or attempting to work) large borders into a responsive design. It may not be all that difficult with images, it turns out.</p>
<p>Instead of applying something like this:</p>
<pre><code>img{
  max-width:100%;
  border:5px solid red;
}</code></pre>
<p>Simply use:</p>
<pre><code>img{
  max-width:98%;
  padding:1%; <span class="code-comment">/* A percentage that, when doubled and added to the above, makes 100%. */</span>
  background:red; <span class="code-comment">/* Color of the faux border. */</span>
}</code></pre>
<h2><a href="http://jsfiddle.net/csswizardry/eqE9J/show/">Demo</a></h2>
<p>I made <a href="http://jsfiddle.net/csswizardry/eqE9J/">a jsFiddle</a> and <a href="http://jsfiddle.net/csswizardry/eqE9J/show/">here is its output</a>.</p>
<p>Now this does seem ridiculously obvious but a quick bit of Googling (other search engines are available) yielded nothing similar. Apologies is someone&#8217;s beaten me to this and I&#8217;m retreading old ground.</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/07/borders-on-responsive-images/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Styling alt text on images</title>
		<link>http://csswizardry.com/2011/06/styling-alt-text-on-images/</link>
		<comments>http://csswizardry.com/2011/06/styling-alt-text-on-images/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 17:41:39 +0000</pubDate>
		<dc:creator>Harry Roberts</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://csswizardry.com/?p=2870</guid>
		<description><![CDATA[I tweeted a tip the other day whereby you add text styles to images so that their alt text is differentiated if images, for whatever reason, cannot be loaded.
The tweet sparked more interest than I expected so I thought I would give the technique a more thorough writeup. The CSS is incredibly simple but it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/csswizardry/status/81748007304962048">I tweeted a tip</a> the other day whereby you add text styles to images so that their <code>alt</code> text is differentiated if images, for whatever reason, cannot be loaded.</p>
<p>The tweet sparked more interest than I expected so I thought I would give the technique a more thorough writeup. The CSS is incredibly simple but it&#8217;s just one of those things that can make a lot of difference to someone&#8217;s UX.</p>
<p>The thinking is that by applying text-styles to images you can affect their <code>alt</code> text and how that appears if the image fails to load. This can help users realise there&#8217;s something different about a piece of content and that it&#8217;s perhaps not directly a part of the current text.</p>
<p>A lot of people weren&#8217;t aware this would or does work but if you think about it, any <code>alt</code> text you&#8217;ve ever seen will have been the same face, colour and style as the rest of the page. <code>alt</code> text (and therefore images) can be styled!</p>
<h2>The code</h2>
<p>I started doing this a long, long time ago but for some reason completely forgot about it until I started developing <a href="http://inuitcss.com">inuit.css</a>.</p>
<p>I tend to always apply italics to the text and oftentimes a text colour. Italics is fairly failsafe as figures and asides etc are often set in italics.</p>
<p>Text colours can be more troublesome as it could be misconstrued as being a link, so use this wisely and avoid using the same colour as your links appear in.</p>
<p>Another fairly progressive (but potentially unstable) addition is to use the <code>:after</code> pseudo-element to append the text &#8216;(image)&#8217; onto the <code>alt</code> text. This only seems to work in Firefox (4).</p>
<p>The code, in full, is simply:</p>
<pre><code>img{
    font-style:italic;
    color:#c00;
}

<span class="code-comment">/*
In Firefox we can insert the word (image) into the alt text of an image that hasn’t loaded.
*/</span>
img:after   { content:&quot; (image)&quot;; }
img::after  { content:&quot; (image)&quot;; } <span class="code-comment">/* New CSS3 standard notation */</span></code></pre>
<p>So there we have it, a simple, tiny addition to make your users&#8217; experience a little more polished and complete&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://csswizardry.com/2011/06/styling-alt-text-on-images/feed/</wfw:commentRss>
		<slash:comments>8</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>
	</channel>
</rss>

