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.

  1. A.

    <script src="script.js">

  2. B.

    <script ref="script.js">

  3. C.

    <script href="script.js">

  4. 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.

Explore the full course: Tpsc Assistant Technical Officer

Loading lesson…