HTML <select> form Attribute

Last Updated : 26 May, 2026

The form attribute is used to associate a <select> element with a specific form. It allows the dropdown menu to be connected to a form even if it is placed outside the <form> tag.

  • Links the <select> element to a form using the form’s id.
  • Allows dropdown elements to exist outside the <form> element.
  • Helps in creating flexible and organized form layouts.

Syntax:

<select form="form_id">

Attribute Values: The form attribute contains a value called form_id, which specifies the id of the <form> element the <select> belongs to.

Example: <select> element with the form attribute specifying the form it belongs to, allowing course selection.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
    <head>
        <title>select Form Attribute</title>
    </head>
<!--Driver Code Ends-->

    <body>
        <center>
            <h2>
                HTML &lt;select&gt; form Attribute
            </h2>
            Select your preferred course from the
            drop-down list:
            <br />
            <select
                form="myGeeks"
                id="myCourses"
                autofocus
            >
                <option value="C++">c++</option>
                <option value="Placement">
                    Placement
                </option>
                <option value="Java">Java</option>
                <option value="Python">
                    Python
                </option>
            </select>
            <br /><br />
            <form id="myGeeks">
                <input type="submit" />
            </form>
        </center>
    </body>

<!--Driver Code Starts-->
</html>

<!--Driver Code Ends-->
Comment