Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <select> required Attribute

The required attribute on a <select> tag specifies that an item must be selected before submitting the form.

The form cannot be submitted if the value is empty or null.

Example

#

A required attribute on a <select> element.
The dropdown must have a value selected before the form can be submitted.


<form action="/tutorial/action.html">
  <select name="size" required>
    <option value="">-- Select Size --</option>
    <option value="small">Small</option>
    <option value="medium">Medium</option>
    <option value="large">Large</option>
  </select><br />

  <button type="submit">Submit</button>
</form>

Using required

The required attribute specifies that an item must be selected before submitting the form.

As long as the option value is null or is an empty string, the form cannot be submitted.

The required attribute is part of the built-in validation functionality in HTML.


Syntax

<select required>

Browser support

Here is when required support started for each browser:

Chrome
1.0 Sep 2008
Firefox
4.0 Mar 2011
IE/Edge
10.0 Sep 2012
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <select>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides