<?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>The Blog of Clint Andrew Hall &#187; Accessibility</title>
	<atom:link href="http://www.clintandrewhall.com/blog/category/code/accessibility/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clintandrewhall.com/blog</link>
	<description>Welcome to my corner of the web, where I post my ponderings, pictures and pontifications.</description>
	<lastBuildDate>Tue, 31 Aug 2010 20:27:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Contact Form Experiment</title>
		<link>http://www.clintandrewhall.com/blog/2009/10/contact-form-experiment/</link>
		<comments>http://www.clintandrewhall.com/blog/2009/10/contact-form-experiment/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 21:43:15 +0000</pubDate>
		<dc:creator>Clint</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://www.clintandrewhall.com/blog/?p=95</guid>
		<description><![CDATA[Yesterday, I saw this tweet from Smashing Magazine: I took a look at the form, and I must say I was impressed too.  Unfortunately, I was using TweetDeck on my iPhone&#8230; as a result, I didn&#8217;t see the contact form at all because the background image didn&#8217;t load very fast.  That prompted me to post [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I saw this tweet from Smashing Magazine:</p>
<div id="attachment_97" class="wp-caption alignnone" style="width: 614px"><img class="size-full wp-image-97" title="Tweet from Smashing Magazine" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/Screen-shot-2009-10-22-at-3.46.46-PM1.jpg" alt="Tweet from Smashing Magazine" width="604" height="97" /><p class="wp-caption-text">Tweet from Smashing Magazine</p></div>
<p>I took a look at the form, and I must say I was impressed too.  Unfortunately, I was using TweetDeck on my iPhone&#8230; as a result, I didn&#8217;t see the contact form at all because the background image didn&#8217;t load very fast.  That prompted me to post this reply:</p>
<div id="attachment_98" class="wp-caption alignnone" style="width: 614px"><img class="size-full wp-image-98" title="My Reply" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/Screen-shot-2009-10-22-at-3.52.34-PM.jpg" alt="My reply on Twitter" width="604" height="112" /><p class="wp-caption-text">My reply on Twitter</p></div>
<p>Being a social media junkie, this tweet was then cross-posted to my Facebook, prompting this reply from a web developer friend of mine:</p>
<div id="attachment_99" class="wp-caption alignnone" style="width: 499px"><img class="size-full wp-image-99" title="Resulting Facebook Conversation" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/facebook-convo.jpg" alt="...the resulting Facebook conversation." width="489" height="409" /><p class="wp-caption-text">...the resulting Facebook conversation.</p></div>
<p>As you can well imagine, I could not let this stand.  So I decided I would refactor the form to prove that, with a few tweaks to the CSS and markup, this form could avoid the problems I pointed out.</p>
<p><span id="more-95"></span>First, let me preface by saying that I am not saying the code is bad&#8230; on the contrary, I really like the concept.  I just want to:</p>
<ol>
<li>Dispel my friend&#8217;s poor logic, and</li>
<li>Raise awareness about accessibility.</li>
</ol>
<p>That said, I tried to minimize my changes to the original code as much as possible; there are certainly improvements that can be made to the CSS and to the markup, but that was not my goal.</p>
<p>For reference, here are the <a title="Before" href="http://www.clintandrewhall.com/demos/contact-form/before.html" target="_blank">before</a> and the <a title="After" href="http://www.clintandrewhall.com/demos/contact-form/after.html" target="_blank">after</a> demo pages.  I&#8217;d load them in separate tabs; you&#8217;ll see they are identical, almost to the pixel.  I&#8217;ve also added a scripted link to allow you to hide the background image.</p>
<h3>The Accessibility Problem</h3>
<p>First, let&#8217;s define the problem. In the existing CSS, the labels are completely hidden and the background is applied to the form.  As a result, here are screen shots of the contact form, with and without its background image, (notice the dotted lines for each form field):</p>
<div id="attachment_100" class="wp-caption alignleft" style="width: 393px"><img class="size-full wp-image-100   " title="Contact Form with Images On" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/Screen-shot-2009-10-22-at-3.40.53-PM.jpg" alt="The contact form with images on and fully loaded" width="383" height="400" /><p class="wp-caption-text">The contact form with images on and fully loaded</p></div>
<div id="attachment_101" class="wp-caption alignleft" style="width: 338px"><img class="size-full wp-image-101 " title="Contact Form with No Image" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/Screen-shot-2009-10-22-at-3.41.08-PM.jpg" alt="The contact form without the image loaded" width="328" height="400" /><p class="wp-caption-text">The contact form without the image loaded</p></div>
<p style="clear:both">
<p style="clear:both">Without the image, the form becomes unusable.  So how can we edit the HTML and style the form to avoid this?</p>
<h3>The Approach</h3>
<p>In short, we need to add labels to each field and have the image hide them if present.  This can be accomplished with z-indexing:</p>
<div id="attachment_103" class="wp-caption alignnone" style="width: 810px"><img class="size-full wp-image-103  " title="Approach Diagram" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/diagram.jpg" alt="A diagram of the layout" width="800" height="340" /><p class="wp-caption-text">A diagram of the layout</p></div>
<h3>The Solution</h3>
<p>First, I refactored the original form into something a bit more manageable, such as adding a fieldset element to the phone number, adding a header element and consolidating the label and input fields, (and thus removing the pesky &#8220;for&#8221; attribute):</p>
<pre><code>...
&lt;h3&gt;&lt;span&gt;Contact Form&lt;/span&gt;&lt;/h3&gt;
...
&lt;fieldset id="phone-el"&gt;
    &lt;legend&gt;&lt;span&gt;Phone&lt;/span&gt;&lt;/legend&gt;
    &lt;p id="phone-ac-el"&gt;
        &lt;label&gt;
            &lt;span&gt;Area Code&lt;/span&gt;
            &lt;input id="phone-ac" class="text" maxlength="3"
                name="phone-ac" size="3" type="text" /&gt;
        &lt;/label&gt;
    &lt;/p&gt;
...
</code></pre>
<p>Since the legend for the phone fieldset wasn&#8217;t being displayed, I decided I would forgo the addition of any empty element and just use it for the contact form.  A bit of positioning based on existing CSS and some negative text-indent and we were in business:</p>
<pre>body#contact #form legend span {
    background: url(res/contact-content.png) center top no-repeat;
    position: absolute;
    top: -199px;
    left: -180px;
    width: 750px;
    height: 786px;
    display: block;
    text-align: left;
    text-indent: -1000px;
    overflow: hidden;
    z-index: 50;
}</pre>
<h3>The Result</h3>
<p>Now, when the page loads and no images are present, the form looks like this:</p>
<div id="attachment_102" class="wp-caption alignnone" style="width: 314px"><img class="size-full wp-image-102 " title="My Refactor of the Contact Form" src="http://www.clintandrewhall.com/blog/wp-content/uploads/2009/10/Screen-shot-2009-10-22-at-3.41.23-PM.jpg" alt="My refactor of the contact form without the image" width="304" height="400" /><p class="wp-caption-text">My refactor of the contact form without the image</p></div>
<p>With a few simple changes, the form is completely usable&#8230; bulletproof&#8230; regardless of the user&#8217;s situation.</p>
<h3>A Few Closing Remarks</h3>
<p>I hate the oft-uttered mantra of, &#8220;those folks aren&#8217;t in my demographic.&#8221;  That is a dangerous and amateur view of an audience for your website.  You should always be looking to make your forms as simple but as accessible as possible, because, frankly&#8230; your demographic is anyone with a web browser.  Discounting any percentage is not only a disadvantage for your business, but a disservice to all users.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clintandrewhall.com/blog/2009/10/contact-form-experiment/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
