TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

HTML option Tag

HTML option Tag with html tutorial, tags, anchor, img, div, entity, textarea, marquee, p tag, heading tag, h1, h2, table, formatting, attribute, elements, ol, ul, Input Types, block element tag, inline element tag, html tags, phrase tag, head, body, form, lists, symbols etc.

<< Back to HTML

HTML <option> tag

HTML <option> tag is used to define options in a dropdown list within <select> or <datalist> element. A dropdown list must have at least one <option> element.

The related <option> of a dropdown list can be grouped using <optgroup> element which helps to understand a large list.

Tips: The <option> tag can be used without any attribute, but it should be used with value attribute which specifies what send to the server.

Syntax

   <option value="">.....</option>

Following are some specifications about the HTML <option> tag

Display Inline
Start tag/End tag Both Start and End tag
Usage Forms and Inputs

Example

<!DOCTYPE html>
<html>
<head>
	<title>Option Tag</title>
	<style>
		body{
			text-align: center;}
	 </style>
</head>
<body>
 <h2>Example of option tag</h2>
 <form>
 	<select>
 		<option>-------Select Your Favorite Color----------</option>
 		<option value="yellow" style="color: violet;">Violet</option>
 		<option value="white" style="color: blue;">Blue</option>
 		<option value="black" style="color: black;">Black</option>
 		<option value="green" style="color: green;">green</option>
 		<option value="red" style="color: red;">Red</option>
 	</select>
 </form>
</body>
Test it Now

Output:

HTML option tag

Attribute:

Tag-specific attributes:

Attribute Value Description
disabled disabled If it is set then that option will be disabled.
label text It defines the name for the list item.
selected selected If it is set, then it will be selected by default in the list.
value text It specifies the data which is sent to the server.

Global attribute:

HTML <option> tag supports the global attributes in HTML

Event attribute:

HTML <option> tag supports the event attributes in HTML.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<option>YesYesYesYesYes
Next TopicHTML output Tag




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf