w3-video.com logo

HTML5 Tutorial

Home HTML5 XAMPP .htaccess Firefox Notepad++

Share it



option nested within elements, elements nested within option

Classified as: -

Parents, option

Children, option

Examples: option parents, option children

Valid Syntax 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!doctype html>
<html>
<head>
<title>...</title>
</head>
<body>

<datalist>
<option>...</option>
<option>...</option>
</datalist>

<select>
<option>...</option>
<option>...</option>
</select>

<select>
<optgroup>
<option>...</option>
<option>...</option>
</optgroup>
</select>

</body>
</html>
Valid Syntax 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!doctype html>
<html>
<head>
<title>...</title>
</head>
<body>

<select>
<optgroup>
<option>option 1</option>
<option> option 2</option>
</optgroup>
</select>

</body>
</html>
Invalid Syntax 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!doctype html>
<html>
<head>
<title>...</title>
<option>...</option>
</head>
<body>

<option>...</option>
<p>
<option>...</option>
</p>

</body>
</html>

Syntax 1: Valid, option nested within datalist, select, optgroup elements: allowed
Syntax 2: Valid, text added inside option: allowed
Syntax 3: Invalid, option nested within elements(head, body, p) other than datalist, select, optgroup: not allowed

option intro option optional, occurrences option browser display option(s) selected vs pre-selectedoption syntaxoption disabled attributeoption selected attribute