Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it allowed to use <label> tag without labeled control?

Tags:

html

forms

label

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?

like image 588
Emergency Exit Avatar asked Aug 30 '12 10:08

Emergency Exit


People also ask

What is the correct way of using label tag in HTML?

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.

Is label tag necessary?

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.

Is it necessary to use label in HTML?

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.

What is the purpose of a label tag?

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.


1 Answers

Nope, as per Quentin’s answer.

However, in HTML5, <dl> can be used for generic associations where <label> isn’t appropriate.

like image 143
Paul D. Waite Avatar answered Oct 24 '22 19:10

Paul D. Waite