HTML <select> requiredAttribute

HTML select 标签参考手册HTML <select> tag

Example

An HTML form with a required drop-down list:

<form action="demo_form.html">
<select required>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<input type="submit">
</form>

Try it yourself »

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Almost all main browsers do not support the required attribute.


Definition and usage

The required attribute is a boolean attribute.

The required attribute specifies that the user must select a value before submitting the form.


Differences between HTML 4.01 and HTML5

The required attribute is new in HTML5.


Differences between HTML and XHTML

In XHTML, attribute minimization is forbidden, and the required attribute must be defined as <select required="required" />.


Syntax

<select required>


HTML select 标签参考手册HTML <select> tag Other extensions