<label> Tag Syntax

<body>
   ...
   ... flow content expected ...
   <form id="form-id" method="GET|POST|etc." action="target-URL">
      ...
      ... phrasing content expected ...<label for="field-id">... phrasing content ...
      ... phrasing content ...</label>...
      ...
   </form>
   ...
   ... phrasing content expected ...<label for="field-id" form="form-id">... phrasing content ...
   ... phrasing content ...</label>...
   ...
</body>
Rules for coding HTML label elements

Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.

  1. Code the label element where phrasing content is expected, usually inside a form element.
  2. Begin the label element with a starting <label> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the xmlns attribute on the <html> tag.
  3. Include a for attribute with the id of the input field being labeled, unless that field will be the default one inside the label element.
  4. If the label is for a field on a form that can be submitted but is outside that form element, include a form attribute referencing the form the label is to be associated with.
  5. Include any other attributes on the <label> tag as appropriate.
  6. Inside the label element, between the starting <label> tag and the ending </label> tag, code the inner HTML phrasing content. The content will normally include text content for the label and the input field the label applies to.
  7. End the label element with a matching </label> closing tag.
Content Model
Contents of the label element

The content of the label element can include HTML comments, text content and only those HTML tags that can be used in phrasing content. If there is no for attribute then the label will be associated with the first button, input, keygen, meter, output, progress, select or textarea element inside the label element.