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:


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads