Example Navigation
Example 4: Text box control labeled using TITLE attribute
Best Practice Rating: Poor
- Text form controls using the
title attribute to label the text box.
- This is a poor practice since it is not part of the HTML specifications to use
title attribute to label form controls
- The
title attribute is used by some developers to improve accessibility since many screen readers will use the attribute if label element markup is not found.
- Using the
title attribute to label form controls is usefule in some limited cases where hidden labeling techniques cannot be used in high density forms layed out in tables.
Example Start
Example End
HTML Source Code
<div class="text">
<div class="label">Name</div>
<input type="text" size="30" name="name" title="Name"/>
</div>
<div class="text">
<div class="label">E-mail</div>
<input type="text" size="25" name="email" title="E-mail"/>
</div>
<div class="text">
<div class="label">Comment</div>
<textarea rows="5" cols="50" name="comment" title="Comment"></textarea>
</div>
CSS Source Code
<style type="text/css">
div.text div.label {
margin: 0;
padding: 0;
margin-left: 20px;
font-size: 100%;
}
div.text input,
div.text textarea {
margin: 0;
padding: 0;
margin-left: 20px;
margin-bottom: 1.25em;
}
</style>