Multiple choice technology databases

What is the correct syntax for referring to an external script called "xxx.js"?

  1. <script type="text/javascript" href="xxx.js">

  2. <script type="text/javascript" src="xxx.js">

  3. <script type="text/javascript" name="xxx.js">

  4. <script type="text/javascript" value="xxx.js">

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The src attribute of the tag is used to specify the path to an external JavaScript file. Option A incorrectly uses href (which is for <link> tags), option C incorrectly uses name (which is for form elements), and option D incorrectly uses value (which is for input elements). The type attribute was historically required but is now optional.