HTML DOM Label object

Label object

The Label object represents the HTML <label> element.

Access Label object

You can access the <label> element by using getElementById():

var x = document.getElementById("myLabel");

Try it yourself

Create Label object

You can create a <label> element by using the document.createElement() method:

var x = document.createElement("LABEL");

Try it yourself

Label object properties

Properties Description
control Return the marked control.
form Returns a reference to the form containing the label.
htmlFor Sets or returns the value of the label's for attribute.

Standard properties and events

Label object supports standardsPropertiesandEvents.

Related pages

HTML tutorial:HTML forms

HTML reference manual:HTML <label> tag