Example Navigation
Example 9: Required text box using image
Best Practice Rating: Good
- The image "
" used to visually indicate a text box is required is included as part of the label.
- The value of the
alt attribute is "required".
Example Start

Indicates required fields.
Example End
HTML Source Code
<div class="inst">
<img src="images/required.png" alt="required imemail"/> Indicates required fields.
</div>
<div class="text">
<label for="name">Name <img src="images/required.png" alt="required"/></label>
<input type="text" size="30" name="name" id="name"/>
</div>
<div class="text">
<label for="email">E-mail <img src="images/required.png" alt="required"/></label>
<input type="text" size="25" name="email" id="email"/>
</div>
<div class="text">
<label for="comment">Comment <img src="images/required.png" alt="required"/></label>
<textarea rows="5" cols="50" id="comment" name="comment"></textarea>
</div>
CSS Source Code
<style type="text/css">
div.inst {
margin: 0;
padding: 0;
margin-left: 20px;
margin-bottom: 1em;
}
div.text label {
margin: 0;
padding: 0;
margin-left: 20px;
display: block;
font-size: 100%;
}
div.text input,
div.text textarea {
margin: 0;
padding: 0;
margin-left: 20px;
margin-bottom: .5em;
display: block;
font-size: 100%;
}
input:active,
input:focus,
input:hover,
textarea:active,
textarea:focus,
textarea:hover {
background-color: lightyellow;
border-color: yellow;
}
</style>