SELECT tag in HTML

68 - 01-Oct-2024
Introduction

The select tag is more often used to collect the input from the user where the input should be from some particular list or options.

The syntax for <select> tag is as follows

<select>
     <option>Item1</option>
     <option>Item2</option>
     <option>Item3</option>
</select>

Output

<select> tag with <optgroup>
optgroup is used to define the groups between the list of options displayed  in the <select> tag.

The syntax for <select> tag with <optgroup>

<select>
     <optgroup label="Airbus">
          <option>320</option>
          <option>330</option>
          <option>380</option>
     </optgroup>
     <optgroup label="Boeing">
          <option>747</option>
          <option>777</option>
          <option>737</option>
     </optgroup>
</select>

Output :

To provide some particular value we provide value attribute to the <option> tag as shown below
<option value="747">Boeing 747</option>

Comments
Load more comments.
Please Login or Sign up to comment.

Search Gyanva

Press "Enter" to search.

More from Publication

What we offer ?

We offer you a platform to publish your experience, knowledge and research with rest of the world. All you need is to sign up and create your own publication on Gyanva.
logo
facebook youtube