I need to show in a page a list of, let's say, person's properties that should be rendered more or less as follow:
name: Name
date: 1/1/2000
other: Other
Reading the doc they say:
The LABEL element may be used to attach information to controls.
So, is it the right tag to encompass the names of the properties like name, date...
even if there's not an <input>
to associate with?
The <label> tag can be used in two ways: Firstly, use <label> tag by providing the <input> and id attribute. The <label> tag needs a for attribute whose value is the same as input id. Alternatively, <input> tag use directly inside the <label> tag.
The HTML Label tag can be associated to a form-control either by nesting the control within it or by matching the value of the label's for attribute to the value of a control's id attribute. The Label tag is necessary to showcase what the field represents on the form you are creating and ultimately displaying.
When writing in HTML, the <label> tag is used to create labels for items in a user interface. Used within <input> tags on a form, the <label> tag is additionally useful because it extends the clickable area of control elements, like buttons.
The <label> tag is used to specify a label for an <input> element of a form. It adds a label to a form control such as text, email, password, textarea etc. It toggles the control when a user clicks on a text within the <label> element.
Nope, as per Quentin’s answer.
However, in HTML5, <dl>
can be used for generic associations where <label>
isn’t appropriate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With