<select> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:select

Introduction

The select element creates lists of options.

The select Element summary

Item Value
Element: select
Local Attributes:name, disabled, form, size, multiple, autofocus, required
Contents:option and optgroup elements
Tag Style: Start and end tag
New in HTML5?No
Changes in HTML5: The form, autofocus and required attributes are new in HTML5

The size attribute sets how many choices to show to the user.

If the multiple attribute is applied, the user is able to select more than one value.

Using the select and option Elements

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <form method="post" action="http://example.com/form"> 
         <input type="hidden" name="recordID" value="1234"> 
         <p> 
            <label for="name">
                Name: <!--  w ww  .  ja v  a 2s. c o m-->
               <input value="java2s.com" id="name" name="name"> 
            </label> 
         </p> 
         <p> 
            <label for="password">
                Password: 
               <input type="password" placeholder="Min 6 characters" id="password" name="password"> 
            </label> 
         </p> 
         <p> 
            <label for="fave">
                Favorite Fruit: 
               <select id="fave" name="fave"> 
                  <option value="CSS" selected label="CSS">CSS</option> 
                  <option value="HTML" label="HTML">HTML</option> 
                  <option value="Oracle" label="Oracle">Oracle</option> 
                  <option value="Typescript" label="Typescript">Typescript</option> 
               </select> 
            </label> 
         </p> 
         <input type="submit" value="Submit"> 
      </form>  
   </body>
</html>

Related Tutorials