TheDeveloperBlog.com

Home | Contact Us

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

HTML optgroup Tag

HTML optgroup 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 <optgroup> tag

HTML <optgroup> tag is used to group related <options> in a drop down list within <select> element.

Using <optgroup> tag with <select> makes easier to access the dropdown list especially if list has large number of options.

Syntax

<optgroup label=" ">........</optgroup>

Following are some specifications about the HTML <optgroup> tag

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

Example

<!DOCTYPE html>
<html>
<head>
	<title>Optgroup Tag</title>
	<style>
		body{
		    text-align: center;
		}
		select{
	                  font-size:20px; 
                                  font-weight:bold; 
                                  color:green; 
		}
	</style>
</head>
<body>
<h2>Example of optgroup tag</h2>
<label>Select your favourite brand</label><br>
<select>
          <optgroup label="Laptop Maufacturur">
	 	<option value="dell">Dell</option>
	 	<option value="hp">HP</option>
	 	<option value="lenovo">Lenovo</option>
	 	<option value="acer">Acer</option>
	 </optgroup>
         <optgroup label="Mobile Manufacturer">
	 	<option value="apple">Apple</option>
	 	<option value="nokia">Nokia</option>
	 	<option value="samsung">Samsung</option>
	 	<option value="coolpad">Coolpad</option>	 
            </optgroup>
</select>
</body>	
</html>
Test it Now

Output:

HTML optgroup tag

Attribute:

Tag-specific attributes:

Attribute Value Description
disabled disabled If it is set then options of that optgroup will be disabled.
label text It defines the label for the group which will be displayed in the drop-down list. It is required attribute.

Global attribute:

HTML <optgroup> tag supports the global attributes in HTML

Event attribute:

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

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<optgroup>YesYesYesYesYes
Next TopicHTML option 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