Web Design

(Nancy Kaufman) #1

256


Add a Label..........................................................


2 Within the field’s tag, type
id=”?”, replacing? with a
descriptive identifier for the
field.

1 In your editor, open an HTML
page that contains a form
tag set and at least one form
control.

Add a Label


W


hile simple text placed next to the field can serve as a label for form fields, you should always
wrap the text in an HTML <label> tag. The tag can either be wrapped around both the label

text and the form field, or it can wrap around the text by itself. Either way, you should also add an


ID attribute to the field, and a for attribute to the label, with a value set to the field’s ID. This


creates a logical association between the field and the label, regardless of whether the label tags


include the field or not.


1


2

Free download pdf