HTML 5 Notes For Professional Chapter 22

Chapter 22: Label Element

AttributesDescription
forReference to the target ID Element. I.e: for=”surname”
formHTML5, [Obsolete] Reference to the form containing the Target Element. Label elements are expected within a
Element. If the form=”someFormId” is provided this allows you to place the Label anywhere in the document.

About Label

The element is used to reference a form action element. In the scope of User Interface it’s used to ease the target / selection of elements like Type radio or checkbox.

as wrapper

It can enclose the desired action element

(Clicking on the text the target input will toggle it’s state / value)

as reference

Using the for attribute you don’t have to place the control element as descendant of label – but the for value must
match it’s ID



Note

Don’t use more than one Control Element within a element

Basic Use

Simple form with labels…

Version ≥ 5
GoalKicker.com – HTML5 Notes for Professionals 66

Pin It on Pinterest

Share This