html tutorial - selected Attribute in HTML - html5 - html code - html form
Learn html - html tutorial - Selected attribute in html - html examples - html programs
- The selected attribute defines that an option has been pre-selected though the page loads.
- The selected attribute is a Boolean attribute.
- The pre-selected option will be selected by default in the drop-down list.
Syntax for selected attribute in HTML:
Sample Coding for selected Attribute in HTML:
Code Explanation for selected Attribute in HTML:
- <option> tag is used to define the list of options in a select list.
- The value attribute is used to set the value for the specified <option>.
- The selected attribute is used to pre-select a value by default on page load.
Output for selected Attribute in HTML:
- The output shows that the <option> JAVA has been pre-selected on page load.
- In the output, the text CSS, HTML, JAVA, PHP has been shown in a drop-down list with four options.
Browser Support for selected Attribute in HTML:
Tips and Notes
- If selected attribute not presents the first value will be the default pre-selected value.