html tutorial - Select <select>-tag in HTML - html5 - html code - html form



select tag in html

Learn html - html tutorial - select tag in html - html examples - html programs

  • The <select> tag used to create a drop-down list.
  • The <option> tag used to specify the options in the drop-down list.
  • <select> tag belongs to Flow content, Phrasing content, Interactive content, Listed, Labelable, Resettable, and Submittable form-associated element.
  • <select> tag supports Global Attributes and Event Attributes.

Syntax for <select> tag:

<select><option>Content HERE….</select></option>

Differences between HTML 4.01 and HTML5 for <select> tag:

HTML 4.01

  • HTML4 <select> tag does not support the following attributes autofocus, form and required.

HTML5

  • HTML5 <select> tag has some new attributes.

Sample Coding for <select> tag:

Tryit<!DOCTYPE html>
<html >
    <head>
        <title>Wikitechy select  Tag</title>
    </head>
    <body>
        Select Tutorial:
        <select>
            <option value=”html”>WikitechyHTML</option>
            <option value=”css”>WikitechyCSS</option>
            <option value=”php”>WikitechyPHP</option>
        </select>
    </body>
</html>

Code Explanation for <select> tag:

code explanation for select tag

  1. <select> tag used to display a drop-down list.
  2. <option> tag used to specify the list of content.

Output of <Select> tag:

output for select tag

  1. The output displays the “WikitechyHTML”, “WikitechyCSS”, and “WikitechyPHP” as a drop-down list.

Attribute List:

Attribute Value HTML4 HTML5 Description
autofocus autofocus No Yes Specifies that the drop-down list should automatically get focus when the page loads
disabled disabled Yes Yes Specifies that a drop-down list should be disabled
form form_id No Yes Defines one or more forms the select field belongs to
multiple multiple Yes Yes Specifies that multiple options can be selected at once
name name Yes Yes Defines a name for the drop-down list
required required No Yes Specifies that the user is required to select a value before submitting the form
size number Yes Yes Defines the number of visible options in a drop-down list

Browser Support for <select> tag:

Yes Yes Yes Yes Yes

Related Searches to select tag in html