HTML src property

HTML script src property HTML and script.html

You don't need to write the same script file repeatedly in HTML, you can create JavaScript in a separate file, save it and use the src property reference, see the following example:

Point to an external JavaScript file:

<script src="myscripts.js"></script>

Try it out . . .

Browser support

HTML script src property HTML script src property HTML script src property HTML script src property HTML script src property

Src properties are supported by all major browsers.


Definitions and usages

The src property specifies the URL of the external script file.

If you want to run the same JavaScript on multiple pages in your Web site, you should create an external JavaScript file instead of writing the same script over and over again. Save the script file .js the src extension, and then refer to it in the src property in the label.

Note: External script files cannot contain labels.

Note: Refers correctly to the external script file that you written to the script.


The difference between HTML 4.01 and HTML5

No.


Grammar

<script src="URL">

The property value

value describe
URL The URL of the external script file.

Possible value:

  • Absolute URL - pointing to another website (such as SRC = "http://www.example.com/example.js" Rel = "External Nofollow")
  • Relative URL - pointing to a file within the website (such as src = "/ scripts / example.js")


HTML script src property HTML and script.html