HTML <select> form Attribute
Last Updated :
13 Mar, 2024
The form attribute in HTML <select> specifies the dropdown list’s associated form, identified by the id attribute of a <form> element.
Syntax:
<select form="form_id">
Attribute Values:
Name
| Description
|
---|
value
| <option> value is sent on form submission, text displays in dropdown.
|
Example: In this example the <select> element with the form attribute specifying the form it belongs to, allowing course selection.
HTML
<!DOCTYPE html>
<html>
<head>
<title>select Form Attribute</title>
</head>
<body>
<center>
<h2>
HTML <select> 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>
</html>
Output:
HTML form Attribute Example Output
Supported Browsers:
The browser supported by HTML <select>form Attribute are listed below:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...