w3-video.com logo

HTML5 Tutorial

Home HTML5 XAMPP .htaccess Firefox Notepad++

Share it



script nested within elements, script statements inside script

Classified as: metadata content, flow content, phrasing content, script-supporting elements

Parents, script element

Children, script element

Examples: script parents, script children

Valid Syntax 1
1
2
3
4
5
6
7
8
9
10
11
12
<!doctype html>
<html>
<head>
<title>...</title>
<script>

</script>
</head>
<body>

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

<script>

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

</script>
</head>
<body>

<script>

</script>
<script src="URL"></script>
</body>
</html>
Invalid Syntax 4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!doctype html>
<html>
<head>
<title>...</title>
</head>
<body>

<table>
<colgroup>
<script>
...
</script>
</colgroup>
...
</table>
<script>
<p>
...
</p>
</script>
</body>
</html>

Syntax 1: Valid, script nested inside head: allowed
Syntax 2: Valid, script nested inside body: allowed
Syntax 3: Valid, script elements (inline, external) nested inside head and body elements: allowed
Syntax 4: Invalid, script nested inside colgroup: not allowed; p nested inside script: not allowed

script intro script inline, imported, data islands script browser display script syntaxscript async attributescript charset attributescript defer attributescript type attributescript src attribute