SlideShare a Scribd company logo
1 of 155
Download to read offline
FALLING IN LOVE WITH FORMS 
Aaron Gustafson 
@AaronGustafson 
slideshare.net/AaronGustafson
Forms suck.
They are incredibly 
tedious to create.
They are undeniably 
annoying to fill in.
They can be 
frustrating to test.
They require logic.
can 
Forms suck.
don’t have to 
Forms suck.
can 
a lot less 
Forms suck.
Forms can be… 
easy to build 
predictable 
effortless to use 
and accessible
It’s all in how you 
look at them.
HELPFUL HINT 
Break large, 
complex forms into 
smaller, simpler, 
reusable patterns
How about a 
common example? 
Let’s look 
at a contact form.
webstandardssherpa.com/contact
webstandardssherpa.com/contact
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
Your Name 
<input type=“text” name=“full_name”>
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
Your Name 
<input name=“full_name”>
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
Your Name 
<input name=“full_name”/>
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
Your Name 
<input name=“full_name”>
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
<label>Your Name</label> 
<input name=“full_name”>
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name”>
FALLING IN LOVE WITH FORMS 
Pattern 1: Label & Field 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required>
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input id=“email” name=“email” required> 
We will only use your email address to respond to your message.
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input id=“email” name=“email” required> 
We will only use your email address to respond to your message. 
!
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input id=“email” name=“email” required> 
We will only use your email address to respond to your message. 
!
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required> 
We will only use your email address to respond to your message. 
!
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required> 
We will only use your email address to respond to your message. 
!
Browsers ignore 
what they don’t 
understand
Progressive 
Enhancement
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required> 
<em> 
We will only use your email address to respond to your message. 
</em>
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required> 
<em class=“note”> 
We will only use your email address to respond to your message. 
</em>
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required 
aria-describedby=“email-note”> 
<em class=“note” id=“email-note”> 
We will only use your email address to respond to your message. 
</em>
FALLING IN LOVE WITH FORMS 
Pattern 2: Label, Field & Note 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required 
aria-describedby=“email-note”> 
<em class=“note” id=“email-note”> 
We will only use your email address to respond to your message. 
</em> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Rinse & Repeat 
<label for=“subject”>Purpose of Your Message</label> 
<select id="subject" name="subject"> 
<option>Question/Comment</option> 
<option>Article Error</option> 
<option>Website Bug Report</option> 
<option>Ask the Sherpas a question</option> 
</select>
FALLING IN LOVE WITH FORMS 
Rinse & Repeat 
<label for=“message”>Your Message</label> 
<textarea id="message" name="message"></textarea>
FALLING IN LOVE WITH FORMS 
Buttons 
<input type=“submit” value=“Send My Message”>
FALLING IN LOVE WITH FORMS 
Buttons 
<button type=“submit”>Send My Message</button>
HELPFUL HINT 
A button element 
can contain pretty 
much anything 
! (within reason)
FALLING IN LOVE WITH FORMS 
Buttons 
<button type="submit" value=“basic"> 
<h3>Basic Plan</h3> 
<p>You get 20 <abbr title="gigabytes">GB</abbr> of storage 
and a single domain name for <strong>$2.99 
<abbr title=“per month”>/mo</abbr></strong></p> 
</button>
That new email field 
looks cool, can we 
see more of that 
fancy HTML5 stuff?
FALLING IN LOVE WITH FORMS 
Requesting URLs 
<label for=“url”>URL</label> 
<input type=“url” id=“url” name=“url” required 
aria-describedby=“url-note” 
> 
<em class=“note” id=“url-note”> 
Please provide the URL for the specific page that includes the area 
you want reviewed. 
</em>
FALLING IN LOVE WITH FORMS 
Requesting URLs 
<label for=“url”>URL</label> 
<input type=“url” id=“url” name=“url” required 
aria-describedby=“url-note” 
> 
<em class=“note” id=“url-note”> 
Please provide the URL for the specific page that includes the area 
you want reviewed. 
</em>
FALLING IN LOVE WITH FORMS 
Requesting URLs 
<label for=“url”>URL</label> 
<input type=“url” id=“url” name=“url” required 
aria-describedby=“url-note” 
> 
<em class=“note” id=“url-note”> 
Please provide the URL for the specific page that includes the area 
you want reviewed. 
</em>
FALLING IN LOVE WITH FORMS 
Providing hints 
<label for=“url”>URL</label> 
<input type=“url” id=“url” name=“url” required 
aria-describedby=“url-note” 
placeholder=“http://www.yoursite.com/specific-page#anchored-section” 
> 
<em class=“note” id=“url-note”> 
Please provide the URL for the specific page that includes the area 
you want reviewed. 
</em>
HELPFUL HINT 
Placeholders are just 
that: placeholders 
for actual content. 
They are not labels!
FALLING IN LOVE WITH FORMS 
Providing hints 
<label for=“url”>URL</label> 
<input type=“url” id=“url” name=“url” required 
aria-describedby=“url-note” 
placeholder=“http://www.yoursite.com/specific-page#anchored-section” 
> 
<em class=“note” id=“url-note”> 
Please provide the URL for the specific page that includes the area 
you want reviewed. 
</em>
FALLING IN LOVE WITH FORMS 
Requesting phone numbers 
<label for="preferred_phone">Preferred Phone</label> 
<input type="tel" id="preferred_phone" name=“preferred_phone” 
placeholder="ex. 123-456-7890” 
>
FALLING IN LOVE WITH FORMS 
Requesting phone numbers 
<label for="preferred_phone">Preferred Phone</label> 
<input type="tel" id="preferred_phone" name=“preferred_phone” 
placeholder="ex. 123-456-7890” 
>
FALLING IN LOVE WITH FORMS 
Requesting numbers 
<label for="test">What is 1 + 1?</label> 
<input id="test" type=“number" name="test">
FALLING IN LOVE WITH FORMS 
Requesting numbers 
<label for="test">What is 1 + 1?</label> 
<input id="test" type=“number" name="test">
FALLING IN LOVE WITH FORMS 
Requesting numbers 
<label for="test">What is 1 + 1?</label> 
<input id="test" type=“number" name=“test” 
pattern=“[0-9]*” 
> 
<!-- Note: pattern ensures Safari Mobile gives a keypad -->
FALLING IN LOVE WITH FORMS 
Requesting numbers 
<label for=“volume">How Loud is Spinal Tap?</label> 
<input id="volume" type=“range" name=“volume” 
min=“0” max=“11” step=“1” 
>
FALLING IN LOVE WITH FORMS 
Requesting numbers 
<label for="test">What is 1 + 1?</label> 
<input id="test" type=“number" name=“test” 
pattern=“[0-9]*” 
min=“0” max=“9” 
>
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="preferred_dates">Preferred Date to Visit</label> 
<input id="preferred_dates" type="date" name=“preferred_dates" 
required 
>
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="preferred_dates">Preferred Date to Visit</label> 
<input id="preferred_dates" type="date" name=“preferred_dates" 
required 
>
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="preferred_dates">Preferred Date to Visit</label> 
<input id="preferred_dates" type="date" name=“preferred_dates" 
required 
>
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="preferred_dates">Preferred Date to Visit</label> 
<input id="preferred_dates" type="date" name=“preferred_dates" 
required 
min=“2014-09-10” max=“2014-12-19” 
>
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="preferred_dates">Preferred Date to Visit</label> 
<input id="preferred_dates" type="date" name=“preferred_dates" 
required 
min=“2014-09-10” max=“2014-12-19” 
>
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="requested_tour_time">Tour Time Requested</label> 
<input id="preferred_dates" type="time" name=“preferred_dates">
FALLING IN LOVE WITH FORMS 
Requesting dates & times 
<label for="requested_tour_time">Tour Time Requested</label> 
<input id="preferred_dates" type="time" name=“preferred_dates">
FALLING IN LOVE WITH FORMS 
Mentalism 
<label for="state">State</label> 
<input id="state" name="state" list="states"> 
<datalist id="states"> 
<option>Alabama</option> 
<option>Alaska</option> 
<option>Arizona</option> 
<option>Arkansas</option> 
<!-- options continue --> 
</datalist>
FALLING IN LOVE WITH FORMS 
Mentalism 
<label for="state">State</label> 
<input id="state" name="state" list="states"> 
<datalist id="states"> 
<option>Alabama</option> 
<option>Alaska</option> 
<option>Arizona</option> 
<option>Arkansas</option> 
<!-- options continue --> 
</datalist>
FALLING IN LOVE WITH FORMS 
Mentalism 
<label for="state">State</label> 
<input id="state" name="state" list="states"> 
<datalist id="states"> 
<option value="AL">Alabama</option> 
<option value="AK">Alaska</option> 
<option value="AZ">Arizona</option> 
<option value="AR">Arkansas</option> 
<!-- options continue --> 
</datalist>
FALLING IN LOVE WITH FORMS 
Mentalism 
<label for="state">State</label> 
<input id="state" name="state" list="states"> 
<datalist id="states"> 
<option value="AL">Alabama</option> 
<option value="AK">Alaska</option> 
<option value="AZ">Arizona</option> 
<option value="AR">Arkansas</option> 
<!-- options continue --> 
</datalist>
FALLING IN LOVE WITH FORMS 
Mentalism: smart fallbacks 
<label for=“state" id=“state_label”>State</label> 
<datalist id=“states”> 
! 
<select name=“state” aria-labelledby=“state_label”> 
<option>Alabama</option> 
<option>Alaska</option> 
<option>Arizona</option> 
<option>Arkansas</option> 
<!-- options continue --> 
</select> 
! 
If other, please specify 
! 
</datalist> 
<input id="state" name="state" list="states"> 
Based on work by Jeremy Keith: http://adactio.com/journal/4272
FALLING IN LOVE WITH FORMS 
Mentalism: smart fallbacks 
<label for=“state" id=“state_label”>State</label> 
<datalist id=“states”> 
! 
<select name=“state” aria-labelledby=“state_label”> 
<option>Alabama</option> 
<option>Alaska</option> 
<option>Arizona</option> 
<option>Arkansas</option> 
<!-- options continue --> 
</select> 
! 
If other, please specify 
! 
</datalist> 
<input id="state" name="state" list="states"> 
Based on work by Jeremy Keith: http://adactio.com/journal/4272
FALLING IN LOVE WITH FORMS 
Mentalism: smart fallbacks 
<label for=“state" id=“state_label”>State</label> 
<datalist id=“states”> 
! 
<select name=“state” aria-labelledby=“state_label”> 
<option>Alabama</option> 
<option>Alaska</option> 
<option>Arizona</option> 
<option>Arkansas</option> 
<!-- options continue --> 
</select> 
! 
If other, please specify 
! 
</datalist> 
<input id="state" name="state" list="states"> 
Based on work by Jeremy Keith: http://adactio.com/journal/4272
FALLING IN LOVE WITH FORMS 
Mentalism: smart fallbacks 
<label for=“state" id=“state_label”>State</label> 
<datalist id=“states”> 
! 
<select name=“state” aria-labelledby=“state_label”> 
<option>Alabama</option> 
<option>Alaska</option> 
<option>Arizona</option> 
<option>Arkansas</option> 
<!-- options continue --> 
</select> 
! 
If other, please specify 
! 
</datalist> 
<input id="state" name="state" list="states"> 
Based on work by Jeremy Keith: http://adactio.com/journal/4272
Ok, I get it: forms in 
HTML5 are awesome. 
But how should we 
organize our forms?
FALLING IN LOVE WITH FORMS 
Do we divide it up? 
<div> 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required> 
</div>
FALLING IN LOVE WITH FORMS 
Do paragraphs make sense? 
<p> 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required> 
</p>
FALLING IN LOVE WITH FORMS 
Is it a list of questions? 
<ol> 
<li> 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required> 
</li> 
</ol>
FALLING IN LOVE WITH FORMS 
Is it a list of questions? 
form ol, 
form ul { 
list-style: none; 
margin: 0; 
padding: 0; 
}
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“text”> 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required> 
</li>
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“form-control form-control--text”> 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required> 
</li>
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“text”> 
<label for=“full_name”>Your Name</label> 
<input id=“full_name” name=“full_name” required> 
</li>
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“email”> 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required 
aria-describedby=“email-note”> 
<em class=“note” id=“email-note”> 
We will only use your email address to respond 
to your message. 
</em> 
</li>
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“select”> 
<label for=“subject”>Purpose of Your Message</label> 
<select id="subject" name="subject"> 
<option>Question/Comment</option> 
<option>Article Error</option> 
<option>Website Bug Report</option> 
<option>Ask the Sherpas a question</option> 
</select> 
</li>
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“textarea”> 
<label for=“message”>Your Message</label> 
<textarea id="message" name=“message"></textarea> 
</li>
FALLING IN LOVE WITH FORMS 
Control Group Classification 
<li class=“buttons”> 
<button type=“submit”>Send My Message</button> 
</li>
Makes sense. 
What about more 
complex form 
constructs?
FALLING IN LOVE WITH FORMS 
Pattern 3: Confirmations 
<input type=“checkbox” name=“newsletter” value=“yes”> 
Sign me up for this newsletter
FALLING IN LOVE WITH FORMS 
Pattern 3: Confirmations 
<input type=“checkbox” name=“newsletter” value=“yes” 
id=“newsletter”> 
<label for=“newsletter”>Sign me up for this newsletter</label>
FALLING IN LOVE WITH FORMS 
Pattern 3: Confirmations 
<label> 
<input type=“checkbox” name=“newsletter” value=“yes”> 
Sign me up for this newsletter 
</label>
FALLING IN LOVE WITH FORMS 
Pattern 3: Confirmations 
input { 
/* Styles for most normal input types */ 
} 
! 
label input { 
/* Styles for checkbox and radio controls */ 
}
FALLING IN LOVE WITH FORMS 
Pattern 3: Confirmations 
<label for=“newsletter”> 
<input type=“checkbox” name=“newsletter” value=“yes” 
id=“newsletter”> 
Sign me up for this newsletter 
</label>
FALLING IN LOVE WITH FORMS 
Pattern 3: Confirmations 
<li class=“confirm”> 
<label for=“newsletter”> 
<input type=“checkbox” name=“newsletter” value=“yes” 
id=“newsletter”> 
Sign me up for this newsletter 
</label> 
</li>
FALLING IN LOVE WITH FORMS 
Pattern 4: Multiple Choice 
Tablets (8 available) 
! 
<label for="asus-nexus-7"> 
<input type="checkbox" name="device[]" id=“asus-nexus-7"> 
Asus Nexus 7 
</label> 
! 
<!-- more options -->
FALLING IN LOVE WITH FORMS 
Pattern 4: Multiple Choice 
Tablets (8 available) 
! 
<ul> 
<li><!-- Asus Nexus 7 --></li> 
<!-- more options --> 
</ul>
FALLING IN LOVE WITH FORMS 
Pattern 4: Multiple Choice 
<fieldset> 
<legend>Tablets (8 available)</legend> 
<ul> 
<li><!-- Asus Nexus 7 --></li> 
<!-- more options --> 
</ul> 
</fieldset>
FALLING IN LOVE WITH FORMS 
Pattern 4: Multiple Choice 
<fieldset> 
<legend>Tablets <em>(8 available)</em></legend> 
<ul> 
<li><!-- Asus Nexus 7 --></li> 
<!-- more options --> 
</ul> 
</fieldset>
FALLING IN LOVE WITH FORMS 
Pattern 4: Multiple Choice 
<fieldset> 
<legend>Tablets <em>(8 available)</em></legend> 
<ul> 
<li><!-- Asus Nexus 7 --></li> 
<!-- more options --> 
</ul> 
</fieldset> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Pattern 4: Multiple Choice 
<li class=“grouped checkboxes”> 
<fieldset> 
<legend>Tablets <em>(8 available)</em></legend> 
<ul> 
<li><!-- Asus Nexus 7 --></li> 
<!-- more options --> 
</ul> 
</fieldset> 
</li>
FALLING IN LOVE WITH FORMS 
Pattern 5: Related Entry 
Requested Day and Time 
! 
<label for="requested_date">Requested Day</label> 
<select id=“requested_date" name=“requested_date" required=“”> 
<!-- options —> 
</select> 
<label for="requested_time">Requested Time</label> 
<select id="requested_time" name=“requested_time" required=""> 
<!-- options —> 
</select>
FALLING IN LOVE WITH FORMS 
Pattern 5: Related Entry 
<fieldset> 
<legend>Requested Day and Time</legend> 
! 
<label for="requested_date">Requested Day</label> 
<select id=“requested_date" name="requested_date" 
required=“”><!-- options --></select> 
<label for="requested_time">Requested Time</label> 
<select id="requested_time" name=“requested_time" required=""> 
<!-- options --></select> 
! 
</fieldset>
FALLING IN LOVE WITH FORMS 
Pattern 5: Related Entry 
<li class=“grouped date-time-selects”> 
<fieldset> 
<legend>Requested Day and Time</legend> 
! 
<label for="requested_date">Requested Day</label> 
<select id=“requested_date" name="requested_date" 
required=“”><!-- options --></select> 
<!-- continued… --> 
! 
</fieldset> 
</li>
FALLING IN LOVE WITH FORMS 
Pattern 5: Related Entry 
/* Hide the labels in an accessible way */ 
form .date-time-selects label { 
position: absolute; 
height: 1px; 
width: 1px; 
overflow: hidden; 
clip: rect(1px 1px 1px 1px); /* IE6 & IE7 */ 
clip: rect(1px, 1px, 1px, 1px); 
}
FALLING IN LOVE WITH FORMS 
Pattern 6: Multiple Labels 
<li class=“grouped year-month-day-selects”> 
<fieldset> 
<legend>Select a date</legend> 
! 
<label for="month">Month</label> 
<select name="month" id=“month”><!-- options --> </select> 
! 
<!-- continued… --> 
! 
</fieldset> 
</li>
FALLING IN LOVE WITH FORMS 
Pattern 6: Multiple Labels 
<li class=“grouped year-month-day-selects”> 
<fieldset> 
<legend>Select a date</legend> 
! 
<label for="month">Month</label> 
<select name="month" id=“month”><!-- options --> </select> 
! 
<!-- continued… --> 
! 
</fieldset> 
</li>
FALLING IN LOVE WITH FORMS 
Pattern 6: Multiple Labels 
<li class=“grouped year-month-day-selects”> 
<fieldset> 
<legend>Select a date</legend> 
! 
<label for="month">Month</label> 
<select name="month" id=“month”><!-- options --> </select> 
! 
<!-- continued… --> 
! 
</fieldset> 
</li> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Pattern 6: Multiple Labels 
<li class=“grouped year-month-day-selects”> 
<fieldset> 
<legend id=“select_date”>Select a date</legend> 
! 
<label for=“month" id=“month_label”>Month</label> 
<select name="month" id=“month” 
aria-labelledby=“select_date month_label” 
><!-- options --> </select> 
! 
<!-- continued… --> 
</fieldset> 
</li>
FALLING IN LOVE WITH FORMS 
Pattern 6: Multiple Labels 
<li class=“grouped year-month-day-selects”> 
<fieldset> 
<legend id=“select_date”>Select a date</legend> 
! 
<label for=“month" id=“month_label”>Month</label> 
<select name="month" id=“month” 
aria-labelledby=“select_date month_label” 
><!-- options --> </select> 
! 
<!-- continued… --> 
</fieldset> 
</li> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<td></td> 
<th>Poor</th> 
<!-- Headings continue --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th>How would you rate your experience with Foo Bar Title 
from initial contact to closing?</th> 
<td> 
<input type="radio" name="experience" value=“1"> 
</td> 
<!-- etc. --> 
</tr> 
</tbody> 
</table>
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<td></td> 
<th>Poor</th> 
<!-- Headings continue --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th>How would you rate your experience with Foo Bar Title 
from initial contact to closing?</th> 
<td> 
<input type="radio" name="experience" value=“1"> 
</td> 
<!-- etc. --> 
</tr> 
</tbody> 
</table>
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<td></td> 
<th>Poor</th> 
<!-- Headings continue --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th>How would you rate your experience with Foo Bar Title 
from initial contact to closing?</th> 
<td> 
<input type="radio" name="experience" value=“1"> 
</td> 
<!-- etc. --> 
</tr> 
</tbody> 
</table>
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<td></td> 
<th id=“value-1”>Poor</th> 
<!-- Headings continue --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th>How would you rate your experience with Foo Bar Title 
from initial contact to closing?</th> 
<td> 
<input … aria-labelledby=“value-1”> 
</td> 
<!-- etc. --> 
</tr> 
</tbody> 
</table>
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<td></td> 
<th id=“value-1”>Poor</th> 
<!-- Headings continue --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th id=“experience”>How would you rate your experience 
with Foo Bar Title from initial contact to closing?</th> 
<td> 
<input … aria-labelledby=“experience value-1”> 
</td> 
<!-- etc. --> 
</tr> 
</tbody> 
</table>
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<!-- Headings before --> 
<th id=“value-3”>Good</th> 
<!-- Headings after --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th id=“experience”>How would you rate your experience 
with Foo Bar Title from initial contact to closing?</th> 
<!-- values 1 & 2 --> 
<td><input … aria-labelledby=“experience value-3”></td> 
<!-- values 4 & 5 --> 
</tr> 
</tbody> 
</table>
FALLING IN LOVE WITH FORMS 
Pattern 7: The dreaded table 
<table> 
<thead> 
<tr> 
<!-- Headings before --> 
<th id=“value-3”>Good</th> 
<!-- Headings after --> 
</tr> 
</thead> 
<tbody> 
<tr> 
<th id=“experience”>How would you rate your experience 
with Foo Bar Title from initial contact to closing?</th> 
<!-- values 1 & 2 --> 
<td><input … aria-labelledby=“experience value-3”></td> 
<!-- values 4 & 5 --> 
</tr> 
</tbody> 
</table> 
Screen Reader: Chrome Vox
HELPFUL HINT 
Focus on 
making the form 
read naturally 
and easily.
HELPFUL HINT 
You can’t always 
make an interface 
perfect, but you can 
make it usable.
Ok, I think I’m 
getting it, but 
small screens still 
scare me a little.
FALLING IN LOVE WITH FORMS 
Tap-friendly hit targets 
.confirm label, 
.radios label, 
.checkboxes label { 
margin: -1em 0; 
padding: 1em 0; 
}
FALLING IN LOVE WITH FORMS 
Tap-friendly hit targets 
.confirm label, 
.radios label, 
.checkboxes label { 
margin: -1em 0; 
padding: 1em 0; 
}
FALLING IN LOVE WITH FORMS 
No layout before its time 
.form-control { 
clear: both; 
} 
.form-control label, 
.form-control input { 
float: left; 
width: 34%; 
} 
.form-control input { 
width: 63%; 
}
FALLING IN LOVE WITH FORMS 
No layout before its time 
.form-control label, 
.form-control input { 
display: block; 
margin-bottom: .328em; 
}
FALLING IN LOVE WITH FORMS 
No layout before its time 
.form-control label, 
.form-control input { 
display: block; 
margin-bottom: .328em; 
} 
! 
@media only screen and (min-width: 60em) { 
/* Side by Side layout */ 
}
FALLING IN LOVE WITH FORMS 
No layout before its time 
.form-control label, 
.form-control input { 
display: block; 
margin-bottom: .328em; 
} 
! 
@media only screen and (min-width: 60em) { 
/* Side by Side layout */ 
} 
YMQMV
FALLING IN LOVE WITH FORMS 
No layout before its time 
@media only screen and (min-width:30em) { 
! 
form .grouped ul li { 
float: left; 
width: 50%; 
} 
! 
}
FALLING IN LOVE WITH FORMS 
No layout before its time 
@media only screen and (min-width:30em) { 
! 
form .grouped ul li { 
float: left; 
width: 50%; 
YMQMV 
} 
! 
}
Makes sense. 
Could we talk a bit 
about validation?
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p>Fields marked with a * are required.</p> 
<p> 
<label for=“first_name"> 
First Name <abbr title=“required">*</abbr> 
</label> 
<input id="first_name" name="first_name" required> 
</p>
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p>Fields marked with a * are required.</p> 
<p> 
<label for=“first_name"> 
First Name <abbr title=“required">*</abbr> 
</label> 
<input id="first_name" name="first_name" required> 
</p>
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p>Fields marked with a * are required.</p> 
<p> 
<label for=“first_name"> 
First Name <abbr title=“required">*</abbr> 
</label> 
<input id="first_name" name="first_name" required> 
</p> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p>Fields marked with a * are 
<strong id="required">required</strong>.</p> 
<p> 
<label for=“first_name"> 
First Name 
<abbr title=“required” aria-labelledby=“required”>*</abbr> 
</label> 
<input id="first_name" name="first_name" required> 
</p>
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p>Fields marked with a * are 
<strong id="required">required</strong>.</p> 
<p> 
<label for=“first_name"> 
First Name 
<abbr title=“required” aria-labelledby=“required”>*</abbr> 
</label> 
<input id="first_name" name="first_name" required> 
</p> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p tabindex="0">Fields marked with a * are required.</p> 
<p> 
<label for=“first_name"> 
First Name <abbr title=“required">*</abbr> 
</label> 
<input id="first_name" name="first_name" required 
aria-required="true"> 
</p>
FALLING IN LOVE WITH FORMS 
Requiring a field 
<p tabindex="0">Fields marked with a * are required.</p> 
<p> 
<label for=“first_name"> 
First Name <abbr title=“required">*</abbr> 
</label> 
<input id="first_name" name="first_name" required 
aria-required="true"> 
</p> 
Screen Reader: Chrome Vox
HELPFUL HINT 
Focus on 
making the form 
read naturally 
and easily.
FALLING IN LOVE WITH FORMS 
Native validation 
<label for=“email”>Your Email</label> 
<input type=“email” id=“email” name=“email” required> 
We will only use your email address to respond to your message. 
!
FALLING IN LOVE WITH FORMS 
Non-native format validation 
<label for="test">What is 1 + 1?</label> 
<input id="test" type=“number" name=“test” 
pattern=“[0-9]*” 
>
FALLING IN LOVE WITH FORMS 
Non-native format validation 
<label for=“test">Enter three numbers 
followed by two letters</label> 
<input id="test" name=“test” 
placeholder=“e.g. 123ab” 
pattern=“d{3}[a-zA-Z]{2}” 
>
FALLING IN LOVE WITH FORMS 
Non-native format validation 
<label for=“test">Enter three numbers 
followed by two letters</label> 
<input id="test" name=“test” 
placeholder=“e.g. 123ab” 
pattern=“d{3}[a-zA-Z]{2}” 
>
FALLING IN LOVE WITH FORMS 
Custom error messages
FALLING IN LOVE WITH FORMS 
Custom error messages 
var field = document.getElementById(‘test’); 
field.setCustomValidity( ‘My custom error message’ );
FALLING IN LOVE WITH FORMS 
Custom error messages 
var field = document.getElementById(‘test’); 
field.setCustomValidity( ‘My custom error message’ );
github.com/easy-designs/jquery.easy-validation.js
A dead simple 
polyfill for HTML5 
forms & custom 
validation messages.
FALLING IN LOVE WITH FORMS 
Custom error messages 
<label for=“test">Enter three numbers 
followed by two letters</label> 
<input id="test" name=“test” 
placeholder=“e.g. 123ab” 
pattern=“d{3}[a-zA-Z]{2}” 
data-validation-error-empty=“You forgot to enter text here” 
data-validation-error-invalid=“Whoops, that’s not right” 
>
FALLING IN LOVE WITH FORMS 
Custom error messages 
<form … 
data-validation-error-empty=“You forgot to enter text here” 
data-validation-error-invalid=“Whoops, that’s not right” 
> 
! 
<label for=“test">Enter three numbers followed by two letters 
</label> 
<input id="test" name=“test” placeholder=“e.g. 123ab” 
pattern=“d{3}[a-zA-Z]{2}” 
data-validation-error-invalid=“Why not try 111aa?” 
> 
! 
</form>
HELPFUL HINT 
Don’t forget about 
server-side 
validation either.
FALLING IN LOVE WITH FORMS 
Provide a list of errors 
retreats4geeks.com/contact
FALLING IN LOVE WITH FORMS 
Provide a list of errors 
<div role=“alert”> 
<p>There were errors with your form submission:</p> 
<ol> 
<li><a href="#message">Message</a> is a required field</li> 
<li><a href="#name">Name</a> is a required field</li> 
<li><a href="#email">Email</a> is a required field</li> 
</ol> 
</div>
FALLING IN LOVE WITH FORMS 
Provide a list of errors 
<div role=“alert”> 
<p>There were errors with your form submission:</p> 
<ol> 
<li><a href="#message">Message</a> is a required field</li> 
<li><a href="#name">Name</a> is a required field</li> 
<li><a href="#email">Email</a> is a required field</li> 
</ol> 
</div> 
Screen Reader: Chrome Vox
FALLING IN LOVE WITH FORMS 
Provide easy access to them 
<div role=“alert”> 
<p>There were errors with your form submission:</p> 
<ol> 
<li><a href="#message">Message</a> is a required field</li> 
<li><a href="#name">Name</a> is a required field</li> 
<li><a href="#email">Email</a> is a required field</li> 
</ol> 
</div>
FALLING IN LOVE WITH FORMS 
Provide easy access to them 
<label for=“message”> 
Message <abbr title=“required">*</abbr> 
</label> 
<textarea id="message" name="message" required></textarea>
FALLING IN LOVE WITH FORMS 
Provide field-level help 
<li class="text validation-error"> 
<label for=“email">Email <abbr title=“required">*</abbr> 
</label> 
<input id="email" type="email" name="email" 
required=“" aria-required=“true” 
aria-invalid="true" 
aria-describedby=“email-error" 
> 
<strong id="email-error" class=“validation-error-message"> 
Your email address is required</strong> 
</li>
FALLING IN LOVE WITH FORMS 
Provide field-level help 
li.validation-error { 
color: #922026; 
} 
! 
li.validation-error input, 
li.validation-error textarea, 
li.validation-error select { 
border-color: #922026; 
}
FALLING IN LOVE WITH FORMS 
Provide field-level help 
.validation-error label::before { 
content: "x "; 
font-family: Verdana, sans-serif; 
speak: none; /* The future! */ 
}
FALLING IN LOVE WITH FORMS 
Provide field-level help 
.validation-error label::before { 
content: "x "; 
font-family: Verdana, sans-serif; 
speak: none; /* The future! */ 
} 
Screen Reader: Chrome Vox
Forms suck.
can 
a lot less 
Forms suck.
Forms can be… 
easy to build 
predictable 
effortless to use 
and accessible
Thank you! 
! 
@AaronGustafson 
aaron-gustafson.com 
slideshare.net/AaronGustafson

