w3resource

HTML selected attribute

selected

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.

Syntax

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

Value

selected

Supported doctypes

Strict, Transition.

Example of HTML selected attribute

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<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" />
</head>
<body>
<form action="html-selected-example.html">
<select>
<option>Soccer</option>
<option>Hockey</option>
<option>Polo</option>
<option>Golf</option>
</select>
</form>
</body>
</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.