Labeling Form Parts

HTML provides a method for marking up labels so that you can formally link them to the associated element and use them for scripting or other purposes. In the examples so far, you’ve seen that the explanatory information for each form element is inside a label element with a for attribute.

For example, you might have “First Name:” before the text field where the visitor should type his or her first name Image.

Image Marking field labels in a formal way gives you an easy way to identify them in a CSS style sheet. If you use the for attribute ...

Get HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.