0

Why no alert appear in the following HTML?

My HTML

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="a.js"/>
</head>
<body>

</body>
<html>

a.js

alert("hello");
william007
  • 17,375
  • 25
  • 118
  • 194

2 Answers2

8

You can't have a self closing script tag. Change the script tag to:

<script src="a.js"></script>
plondon
  • 492
  • 3
  • 10
0

A script tag cannot be self-closing. try this:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="a.js"></script>
</head>
<body>

</body>
</html>
Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73