HTML: how to indicate a required input field by adding a background image 

Joined:
04/09/2007
Posts:
727

November 03, 2007 17:36:24    Last update: January 10, 2011 22:22:43
When rendering an HTML form, it is customary to use an icon to indicate that a field is required. You can render the icon in HTML directly, but it's a lot more convenient to use CSS. Here's the CSS:
label.required {
	background: url(/img/required.gif) left no-repeat;
	padding-left: 14px;
}


And the HTML:
<label class="required">A required field</label>:
<input name="aRequiredField"/>
Share |
| Comment  | Tags
 
Easy email testing with http://www.ximailstop.com