HTML selected attribute


The purpose of the HTML selected attribute is to specify whether an option is selected in a form.

Supported elements

HTML selected attribute supports option element.


<option selected value="value">text</option>



Supported doctypes

Strict, Transition.

Example of HTML selected attribute

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>html selected attribute example - HTML tutorial | w3resource</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="description" content="HTML selected example, HTML tutorials, w3resource.com" />
<form action="html-selected-example.html">

Result html selected attribute

View this example in a separate browser window

Example of HTML selected attribute

Previous: HTML scrolling attribute
Next: HTML shape attribute

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook