Open In App

HTML <label> form Attribute

Last Updated : 12 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML <label> form Attribute is used to specify the form to which the label belongs, associating it with a specific input element.

Syntax:

<label form="form_id"> 

Attribute Values:

The form attribute in HTML’s <label> tag specifies the id of the <form> element to which the label belongs.

HTML <label> form Attribute Examples

Example: Here is the basic implementation of HTML <label> form Attribute.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML label form Attribute
    </title>
</head>

<body style="text-align:center">
    <form action="#" method="get" id="GFG_form">
        <!-- Starts label tag from here -->
        <label for="student">
            Student
        </label>

        <input type="radio" 
               name="Occupation" 
               id="student" 
               value="student">
               <br>

        <label for="business">
            Business
        </label>

        <input type="radio" 
               name="Occupation" 
               id="business" 
               value="business">
               <br>
    </form>

    <label for="other" 
           form="GFG_form">
           Other
    </label>
</body>

</html>

Output:

html-label-form-attribute-example

HTML Label form attribute

Supported Browsers

The browser supported by <label> form Attribute are listed below:


Similar Reads

HTML | aria-label attribute
The aria-label helps define a string and provides additional information about the structure of the document for users using assistive technology. In most cases, arial-label is used to replace an existing label with more precise information. However, we should be careful while using aria-label as it does not work with all HTML elements. The aria-la
2 min read
HTML &lt;label&gt; for Attribute
The HTML &lt;label&gt; for Attribute is used to specify the type of form element a label is bound to. Syntax: &lt;label for="element_id"&gt; Attribute Values: It contains the value i.e element_id which specify the id of the element that the label is bound to. Example: This Example that illustrates the use of for attribute in &lt;label&gt; element.
1 min read
HTML | &lt;track&gt; label Attribute
The HTML &lt;track&gt; label Attribute is used to specify the label of the text track. Syntax: &lt;track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English"&gt; Attribute Values: label: It specify the label of the text track. Example: C/C++ Code &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html&amp;gt; &amp;lt;head&amp;gt; &amp;lt;style
1 min read
HTML | &lt;option&gt; label Attribute
The HTML option label Attribute is used to specify the text value which represents the shorted label for option. The shortest version will be displayed in the drop-down list. Syntax: &lt;option label="text"&gt; Attribute Values: It contains single value text which specify the shorter version for an option. Below example illustrates the use of label
1 min read
HTML | &lt;optgroup&gt; label Attribute
The HTML optgroup label Attribute is used to specify a label for an &lt;optgroup&gt; Element. Syntax: &lt;optgroup label="text"&gt; Attribute Values: It contains the value i.e text which specify the description for a optgroup Element. Example: &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;HTML &lt;optgroup&gt; label Attribute &lt;/ti
1 min read
HTML &lt;menuitem&gt; label Attribute
The HTML &lt;menuitem&gt; label attribute is used to specify the text value which represents the name of command or menuitem. Syntax: &lt;menuitem label="text"&gt; Attribute Values: It contains a single value that defines a shorter description. Example: Below code illustrates the use of label attribute with the &lt;menuitem&gt; tag. C/C++ Code &lt;
1 min read
HTML &lt;menu&gt; label Attribute
The HTML &lt;menu&gt; label Attribute is used to specify a text value that indicates the visible label name of the menu element Although, this attribute is also used to specify the name of the menu items inside the menu. Syntax: &lt;menu label="text"&gt; Note: This attribute has been deprecated and is no longer used. Attribute Values text: It conta
1 min read
What is the use of label Attribute in HTML ?
The "label" attribute in HTML is used within the &lt;label&gt; tag to associate a label with form elements such as input fields, select boxes, and "textareas". This association improves accessibility and usability by providing a clear and clickable label for form controls, enhancing the overall user experience, and facilitating interaction with web
1 min read
HTML label Attribute
The HTML label Attribute is used to specify the title of the Text Track. The title of the Text Track is used by the browser when listing available text tracks. It is used in &lt;track&gt; element.  Syntax: &lt;track label="English"&gt; HTML label Attribute Supported Tags: &lt;track&gt;&lt;option&gt;&lt;optgroup&gt;&lt;menu&gt;&lt;menuitem&gt;HTML l
1 min read
HTML DOM Label form Property
The HTML DOM Label form Property is used for returning the reference to the form containing the Label Element. It is read-only Property that returns a form object on success. Syntax: labelObject.form Return Value: It returns a reference that contains the label and null if the label is not in the form returns a form. Example: In this example, we wil
1 min read