Easy Tutorial
❮ Att Input Placeholder Att Object Name ❯

HTML <script> src Attribute

HTML <script> Tag

Example

Pointing to an external JavaScript file:


Browser Support

All major browsers support the src attribute.


Definition and Usage

The src attribute specifies the URL of an external script file.

If you want to run the same JavaScript on multiple pages of your website, you should create an external JavaScript file instead of repeating the same script. Save the script file with a .js extension and then reference it using the src attribute in the <script> tag.

Note: The external script file should not contain the <script> tag.

Note: Properly reference the external script file where you have written your script.


Differences Between HTML 4.01 and HTML5

None.


Syntax

Attribute Values

Value Description
URL The URL of the external script file. Possible values: Absolute URL - points to another website (e.g., src="http://www.example.com/example.js")<br> Relative URL - points to a file within the website (e.g., src="/scripts/example.js")
❮ Att Input Placeholder Att Object Name ❯