More Related Content

Viewers also liked

Validating UX Strategy Concepts Through Service Design
Validating UX Strategy Concepts Through Service DesignValidating UX Strategy Concepts Through Service Design
Validating UX Strategy Concepts Through Service DesignAshley Halsey Hemingway
 
UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...
UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...
UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...Yury Vetrov
 
9 Secrets of Kano Model
9 Secrets of Kano Model9 Secrets of Kano Model
9 Secrets of Kano ModelGena Drahun
 
3 Управление требованиями в Agile, Story Mapping для формирования баклога про...
3 Управление требованиями в Agile, Story Mapping для формирования баклога про...3 Управление требованиями в Agile, Story Mapping для формирования баклога про...
3 Управление требованиями в Agile, Story Mapping для формирования баклога про...Magneta AI
 
Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014
Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014
Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014Andrew Sikorskiy
 
UX Poland 2014: Y.Vetrov — Applied UX Strategy
UX Poland 2014: Y.Vetrov — Applied UX StrategyUX Poland 2014: Y.Vetrov — Applied UX Strategy
UX Poland 2014: Y.Vetrov — Applied UX StrategyYury Vetrov
 
Why users can't find answers in help material
Why users can't find answers in help materialWhy users can't find answers in help material
Why users can't find answers in help materialTom Johnson
 
CodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуре
CodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуреCodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуре
CodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуреYury Vetrov
 
UXPeople2013: Юрий Ветров — UX-стратегия. Теория и практика
UXPeople2013: Юрий Ветров — UX-стратегия. Теория и практикаUXPeople2013: Юрий Ветров — UX-стратегия. Теория и практика
UXPeople2013: Юрий Ветров — UX-стратегия. Теория и практикаYury Vetrov
 
Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...
Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...
Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...Yury Vetrov
 
User Story Mapping in Practice
User Story Mapping in PracticeUser Story Mapping in Practice
User Story Mapping in PracticeSteve Rogalsky
 
5 Things I Wish I Knew – A Service Design Journey
5 Things I Wish I Knew – A Service Design Journey5 Things I Wish I Knew – A Service Design Journey
5 Things I Wish I Knew – A Service Design JourneyJamin Hegeman
 

Viewers also liked (16)

Writing Great Alt Text
Writing Great Alt TextWriting Great Alt Text
Writing Great Alt Text
 
Validating UX Strategy Concepts Through Service Design
Validating UX Strategy Concepts Through Service DesignValidating UX Strategy Concepts Through Service Design
Validating UX Strategy Concepts Through Service Design
 
Экономическая логика Customer Experience
Экономическая логика Customer Experience Экономическая логика Customer Experience
Экономическая логика Customer Experience
 
UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...
UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...
UXRussia2014: Юрий Ветров ― Burger-Driven Design. Фреймворк Mail.Ru для унифи...
 
9 Secrets of Kano Model
9 Secrets of Kano Model9 Secrets of Kano Model
9 Secrets of Kano Model
 
3 Управление требованиями в Agile, Story Mapping для формирования баклога про...
3 Управление требованиями в Agile, Story Mapping для формирования баклога про...3 Управление требованиями в Agile, Story Mapping для формирования баклога про...
3 Управление требованиями в Agile, Story Mapping для формирования баклога про...
 
Story mapping
Story mappingStory mapping
Story mapping
 
Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014
Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014
Будущее UX методологии и проблемы/«дорожная карта» // RIF'2014
 
UX Poland 2014: Y.Vetrov — Applied UX Strategy
UX Poland 2014: Y.Vetrov — Applied UX StrategyUX Poland 2014: Y.Vetrov — Applied UX Strategy
UX Poland 2014: Y.Vetrov — Applied UX Strategy
 
Why users can't find answers in help material
Why users can't find answers in help materialWhy users can't find answers in help material
Why users can't find answers in help material
 
CodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуре
CodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуреCodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуре
CodeFest2015: Ю.Ветров — От дизайн-команды к дизайн-культуре
 
UXPeople2013: Юрий Ветров — UX-стратегия. Теория и практика
UXPeople2013: Юрий Ветров — UX-стратегия. Теория и практикаUXPeople2013: Юрий Ветров — UX-стратегия. Теория и практика
UXPeople2013: Юрий Ветров — UX-стратегия. Теория и практика
 
Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...
Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...
Design Weekend Ярославль 2014: Юрий Ветров — Продуктовый дизайнер. Современно...
 
From Paths to Sandboxes
From Paths to SandboxesFrom Paths to Sandboxes
From Paths to Sandboxes
 
User Story Mapping in Practice
User Story Mapping in PracticeUser Story Mapping in Practice
User Story Mapping in Practice
 
5 Things I Wish I Knew – A Service Design Journey
5 Things I Wish I Knew – A Service Design Journey5 Things I Wish I Knew – A Service Design Journey
5 Things I Wish I Knew – A Service Design Journey
 

More from Aaron Gustafson

Delivering Critical Information and Services [JavaScript & Friends 2021]
Delivering Critical Information and Services [JavaScript & Friends 2021]Delivering Critical Information and Services [JavaScript & Friends 2021]
Delivering Critical Information and Services [JavaScript & Friends 2021]Aaron Gustafson
 
Adapting to Reality [Guest Lecture, March 2021]
Adapting to Reality [Guest Lecture, March 2021]Adapting to Reality [Guest Lecture, March 2021]
Adapting to Reality [Guest Lecture, March 2021]Aaron Gustafson
 
Designing the Conversation [Beyond Tellerrand 2019]
Designing the Conversation [Beyond Tellerrand 2019]Designing the Conversation [Beyond Tellerrand 2019]
Designing the Conversation [Beyond Tellerrand 2019]Aaron Gustafson
 
Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]
Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]
Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]Aaron Gustafson
 
Progressive Web Apps: Where Do I Begin?
Progressive Web Apps: Where Do I Begin?Progressive Web Apps: Where Do I Begin?
Progressive Web Apps: Where Do I Begin?Aaron Gustafson
 
Media in the Age of PWAs [ImageCon 2019]
Media in the Age of PWAs [ImageCon 2019]Media in the Age of PWAs [ImageCon 2019]
Media in the Age of PWAs [ImageCon 2019]Aaron Gustafson
 
Adapting to Reality [Starbucks Lunch & Learn]
Adapting to Reality [Starbucks Lunch & Learn]Adapting to Reality [Starbucks Lunch & Learn]
Adapting to Reality [Starbucks Lunch & Learn]Aaron Gustafson
 
Conversational Semantics for the Web [CascadiaJS 2018]
Conversational Semantics for the Web [CascadiaJS 2018]Conversational Semantics for the Web [CascadiaJS 2018]
Conversational Semantics for the Web [CascadiaJS 2018]Aaron Gustafson
 
Better Performance === Greater Accessibility [Inclusive Design 24 2018]
Better Performance === Greater Accessibility [Inclusive Design 24 2018]Better Performance === Greater Accessibility [Inclusive Design 24 2018]
Better Performance === Greater Accessibility [Inclusive Design 24 2018]Aaron Gustafson
 
PWA: Where Do I Begin? [Microsoft Ignite 2018]
PWA: Where Do I Begin? [Microsoft Ignite 2018]PWA: Where Do I Begin? [Microsoft Ignite 2018]
PWA: Where Do I Begin? [Microsoft Ignite 2018]Aaron Gustafson
 
Designing the Conversation [Concatenate 2018]
Designing the Conversation [Concatenate 2018]Designing the Conversation [Concatenate 2018]
Designing the Conversation [Concatenate 2018]Aaron Gustafson
 
Designing the Conversation [Accessibility DC 2018]
Designing the Conversation [Accessibility DC 2018]Designing the Conversation [Accessibility DC 2018]
Designing the Conversation [Accessibility DC 2018]Aaron Gustafson
 
Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]Aaron Gustafson
 
The Web Should Just Work for Everyone
The Web Should Just Work for EveryoneThe Web Should Just Work for Everyone
The Web Should Just Work for EveryoneAaron Gustafson
 
Performance as User Experience [AEA SEA 2018]
Performance as User Experience [AEA SEA 2018]Performance as User Experience [AEA SEA 2018]
Performance as User Experience [AEA SEA 2018]Aaron Gustafson
 
Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]Aaron Gustafson
 
Advanced Design Methods 1, Day 2
Advanced Design Methods 1, Day 2Advanced Design Methods 1, Day 2
Advanced Design Methods 1, Day 2Aaron Gustafson
 
Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1Aaron Gustafson
 
Designing the Conversation [Paris Web 2017]
Designing the Conversation [Paris Web 2017]Designing the Conversation [Paris Web 2017]
Designing the Conversation [Paris Web 2017]Aaron Gustafson
 
Exploring Adaptive Interfaces [Generate 2017]
Exploring Adaptive Interfaces [Generate 2017]Exploring Adaptive Interfaces [Generate 2017]
Exploring Adaptive Interfaces [Generate 2017]Aaron Gustafson
 

More from Aaron Gustafson (20)

Delivering Critical Information and Services [JavaScript & Friends 2021]
Delivering Critical Information and Services [JavaScript & Friends 2021]Delivering Critical Information and Services [JavaScript & Friends 2021]
Delivering Critical Information and Services [JavaScript & Friends 2021]
 
Adapting to Reality [Guest Lecture, March 2021]
Adapting to Reality [Guest Lecture, March 2021]Adapting to Reality [Guest Lecture, March 2021]
Adapting to Reality [Guest Lecture, March 2021]
 
Designing the Conversation [Beyond Tellerrand 2019]
Designing the Conversation [Beyond Tellerrand 2019]Designing the Conversation [Beyond Tellerrand 2019]
Designing the Conversation [Beyond Tellerrand 2019]
 
Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]
Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]
Getting Started with Progressive Web Apps [Beyond Tellerrand 2019]
 
Progressive Web Apps: Where Do I Begin?
Progressive Web Apps: Where Do I Begin?Progressive Web Apps: Where Do I Begin?
Progressive Web Apps: Where Do I Begin?
 
Media in the Age of PWAs [ImageCon 2019]
Media in the Age of PWAs [ImageCon 2019]Media in the Age of PWAs [ImageCon 2019]
Media in the Age of PWAs [ImageCon 2019]
 
Adapting to Reality [Starbucks Lunch & Learn]
Adapting to Reality [Starbucks Lunch & Learn]Adapting to Reality [Starbucks Lunch & Learn]
Adapting to Reality [Starbucks Lunch & Learn]
 
Conversational Semantics for the Web [CascadiaJS 2018]
Conversational Semantics for the Web [CascadiaJS 2018]Conversational Semantics for the Web [CascadiaJS 2018]
Conversational Semantics for the Web [CascadiaJS 2018]
 
Better Performance === Greater Accessibility [Inclusive Design 24 2018]
Better Performance === Greater Accessibility [Inclusive Design 24 2018]Better Performance === Greater Accessibility [Inclusive Design 24 2018]
Better Performance === Greater Accessibility [Inclusive Design 24 2018]
 
PWA: Where Do I Begin? [Microsoft Ignite 2018]
PWA: Where Do I Begin? [Microsoft Ignite 2018]PWA: Where Do I Begin? [Microsoft Ignite 2018]
PWA: Where Do I Begin? [Microsoft Ignite 2018]
 
Designing the Conversation [Concatenate 2018]
Designing the Conversation [Concatenate 2018]Designing the Conversation [Concatenate 2018]
Designing the Conversation [Concatenate 2018]
 
Designing the Conversation [Accessibility DC 2018]
Designing the Conversation [Accessibility DC 2018]Designing the Conversation [Accessibility DC 2018]
Designing the Conversation [Accessibility DC 2018]
 
Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]Performance as User Experience [AEADC 2018]
Performance as User Experience [AEADC 2018]
 
The Web Should Just Work for Everyone
The Web Should Just Work for EveryoneThe Web Should Just Work for Everyone
The Web Should Just Work for Everyone
 
Performance as User Experience [AEA SEA 2018]
Performance as User Experience [AEA SEA 2018]Performance as User Experience [AEA SEA 2018]
Performance as User Experience [AEA SEA 2018]
 
Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]
 
Advanced Design Methods 1, Day 2
Advanced Design Methods 1, Day 2Advanced Design Methods 1, Day 2
Advanced Design Methods 1, Day 2
 
Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1Advanced Design Methods 1, Day 1
Advanced Design Methods 1, Day 1
 
Designing the Conversation [Paris Web 2017]
Designing the Conversation [Paris Web 2017]Designing the Conversation [Paris Web 2017]
Designing the Conversation [Paris Web 2017]
 
Exploring Adaptive Interfaces [Generate 2017]
Exploring Adaptive Interfaces [Generate 2017]Exploring Adaptive Interfaces [Generate 2017]
Exploring Adaptive Interfaces [Generate 2017]
 

