Horje

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

An HTML form with a required drop-down list.

Definition and Usage

The required attribute is a boolean attribute.

When present, it specifies the user is required to select a value before submitting the form.


Browser Support

Syntax

<select required>

index.html
Example: HTML
<label for="cars">Choose a car:</label>

<select name="cars" id="cars" required>
  <option value="">None</option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select> 

Output should be:

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




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