Example Navigation
Example 7: Required response using image
Best Practice Rating: Good
The required image is part of the legend content and the alt attribute content is added to the legend content.
Example Start
You must select at least one item
Select standard pizza toppings
Select premium pizza toppings (extra cost)
Example End
HTML Source Code
<p class="inst"><img src="images/required.png" alt="required" /> You must select at least one item</p>
<fieldset class="group">
<legend>Select standard pizza toppings <img src="images/required.png" alt="you must select at least one item" /> </legend>
<ul class="checkbox">
<li><input type="checkbox" id="cb1" value="cheese" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb1">Cheese</label></li>
<li><input type="checkbox" id="cb2" value="pepperoni" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb2">Pepperoni</label></li>
<li><input type="checkbox" id="cb3" value="sausage" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb3">Sausage</label></li>
<li><input type="checkbox" id="cb4" value="mushrooms" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb4">Mushrooms</label></li>
<li><input type="checkbox" id="cb5" value="onions" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb5">Onions</label></li>
<li><input type="checkbox" id="cb6" value="gpeppers" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb6">Green Peppers</label></li>
</ul>
</fieldset>
<fieldset class="group">
<legend>Select <span class="prem">premium</span> pizza toppings (extra cost)</legend>
<ul class="checkbox">
<li><input type="checkbox" id="cb7" value="proscuitto" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb7">Proscuitto</label></li>
<li><input type="checkbox" id="cb8" value="portobello" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb8">Portobello Mushrooms</label></li>
<li><input type="checkbox" id="cb9" value="ypeppers" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb9">Yellow Peppers</label></li>
<li><input type="checkbox" id="cb10" value="bcheese" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb10">Blue Cheese</label></li>
<li><input type="checkbox" id="cb11" value="shrimps" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb11">Shrimps</label></li>
<li><input type="checkbox" id="cb12" value="sundried" onfocus="parentFocus(event)" onblur="parentBlur(event)"/><label for="cb12">Sun Dried Tomatoes</label></li>
</ul>
</fieldset>
Javascript Source Code
<script type="text/javascript">
//
// Add focus styling to the parent (LI) element of the radio button receiving focus
//
function parentFocus( event ) {
// Get event object if using Internet Explorer
var e = event || window.event;
// Check the object for W3C DOM event object, if not use IE event object to update the class of the parent element
if( e.target )
e.target.parentNode.className = "focus";
else
e.srcElement.parentNode.className = "focus";
}
//
// Remove focus styling from the parent (LI) element of the radio button receiving focus
//
function parentBlur( event ) {
// Get event object if using Internet Explorer
var e = event || window.event;
var node;
// Check the object for W3C DOM event object, if not use IE event object to update the class of the parent element
if( e.target )
e.target.parentNode.className = "";
else
e.srcElement.parentNode.className = "";
}
</script>
CSS Source Code
<style type="text/css">
fieldset.group {
margin: 0;
padding: 0;
margin-bottom: 1.25em;
padding: .125em;
border-style:none;
}
fieldset.group legend {
margin: 0;
padding: 0;
font-weight: bold;
margin-left: 20px;
font-size: 100%;
color: black;
}
ul.checkbox {
margin: 0;
padding: 0;
margin-left: 20px;
list-style: none;
}
ul.checkbox li input {
margin-right: .25em;
}
ul.checkbox li {
border: 1px transparent solid;
}
ul.checkbox li label {
margin-left: ;
}
ul.checkbox li:hover,
ul.checkbox li.focus {
background-color: lightyellow;
border: 1px gray solid;
width: 12em;
}
p.inst {
margin: 0;
padding: 0;
margin-bottom: .75em;
margin-left: 20px;
font-size: 100%;
color: black;
}
span.prem {
font-family:fantasy;
font-style:italic;
letter-spacing: .05em;
}
</style>