HTML <script> srcAttribute
Examples
Point to an external JavaScript file:
<script src="myscripts.js.html"></script>
Try it Yourself »
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 writing the same script repeatedly. Save the script file with a .js extension, and then reference it using the src attribute in the <script> tag.
Note:External script files cannot contain <script> tags.
Note:Correctly reference the external script file in which you write your script.
Differences between HTML 4.01 and HTML5
None.
Syntax
<script src="URL.html">
Attribute Values
| Value | Description |
|---|---|
| URL | The URL of the external script file. Possible values:
|
HTML <script> Tag Other Extensions