What is the correct syntax for referring to an external script in HTML ?
2025
What is the correct syntax for referring to an external script in HTML ?
Answer: A. <script src="script.js"> — The correct syntax is <script src="external.js"></script>. The src attribute specifies the URL of an external JavaScript file to be included in the document.
- A.
<script src="script.js">
- B.
<script ref="script.js">
- C.
<script href="script.js">
- D.
<script link="script.js">
Attempted by 246 students.
Show answer & explanation
Correct answer: A
The correct syntax is <script src="external.js"></script>. The src attribute specifies the URL of an external JavaScript file to be included in the document.
Loading lesson…