A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-label-form-attribute/ below:

HTML <label> form Attribute - GeeksforGeeks

HTML <label> form Attribute

Last Updated : 11 Jul, 2025

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 Supported Browsers

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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4