Recently uploaded

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Falling in Love with Forms [BlendConf 2014]

  • 1. FALLING IN LOVE WITH FORMS Aaron Gustafson @AaronGustafson slideshare.net/AaronGustafson
  • 3. They are incredibly tedious to create.
  • 4. They are undeniably annoying to fill in.
  • 5. They can be frustrating to test.
  • 8. don’t have to Forms suck.
  • 9. can a lot less Forms suck.
  • 10. Forms can be… easy to build predictable effortless to use and accessible
  • 11. It’s all in how you look at them.
  • 12. HELPFUL HINT Break large, complex forms into smaller, simpler, reusable patterns
  • 13. How about a common example? Let’s look at a contact form.
  • 16. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field Your Name <input type=“text” name=“full_name”>
  • 17. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field Your Name <input name=“full_name”>
  • 18. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field Your Name <input name=“full_name”/>
  • 19. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field Your Name <input name=“full_name”>
  • 20. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field <label>Your Name</label> <input name=“full_name”>
  • 21. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name”>
  • 22. FALLING IN LOVE WITH FORMS Pattern 1: Label & Field <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required>
  • 23. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input id=“email” name=“email” required> We will only use your email address to respond to your message.
  • 24. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input id=“email” name=“email” required> We will only use your email address to respond to your message. !
  • 25. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input id=“email” name=“email” required> We will only use your email address to respond to your message. !
  • 26. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required> We will only use your email address to respond to your message. !
  • 27. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required> We will only use your email address to respond to your message. !
  • 28. Browsers ignore what they don’t understand
  • 30. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required> <em> We will only use your email address to respond to your message. </em>
  • 31. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required> <em class=“note”> We will only use your email address to respond to your message. </em>
  • 32. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required aria-describedby=“email-note”> <em class=“note” id=“email-note”> We will only use your email address to respond to your message. </em>
  • 33. FALLING IN LOVE WITH FORMS Pattern 2: Label, Field & Note <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required aria-describedby=“email-note”> <em class=“note” id=“email-note”> We will only use your email address to respond to your message. </em> Screen Reader: Chrome Vox
  • 34. FALLING IN LOVE WITH FORMS Rinse & Repeat <label for=“subject”>Purpose of Your Message</label> <select id="subject" name="subject"> <option>Question/Comment</option> <option>Article Error</option> <option>Website Bug Report</option> <option>Ask the Sherpas a question</option> </select>
  • 35. FALLING IN LOVE WITH FORMS Rinse & Repeat <label for=“message”>Your Message</label> <textarea id="message" name="message"></textarea>
  • 36. FALLING IN LOVE WITH FORMS Buttons <input type=“submit” value=“Send My Message”>
  • 37. FALLING IN LOVE WITH FORMS Buttons <button type=“submit”>Send My Message</button>
  • 38. HELPFUL HINT A button element can contain pretty much anything ! (within reason)
  • 39. FALLING IN LOVE WITH FORMS Buttons <button type="submit" value=“basic"> <h3>Basic Plan</h3> <p>You get 20 <abbr title="gigabytes">GB</abbr> of storage and a single domain name for <strong>$2.99 <abbr title=“per month”>/mo</abbr></strong></p> </button>
  • 40. That new email field looks cool, can we see more of that fancy HTML5 stuff?
  • 41. FALLING IN LOVE WITH FORMS Requesting URLs <label for=“url”>URL</label> <input type=“url” id=“url” name=“url” required aria-describedby=“url-note” > <em class=“note” id=“url-note”> Please provide the URL for the specific page that includes the area you want reviewed. </em>
  • 42. FALLING IN LOVE WITH FORMS Requesting URLs <label for=“url”>URL</label> <input type=“url” id=“url” name=“url” required aria-describedby=“url-note” > <em class=“note” id=“url-note”> Please provide the URL for the specific page that includes the area you want reviewed. </em>
  • 43. FALLING IN LOVE WITH FORMS Requesting URLs <label for=“url”>URL</label> <input type=“url” id=“url” name=“url” required aria-describedby=“url-note” > <em class=“note” id=“url-note”> Please provide the URL for the specific page that includes the area you want reviewed. </em>
  • 44. FALLING IN LOVE WITH FORMS Providing hints <label for=“url”>URL</label> <input type=“url” id=“url” name=“url” required aria-describedby=“url-note” placeholder=“http://www.yoursite.com/specific-page#anchored-section” > <em class=“note” id=“url-note”> Please provide the URL for the specific page that includes the area you want reviewed. </em>
  • 45. HELPFUL HINT Placeholders are just that: placeholders for actual content. They are not labels!
  • 46. FALLING IN LOVE WITH FORMS Providing hints <label for=“url”>URL</label> <input type=“url” id=“url” name=“url” required aria-describedby=“url-note” placeholder=“http://www.yoursite.com/specific-page#anchored-section” > <em class=“note” id=“url-note”> Please provide the URL for the specific page that includes the area you want reviewed. </em>
  • 47. FALLING IN LOVE WITH FORMS Requesting phone numbers <label for="preferred_phone">Preferred Phone</label> <input type="tel" id="preferred_phone" name=“preferred_phone” placeholder="ex. 123-456-7890” >
  • 48. FALLING IN LOVE WITH FORMS Requesting phone numbers <label for="preferred_phone">Preferred Phone</label> <input type="tel" id="preferred_phone" name=“preferred_phone” placeholder="ex. 123-456-7890” >
  • 49. FALLING IN LOVE WITH FORMS Requesting numbers <label for="test">What is 1 + 1?</label> <input id="test" type=“number" name="test">
  • 50. FALLING IN LOVE WITH FORMS Requesting numbers <label for="test">What is 1 + 1?</label> <input id="test" type=“number" name="test">
  • 51. FALLING IN LOVE WITH FORMS Requesting numbers <label for="test">What is 1 + 1?</label> <input id="test" type=“number" name=“test” pattern=“[0-9]*” > <!-- Note: pattern ensures Safari Mobile gives a keypad -->
  • 52. FALLING IN LOVE WITH FORMS Requesting numbers <label for=“volume">How Loud is Spinal Tap?</label> <input id="volume" type=“range" name=“volume” min=“0” max=“11” step=“1” >
  • 53. FALLING IN LOVE WITH FORMS Requesting numbers <label for="test">What is 1 + 1?</label> <input id="test" type=“number" name=“test” pattern=“[0-9]*” min=“0” max=“9” >
  • 54. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="preferred_dates">Preferred Date to Visit</label> <input id="preferred_dates" type="date" name=“preferred_dates" required >
  • 55. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="preferred_dates">Preferred Date to Visit</label> <input id="preferred_dates" type="date" name=“preferred_dates" required >
  • 56. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="preferred_dates">Preferred Date to Visit</label> <input id="preferred_dates" type="date" name=“preferred_dates" required >
  • 57. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="preferred_dates">Preferred Date to Visit</label> <input id="preferred_dates" type="date" name=“preferred_dates" required min=“2014-09-10” max=“2014-12-19” >
  • 58. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="preferred_dates">Preferred Date to Visit</label> <input id="preferred_dates" type="date" name=“preferred_dates" required min=“2014-09-10” max=“2014-12-19” >
  • 59. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="requested_tour_time">Tour Time Requested</label> <input id="preferred_dates" type="time" name=“preferred_dates">
  • 60. FALLING IN LOVE WITH FORMS Requesting dates & times <label for="requested_tour_time">Tour Time Requested</label> <input id="preferred_dates" type="time" name=“preferred_dates">
  • 61. FALLING IN LOVE WITH FORMS Mentalism <label for="state">State</label> <input id="state" name="state" list="states"> <datalist id="states"> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <!-- options continue --> </datalist>
  • 62. FALLING IN LOVE WITH FORMS Mentalism <label for="state">State</label> <input id="state" name="state" list="states"> <datalist id="states"> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <!-- options continue --> </datalist>
  • 63. FALLING IN LOVE WITH FORMS Mentalism <label for="state">State</label> <input id="state" name="state" list="states"> <datalist id="states"> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <!-- options continue --> </datalist>
  • 64. FALLING IN LOVE WITH FORMS Mentalism <label for="state">State</label> <input id="state" name="state" list="states"> <datalist id="states"> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <!-- options continue --> </datalist>
  • 65. FALLING IN LOVE WITH FORMS Mentalism: smart fallbacks <label for=“state" id=“state_label”>State</label> <datalist id=“states”> ! <select name=“state” aria-labelledby=“state_label”> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <!-- options continue --> </select> ! If other, please specify ! </datalist> <input id="state" name="state" list="states"> Based on work by Jeremy Keith: http://adactio.com/journal/4272
  • 66. FALLING IN LOVE WITH FORMS Mentalism: smart fallbacks <label for=“state" id=“state_label”>State</label> <datalist id=“states”> ! <select name=“state” aria-labelledby=“state_label”> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <!-- options continue --> </select> ! If other, please specify ! </datalist> <input id="state" name="state" list="states"> Based on work by Jeremy Keith: http://adactio.com/journal/4272
  • 67. FALLING IN LOVE WITH FORMS Mentalism: smart fallbacks <label for=“state" id=“state_label”>State</label> <datalist id=“states”> ! <select name=“state” aria-labelledby=“state_label”> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <!-- options continue --> </select> ! If other, please specify ! </datalist> <input id="state" name="state" list="states"> Based on work by Jeremy Keith: http://adactio.com/journal/4272
  • 68. FALLING IN LOVE WITH FORMS Mentalism: smart fallbacks <label for=“state" id=“state_label”>State</label> <datalist id=“states”> ! <select name=“state” aria-labelledby=“state_label”> <option>Alabama</option> <option>Alaska</option> <option>Arizona</option> <option>Arkansas</option> <!-- options continue --> </select> ! If other, please specify ! </datalist> <input id="state" name="state" list="states"> Based on work by Jeremy Keith: http://adactio.com/journal/4272
  • 69. Ok, I get it: forms in HTML5 are awesome. But how should we organize our forms?
  • 70. FALLING IN LOVE WITH FORMS Do we divide it up? <div> <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required> </div>
  • 71. FALLING IN LOVE WITH FORMS Do paragraphs make sense? <p> <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required> </p>
  • 72. FALLING IN LOVE WITH FORMS Is it a list of questions? <ol> <li> <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required> </li> </ol>
  • 73. FALLING IN LOVE WITH FORMS Is it a list of questions? form ol, form ul { list-style: none; margin: 0; padding: 0; }
  • 74. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“text”> <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required> </li>
  • 75. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“form-control form-control--text”> <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required> </li>
  • 76. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“text”> <label for=“full_name”>Your Name</label> <input id=“full_name” name=“full_name” required> </li>
  • 77. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“email”> <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required aria-describedby=“email-note”> <em class=“note” id=“email-note”> We will only use your email address to respond to your message. </em> </li>
  • 78. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“select”> <label for=“subject”>Purpose of Your Message</label> <select id="subject" name="subject"> <option>Question/Comment</option> <option>Article Error</option> <option>Website Bug Report</option> <option>Ask the Sherpas a question</option> </select> </li>
  • 79. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“textarea”> <label for=“message”>Your Message</label> <textarea id="message" name=“message"></textarea> </li>
  • 80. FALLING IN LOVE WITH FORMS Control Group Classification <li class=“buttons”> <button type=“submit”>Send My Message</button> </li>
  • 81. Makes sense. What about more complex form constructs?
  • 82. FALLING IN LOVE WITH FORMS Pattern 3: Confirmations <input type=“checkbox” name=“newsletter” value=“yes”> Sign me up for this newsletter
  • 83. FALLING IN LOVE WITH FORMS Pattern 3: Confirmations <input type=“checkbox” name=“newsletter” value=“yes” id=“newsletter”> <label for=“newsletter”>Sign me up for this newsletter</label>
  • 84. FALLING IN LOVE WITH FORMS Pattern 3: Confirmations <label> <input type=“checkbox” name=“newsletter” value=“yes”> Sign me up for this newsletter </label>
  • 85. FALLING IN LOVE WITH FORMS Pattern 3: Confirmations input { /* Styles for most normal input types */ } ! label input { /* Styles for checkbox and radio controls */ }
  • 86. FALLING IN LOVE WITH FORMS Pattern 3: Confirmations <label for=“newsletter”> <input type=“checkbox” name=“newsletter” value=“yes” id=“newsletter”> Sign me up for this newsletter </label>
  • 87. FALLING IN LOVE WITH FORMS Pattern 3: Confirmations <li class=“confirm”> <label for=“newsletter”> <input type=“checkbox” name=“newsletter” value=“yes” id=“newsletter”> Sign me up for this newsletter </label> </li>
  • 88. FALLING IN LOVE WITH FORMS Pattern 4: Multiple Choice Tablets (8 available) ! <label for="asus-nexus-7"> <input type="checkbox" name="device[]" id=“asus-nexus-7"> Asus Nexus 7 </label> ! <!-- more options -->
  • 89. FALLING IN LOVE WITH FORMS Pattern 4: Multiple Choice Tablets (8 available) ! <ul> <li><!-- Asus Nexus 7 --></li> <!-- more options --> </ul>
  • 90. FALLING IN LOVE WITH FORMS Pattern 4: Multiple Choice <fieldset> <legend>Tablets (8 available)</legend> <ul> <li><!-- Asus Nexus 7 --></li> <!-- more options --> </ul> </fieldset>
  • 91. FALLING IN LOVE WITH FORMS Pattern 4: Multiple Choice <fieldset> <legend>Tablets <em>(8 available)</em></legend> <ul> <li><!-- Asus Nexus 7 --></li> <!-- more options --> </ul> </fieldset>
  • 92. FALLING IN LOVE WITH FORMS Pattern 4: Multiple Choice <fieldset> <legend>Tablets <em>(8 available)</em></legend> <ul> <li><!-- Asus Nexus 7 --></li> <!-- more options --> </ul> </fieldset> Screen Reader: Chrome Vox
  • 93. FALLING IN LOVE WITH FORMS Pattern 4: Multiple Choice <li class=“grouped checkboxes”> <fieldset> <legend>Tablets <em>(8 available)</em></legend> <ul> <li><!-- Asus Nexus 7 --></li> <!-- more options --> </ul> </fieldset> </li>
  • 94. FALLING IN LOVE WITH FORMS Pattern 5: Related Entry Requested Day and Time ! <label for="requested_date">Requested Day</label> <select id=“requested_date" name=“requested_date" required=“”> <!-- options —> </select> <label for="requested_time">Requested Time</label> <select id="requested_time" name=“requested_time" required=""> <!-- options —> </select>
  • 95. FALLING IN LOVE WITH FORMS Pattern 5: Related Entry <fieldset> <legend>Requested Day and Time</legend> ! <label for="requested_date">Requested Day</label> <select id=“requested_date" name="requested_date" required=“”><!-- options --></select> <label for="requested_time">Requested Time</label> <select id="requested_time" name=“requested_time" required=""> <!-- options --></select> ! </fieldset>
  • 96. FALLING IN LOVE WITH FORMS Pattern 5: Related Entry <li class=“grouped date-time-selects”> <fieldset> <legend>Requested Day and Time</legend> ! <label for="requested_date">Requested Day</label> <select id=“requested_date" name="requested_date" required=“”><!-- options --></select> <!-- continued… --> ! </fieldset> </li>
  • 97. FALLING IN LOVE WITH FORMS Pattern 5: Related Entry /* Hide the labels in an accessible way */ form .date-time-selects label { position: absolute; height: 1px; width: 1px; overflow: hidden; clip: rect(1px 1px 1px 1px); /* IE6 & IE7 */ clip: rect(1px, 1px, 1px, 1px); }
  • 98. FALLING IN LOVE WITH FORMS Pattern 6: Multiple Labels <li class=“grouped year-month-day-selects”> <fieldset> <legend>Select a date</legend> ! <label for="month">Month</label> <select name="month" id=“month”><!-- options --> </select> ! <!-- continued… --> ! </fieldset> </li>
  • 99. FALLING IN LOVE WITH FORMS Pattern 6: Multiple Labels <li class=“grouped year-month-day-selects”> <fieldset> <legend>Select a date</legend> ! <label for="month">Month</label> <select name="month" id=“month”><!-- options --> </select> ! <!-- continued… --> ! </fieldset> </li>
  • 100. FALLING IN LOVE WITH FORMS Pattern 6: Multiple Labels <li class=“grouped year-month-day-selects”> <fieldset> <legend>Select a date</legend> ! <label for="month">Month</label> <select name="month" id=“month”><!-- options --> </select> ! <!-- continued… --> ! </fieldset> </li> Screen Reader: Chrome Vox
  • 101. FALLING IN LOVE WITH FORMS Pattern 6: Multiple Labels <li class=“grouped year-month-day-selects”> <fieldset> <legend id=“select_date”>Select a date</legend> ! <label for=“month" id=“month_label”>Month</label> <select name="month" id=“month” aria-labelledby=“select_date month_label” ><!-- options --> </select> ! <!-- continued… --> </fieldset> </li>
  • 102. FALLING IN LOVE WITH FORMS Pattern 6: Multiple Labels <li class=“grouped year-month-day-selects”> <fieldset> <legend id=“select_date”>Select a date</legend> ! <label for=“month" id=“month_label”>Month</label> <select name="month" id=“month” aria-labelledby=“select_date month_label” ><!-- options --> </select> ! <!-- continued… --> </fieldset> </li> Screen Reader: Chrome Vox
  • 103. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table
  • 104. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <td></td> <th>Poor</th> <!-- Headings continue --> </tr> </thead> <tbody> <tr> <th>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <td> <input type="radio" name="experience" value=“1"> </td> <!-- etc. --> </tr> </tbody> </table>
  • 105. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <td></td> <th>Poor</th> <!-- Headings continue --> </tr> </thead> <tbody> <tr> <th>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <td> <input type="radio" name="experience" value=“1"> </td> <!-- etc. --> </tr> </tbody> </table>
  • 106. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <td></td> <th>Poor</th> <!-- Headings continue --> </tr> </thead> <tbody> <tr> <th>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <td> <input type="radio" name="experience" value=“1"> </td> <!-- etc. --> </tr> </tbody> </table>
  • 107. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <td></td> <th id=“value-1”>Poor</th> <!-- Headings continue --> </tr> </thead> <tbody> <tr> <th>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <td> <input … aria-labelledby=“value-1”> </td> <!-- etc. --> </tr> </tbody> </table>
  • 108. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <td></td> <th id=“value-1”>Poor</th> <!-- Headings continue --> </tr> </thead> <tbody> <tr> <th id=“experience”>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <td> <input … aria-labelledby=“experience value-1”> </td> <!-- etc. --> </tr> </tbody> </table>
  • 109. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <!-- Headings before --> <th id=“value-3”>Good</th> <!-- Headings after --> </tr> </thead> <tbody> <tr> <th id=“experience”>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <!-- values 1 & 2 --> <td><input … aria-labelledby=“experience value-3”></td> <!-- values 4 & 5 --> </tr> </tbody> </table>
  • 110. FALLING IN LOVE WITH FORMS Pattern 7: The dreaded table <table> <thead> <tr> <!-- Headings before --> <th id=“value-3”>Good</th> <!-- Headings after --> </tr> </thead> <tbody> <tr> <th id=“experience”>How would you rate your experience with Foo Bar Title from initial contact to closing?</th> <!-- values 1 & 2 --> <td><input … aria-labelledby=“experience value-3”></td> <!-- values 4 & 5 --> </tr> </tbody> </table> Screen Reader: Chrome Vox
  • 111. HELPFUL HINT Focus on making the form read naturally and easily.
  • 112. HELPFUL HINT You can’t always make an interface perfect, but you can make it usable.
  • 113. Ok, I think I’m getting it, but small screens still scare me a little.
  • 114. FALLING IN LOVE WITH FORMS Tap-friendly hit targets .confirm label, .radios label, .checkboxes label { margin: -1em 0; padding: 1em 0; }
  • 115. FALLING IN LOVE WITH FORMS Tap-friendly hit targets .confirm label, .radios label, .checkboxes label { margin: -1em 0; padding: 1em 0; }
  • 116. FALLING IN LOVE WITH FORMS No layout before its time .form-control { clear: both; } .form-control label, .form-control input { float: left; width: 34%; } .form-control input { width: 63%; }
  • 117. FALLING IN LOVE WITH FORMS No layout before its time .form-control label, .form-control input { display: block; margin-bottom: .328em; }
  • 118. FALLING IN LOVE WITH FORMS No layout before its time .form-control label, .form-control input { display: block; margin-bottom: .328em; } ! @media only screen and (min-width: 60em) { /* Side by Side layout */ }
  • 119. FALLING IN LOVE WITH FORMS No layout before its time .form-control label, .form-control input { display: block; margin-bottom: .328em; } ! @media only screen and (min-width: 60em) { /* Side by Side layout */ } YMQMV
  • 120. FALLING IN LOVE WITH FORMS No layout before its time @media only screen and (min-width:30em) { ! form .grouped ul li { float: left; width: 50%; } ! }
  • 121. FALLING IN LOVE WITH FORMS No layout before its time @media only screen and (min-width:30em) { ! form .grouped ul li { float: left; width: 50%; YMQMV } ! }
  • 122. Makes sense. Could we talk a bit about validation?
  • 123. FALLING IN LOVE WITH FORMS Requiring a field <p>Fields marked with a * are required.</p> <p> <label for=“first_name"> First Name <abbr title=“required">*</abbr> </label> <input id="first_name" name="first_name" required> </p>
  • 124. FALLING IN LOVE WITH FORMS Requiring a field <p>Fields marked with a * are required.</p> <p> <label for=“first_name"> First Name <abbr title=“required">*</abbr> </label> <input id="first_name" name="first_name" required> </p>
  • 125. FALLING IN LOVE WITH FORMS Requiring a field <p>Fields marked with a * are required.</p> <p> <label for=“first_name"> First Name <abbr title=“required">*</abbr> </label> <input id="first_name" name="first_name" required> </p> Screen Reader: Chrome Vox
  • 126. FALLING IN LOVE WITH FORMS Requiring a field <p>Fields marked with a * are <strong id="required">required</strong>.</p> <p> <label for=“first_name"> First Name <abbr title=“required” aria-labelledby=“required”>*</abbr> </label> <input id="first_name" name="first_name" required> </p>
  • 127. FALLING IN LOVE WITH FORMS Requiring a field <p>Fields marked with a * are <strong id="required">required</strong>.</p> <p> <label for=“first_name"> First Name <abbr title=“required” aria-labelledby=“required”>*</abbr> </label> <input id="first_name" name="first_name" required> </p> Screen Reader: Chrome Vox
  • 128. FALLING IN LOVE WITH FORMS Requiring a field <p tabindex="0">Fields marked with a * are required.</p> <p> <label for=“first_name"> First Name <abbr title=“required">*</abbr> </label> <input id="first_name" name="first_name" required aria-required="true"> </p>
  • 129. FALLING IN LOVE WITH FORMS Requiring a field <p tabindex="0">Fields marked with a * are required.</p> <p> <label for=“first_name"> First Name <abbr title=“required">*</abbr> </label> <input id="first_name" name="first_name" required aria-required="true"> </p> Screen Reader: Chrome Vox
  • 130. HELPFUL HINT Focus on making the form read naturally and easily.
  • 131. FALLING IN LOVE WITH FORMS Native validation <label for=“email”>Your Email</label> <input type=“email” id=“email” name=“email” required> We will only use your email address to respond to your message. !
  • 132. FALLING IN LOVE WITH FORMS Non-native format validation <label for="test">What is 1 + 1?</label> <input id="test" type=“number" name=“test” pattern=“[0-9]*” >
  • 133. FALLING IN LOVE WITH FORMS Non-native format validation <label for=“test">Enter three numbers followed by two letters</label> <input id="test" name=“test” placeholder=“e.g. 123ab” pattern=“d{3}[a-zA-Z]{2}” >
  • 134. FALLING IN LOVE WITH FORMS Non-native format validation <label for=“test">Enter three numbers followed by two letters</label> <input id="test" name=“test” placeholder=“e.g. 123ab” pattern=“d{3}[a-zA-Z]{2}” >
  • 135. FALLING IN LOVE WITH FORMS Custom error messages
  • 136. FALLING IN LOVE WITH FORMS Custom error messages var field = document.getElementById(‘test’); field.setCustomValidity( ‘My custom error message’ );
  • 137. FALLING IN LOVE WITH FORMS Custom error messages var field = document.getElementById(‘test’); field.setCustomValidity( ‘My custom error message’ );
  • 139. A dead simple polyfill for HTML5 forms & custom validation messages.
  • 140. FALLING IN LOVE WITH FORMS Custom error messages <label for=“test">Enter three numbers followed by two letters</label> <input id="test" name=“test” placeholder=“e.g. 123ab” pattern=“d{3}[a-zA-Z]{2}” data-validation-error-empty=“You forgot to enter text here” data-validation-error-invalid=“Whoops, that’s not right” >
  • 141. FALLING IN LOVE WITH FORMS Custom error messages <form … data-validation-error-empty=“You forgot to enter text here” data-validation-error-invalid=“Whoops, that’s not right” > ! <label for=“test">Enter three numbers followed by two letters </label> <input id="test" name=“test” placeholder=“e.g. 123ab” pattern=“d{3}[a-zA-Z]{2}” data-validation-error-invalid=“Why not try 111aa?” > ! </form>
  • 142. HELPFUL HINT Don’t forget about server-side validation either.
  • 143. FALLING IN LOVE WITH FORMS Provide a list of errors retreats4geeks.com/contact
  • 144. FALLING IN LOVE WITH FORMS Provide a list of errors <div role=“alert”> <p>There were errors with your form submission:</p> <ol> <li><a href="#message">Message</a> is a required field</li> <li><a href="#name">Name</a> is a required field</li> <li><a href="#email">Email</a> is a required field</li> </ol> </div>
  • 145. FALLING IN LOVE WITH FORMS Provide a list of errors <div role=“alert”> <p>There were errors with your form submission:</p> <ol> <li><a href="#message">Message</a> is a required field</li> <li><a href="#name">Name</a> is a required field</li> <li><a href="#email">Email</a> is a required field</li> </ol> </div> Screen Reader: Chrome Vox
  • 146. FALLING IN LOVE WITH FORMS Provide easy access to them <div role=“alert”> <p>There were errors with your form submission:</p> <ol> <li><a href="#message">Message</a> is a required field</li> <li><a href="#name">Name</a> is a required field</li> <li><a href="#email">Email</a> is a required field</li> </ol> </div>
  • 147. FALLING IN LOVE WITH FORMS Provide easy access to them <label for=“message”> Message <abbr title=“required">*</abbr> </label> <textarea id="message" name="message" required></textarea>
  • 148. FALLING IN LOVE WITH FORMS Provide field-level help <li class="text validation-error"> <label for=“email">Email <abbr title=“required">*</abbr> </label> <input id="email" type="email" name="email" required=“" aria-required=“true” aria-invalid="true" aria-describedby=“email-error" > <strong id="email-error" class=“validation-error-message"> Your email address is required</strong> </li>
  • 149. FALLING IN LOVE WITH FORMS Provide field-level help li.validation-error { color: #922026; } ! li.validation-error input, li.validation-error textarea, li.validation-error select { border-color: #922026; }
  • 150. FALLING IN LOVE WITH FORMS Provide field-level help .validation-error label::before { content: "x "; font-family: Verdana, sans-serif; speak: none; /* The future! */ }
  • 151. FALLING IN LOVE WITH FORMS Provide field-level help .validation-error label::before { content: "x "; font-family: Verdana, sans-serif; speak: none; /* The future! */ } Screen Reader: Chrome Vox
  • 153. can a lot less Forms suck.
  • 154. Forms can be… easy to build predictable effortless to use and accessible
  • 155. Thank you! ! @AaronGustafson aaron-gustafson.com slideshare.net/AaronGustafson