Friday, 30 December 2011

HTML5 - list Attribute

list Attribute

The list attribute specifies a datalist for an input field. A datalist is a list of options for an input field.
Note: The list attribute works with the following <input> types: text, search, url, telephone, email, date pickers, number, range, and color.

Syntax

Webpage: <input type="url" list="url_list" name="link" />
<datalist id="url_list">
<option label="W3Schools" value="http://css3-xhtml.blogspot.com" />
<option label="Google" value="http://www.google.com" />
<option label="Microsoft" value="http://html5-demo.blogspot.com" />
</datalist> 

Example

  <!DOCTYPE html>
<html>
<body>

<form action="demo_form.asp" method="get">
Webpage: <input type="url" list="url_list" name="link" />
<datalist id="url_list">
<option label="css3-xhtml" value="http://css3-xhtml.blogspot.com" />
<option label="Google" value="http://www.google.com" />
<option label="html5-demo" value="http://html5-demo.blogspot.com" />
</datalist>
<input type="submit" />
</form>

</body>
</html>

No comments:

Post a Comment