Rachel Shearer
Rachel Shearer
Screen readers and magnifiers allow the user to explore both static text and interactive elements.
Here's an example web form to demonstrate:
<nav>, <header>, and
<h1> are useful here.
The plain in rain stays mainly in the Spain
<blockquote>
The <span>plain</span><span>in</span><span>rain</span>
<span>stays mainly in the </span><span>Spain</span>
</blockquote>
<span onclick="">... ⇒ <a href="">... <div onclick="">... ⇒ <button onclick="">...
<div>Click on this button:
<div class="custombutton" onclick="alert('sent!')">Send</div></div>
<div>Click on this button:
<button class="custombutton" onclick="alert('sent!')">Send</button></div>
<label> is perfect for form elements.
<label for="firstname">First name:</label> <input type="text" id="firstname"/>
alt attribute:
alt text.
<img src="chart.png" alt="[description]">
<img src="bullet35648.gif" alt="">
<input type="text" id="user"> <input type="password" id="password"> <img src="../images/901d3n94t3.jpg" /> <br> <span class="label_left">User Name</span> <span class="label_right">PIN</span> <br><button>Send</button>
<input type="text" id="user_correct"> <input type="password" id="password_correct"> <img src="../images/901d3n94t3.jpg" alt="Bridge Security Image"/> <br> <label for="user_correct" class="label_left">User Name</label> <label for="password_correct" class="label_right">PIN</label> <br><button>Send</button>
<script>
function confirm() {
$('ink_dialog').style.display = 'block';
$('dialog_live').style.backgroundColor = 'gray';
}
function closeDialog() {
$('ink_dialog').style.display = 'none';
$('dialog_live').style.backgroundColor = 'white';
}
</script>
<div id="ink_dialog" class="dialog">
<p>Are you sure you can afford it?</p>
<button id="ok" onclick="closeDialog()">OK</button>
<button id="cancel" onclick="closeDialog()">Cancel</button>
</div>
<button id="confirm" onclick="confirm()">
Buy More Printer Ink
</button>
<script>
function confirm_correct() {
$('ink_dialog_correct').style.display = 'block';
$('ok_correct').focus();
$('dialog_correct').style.backgroundColor = 'gray';
var lastFocus = $('ok_correct');
var listener = function(e) {
window.setTimeout(function() {
if (e.target != $('ok_correct') && e.target != $('cancel_correct'))
{
lastFocus.focus();
} else {
lastFocus = e.target;
}
}, 0);
};
document.addEventListener('focus', listener, true);
$('ok_correct').addEventListener('click', function(e) {
$('ink_dialog_correct').style.display = 'none';
$('dialog_correct').style.backgroundColor = 'white';
document.removeEventListener('focus', listener, true);
$('confirm_correct').focus();
}, false);
$('cancel_correct').addEventListener('click', function(e) {
$('ink_dialog_correct').style.display = 'none';
$('dialog_correct').style.backgroundColor = 'white';
document.removeEventListener('focus', listener, true);
$('confirm_correct').focus();
}, false);
}
</script>
<div id="ink_dialog_correct" class="dialog" role="dialog">
<p>Are you sure you can afford it?</p>
<button id="ok_correct">OK</button>
<button id="cancel_correct">Cancel</button>
</div>
<button id="confirm_correct" onclick="confirm_correct()">
Buy More Printer Ink
</button>
div soup. Now what?
<div class="addToCircles_widget">
<span class="label">Add to circles</span>
</div>
<!-- The entire rest of the DOM is here -->
<div class="addToCircles_dropdown">
<div>1</div><div class="check"></div><span>Friends</span>
<div>2</div><div class="check"></div><span>Family</span>
<div>0</div><div class="check"></div><span>Acquaintances</span>
<div>2</div><div class="check"></div><span>Following</span>
<div class="createNew">Create new circle</div>
</div>
tabindex:
<!-- Natural tab order --> <div onclick="" tabindex="0">Clicky 1</div> <!-- Custom tab order --> <div onclick="" tabindex="7">Clicky 2</div> <!-- Focusable but not in tab order. This is useful when hiding focusable controls from sighted and keyboard-only users --> <div onclick="" tabindex="-1">Clicky 3</div>
element.focus()<div id="reply_icon"
tabindex="0"
onclick="reply()"
onkeydown="return onReplyKeydown(event)">Reply</div>
<script>
function onReplyKeydown(event) {
if (event.keyCode == 32 || event.keyCode == 13) // Space / Enter
reply();
}
</script>
tabindex="0"
<div class="addToCircles_widget" tabindex="0"> <span class="label" >Add to circles</span></div>
dialog.$('firstFocusableElt').focus();
role attribute to indicate that a generic tag is playing the role of a standard
widget like a button.
<div tabindex="0" role="button">Send</div>
<div tabindex="0" role="menuitem">Paste</div>
<section role="search">Search this Site ...</section>
<div tabindex="0" role="checkbox" aria-checked="true">
aria-live identifies dynamic content on a page.
aria-live is added to elements that will be updated and describes the type of
updates the element receives.
<div class="addToCircles_widget" tabindex="0" role="button"> <span class="label" >Add to circles</span></div>
<div class="circlePicker" role="dialog">
<div class="check" role="checkbox" aria-checked="false">