HTML5 option tag, Example of <option>tag.


 

HTML5 option tag, Example of <option>tag.

In this section, you will see the use of <option>tag of HTML5.

In this section, you will see the use of <option>tag of HTML5.

HTML5 option tag, Example of <option> tag.

Here, you will see the use of <option> tag in HTML5. The <option> tag is used for providing option for drop-down list or selection list. Every thing presents in option tag will be display in drop down list. It is like a child of select tag , datalist, and optgroup tag. The <option> tag can be used without any attributes.

Attribute of option:
Attribute provides significant information about the option tag for the browser. There are following attributes......

Attributes Value Description
disabled disabled or empty Element does not receive focus of user.
selected selected or empty option automatically selected.
 label  string Define label for option.
value string Initial value of option.

Declaration Syntax :

Declaration syntax of <option> in HTML5.

                         <option attributes> Text </option >

Example of <option> in HTML5:

Code:
option_Tag.html
<!DOCTYPE html >
<html >
<head>
<title>Title of document</title>
</head>
<body>
<p><strong>option</strong><b> tag Example.</b></p>
<p><b>Implementation of &lt;option&gt; in HTML5.</b></p>
<select style="width: 139px">
<option></option>
<option>C</option>
<option>C++</option>
<option>JAVA</option>
<option disabled>PHP</option>
</select>
</body>
</html>
Output:

Download this code

Difference Between HTML5 and HTML4.01:

The <option> tag is available in both HTML5 and HTML4.01.

Ads