Skip to content

Instantly share code, notes, and snippets.

@dylanb
Last active August 29, 2015 14:19
Show Gist options
  • Save dylanb/88771962564e5a87ee2c to your computer and use it in GitHub Desktop.
Save dylanb/88771962564e5a87ee2c to your computer and use it in GitHub Desktop.
Incorrect and correct way to label a group of inputs using ARIA
<!doctype html>
<html>
<head>
<title>Testing Group Labels</title>
</head>
<body>
<a href="#">before</a>
<h2>Wrong Way</h2>
<div role="group" aria-labelledby="selectAdministratorHeader" id="selectAdministrator">
<div>
<h3 id="selectAdministratorHeader">Select an EasyBiz Administrator</h3>
</div>
<div>
<div>To complete enrollment in EasyBiz, a My Account for the administrator is required.</div>
<div>Consider the <a href="#">administrator's responsibilities</a> for determining the best person for the role.</div>
</div>
<div>
<div></div>
</div>
<div>
<div>
<input id="HaveAccount" name="SignInGroup" type="radio" value="HaveMyAccountProfile">
<label for="HaveAccount">Administrator has a My Account profile.</label>
</div>
</div>
<div>
<div>
<input id="NeedAccount" name="SignInGroup" type="radio" value="NeedMyAccountProfile">
<label for="NeedAccount">Administrator needs a My Account profile.</label>
</div>
</div>
</div>
<a href="#">between</a>
<h2>Right Way</h2>
<div role="group" aria-labelledby="selectAdministratorHeaderRight" id="selectAdministratorRight">
<div>
<h3 id="selectAdministratorHeaderRight">Select an EasyBiz Administrator</h3>
</div>
<div>
<div>To complete enrollment in EasyBiz, a My Account for the administrator is required.</div>
<div>Consider the <a href="#">administrator's responsibilities</a> for determining the best person for the role.</div>
</div>
<div>
<div></div>
</div>
<div>
<div>
<input id="HaveAccountRight" name="SignInGroupRight" type="radio" value="HaveMyAccountProfile" aria-labelledby="HaveAccountRightLabel selectAdministratorHeaderRight">
<label id="HaveAccountRightLabel">Administrator has a My Account profile.</label>
</div>
</div>
<div>
<div>
<input id="NeedAccountRight" name="SignInGroupRight" type="radio" value="NeedMyAccountProfile" aria-labelledby="NeedAccountRightLabel selectAdministratorHeaderRight">
<label id="NeedAccountRightLabel">Administrator needs a My Account profile.</label>
</div>
</div>
</div>
<a href="#">between</a>
<h2>Right Way Checkboxes</h2>
<div role="group" aria-labelledby="foodHeader" id="food">
<div>
<h3 id="foodHeader">What food does your Admin eat?</h3>
</div>
<div>
<div>Admins spend a bunch of time, late at night, doing admin-y things. Send them some food!!</div>
</div>
<div>
<div></div>
</div>
<div>
<div>
<label>
<input id="pizza" name="pizza" type="checkbox" aria-labelledby="foodHeader pizzaLabel">
<span id="pizzaLabel">Pizza
</label>
</div>
</div>
<div>
<div>
<label>
<input id="pasta" name="pasta" type="checkbox" aria-labelledby="foodHeader pastaLabel">
<span id="pastaLabel">Pasta
</label>
</div>
</div>
</div>
<a href="#">after</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment