<datalist>


HTML <datalist> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>
	
<form action="demo-form.php" method="get">
<input list="browsers" name="browser">
<datalist id="browsers">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist>
<input type="submit">
</form>

<p><strong>注意:</strong> Internet Explorer 9(更早IE版本),Safari不支持 datalist 标签。</p>

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

IE 10, Firefox, Opera and Chrome support< datalist> tag.

Note: IE 9 and earlier versions of IE and Safari do not support the <datalist> tag.


Tag definition and usage instructions

<datalist> tag specifies a list of possible options for the <input> element.

The<datalist> tag is used to provide "auto-complete" features for the <input> element. The user will see a drop-down list with predefined options that will serve as the user's input data.

Please use the list attribute of the <input> element to bind the <datalist> element.


Differences between HTML 4.01 and HTML5

The<datalist> tag is a new tag in HTML5.


Global attributes

<datalist> tag supports HTML global attributes.


Event attributes

<datalist> tag supports HTML event attributes.