Horje

How to add HTML <select> form Attribute with label Tag

A drop-down list located outside a form (but still a part of the form).

Definition and Usage

The form attribute specifies the form the drop-down list belongs to.

The value of this attribute must be equal to the id attribute of a <form> element in the same document.


Browser Support

Syntax

<select form="form_id">

Attribute Values

Value Description
form_id Specifies the form element the <select> element belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document.
index.html
Example: HTML
<form action="/action_page.php" id="carform">
  <label for="fname">Firstname:</label>
  <input type="text" id="fname" name="fname">
  <input type="submit">
</form>

<label for="cars">Choose a car:</label>
<select name="cars" id="cars" form="carform">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

How to add HTML <select> form Attribute with label Tag




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin