Dofactory.com
Dofactory.com

HTML <script> src Attribute

The src attribute on a <script> tag specifies the URL or path of a script file to be included in the current page.

The browser uses the URL to locate and load the script file.

Example

#

A src attribute on a <script> element.
The attribute references a JavaSript file.

<script src="/tutorial/myscript.js">
</script>

Using src

The src attribute specifies the URL of a script file to be included in the page.

JavaScript files have a .js file extension.

The URL can be internal (same website) or external (from another website).


Syntax

<script src="URL">

Values

#

Value Description
URL URL or path of a javascript file.

Browser support

Here is when src support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <script>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023


What's your favorite/least favorite part of Dofactory?


Guides