Advertisement
Home Open Editor ❯

HTML <script> src Attribute

Example

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

Try this code ❯

Meaning

The src attribute specifies the URL of a file containing scripting code.

The URI of an external script; this can be used as an alternative to embedding a script directly within a document.

Most of the times files containing JavaScript code will have a .js extension, and a server will attach the appropriate MIME type; if not, the type attribute might be used to explicitly set the content type of the external script file.


Standard Syntax

<script src="URL"></script>


Advertisement

Attribute Values

Value Description
URL

Value can be

  • An absolute URL - point to within or another web site ( href="http://www.example.com/index.html")
  • A relative URL - point to within a web site ( href="index.html")
Home Open Editor ❯
Advertisement