Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

HTML <option> Tag

  • Difficulty Level : Easy
  • Last Updated : 02 Mar, 2021

The <option> tag in HTML is used to choose an option from a Drop-Down menu. This tag can be used with or without any attributes and needed value can be sent to the server. The group of options can be created using <optgroup> Tag. It creates a group of related menu items.

Syntax: 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

<option> Contents... </option>

Attributes: The <option> tag contains four attributes which are listed below: 

  • disabled: This attribute contains the value disabled which represents the option is disabled.
  • label: This attribute contains the text value which represents the shorted label for the option.
  • selected: This attribute contains the value selected which represents the item that is pre-selected when the browser loaded.
  • value: This attribute contains the value text sent to the server.

Example 1: 



HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML option Tag</h2>
    <select>
        <!-- option tag starts -->
            <option>Choose an option</option>
            <option value="html">HTML</option>
            <option value="java">JAVA</option>
            <option value="C++">C++</option>
            <option value="php">PHP</option>
            <option value="perl">PERL</option>
        <!-- option tag ends -->
        </select>
</body>
  
</html>

Output: 
 

Example 2: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML option Tag</h2>
    <strong>Select City<br></strong>
    <select>
        <!-- option tag starts -->
            <option>Allahabad</option>
            <option>Pryagraj</option>
            <option>Jaipur</option>
            <option>Noida</option>
        <!-- option tag ends     -->
        </select>
</body>
  
</html>

Output: 
 

Supported Browsers: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera



My Personal Notes arrow_drop_up
Recommended Articles
Page :