Date First Published: 28th February 2023
Topic: Web Design & Development
Subtopic: Web Development
Article Type: Computer Terms & Definitions
Difficulty: MediumDifficulty Level: 5/10
Learn more about what the HTML <script> tag is in this article.
In HTML, the <script> tag is used to embed client-side JavaScript code onto a webpage. It can point to an external script file using the src attribute or contain scripting statements. Common uses for JavaScript are form validation, setting of cookies, and displaying animations. The <script> tag can be placed in the <body> or <head> section of a HTML document and multiple script tags can be placed in one document as the browser will run all the scripts, starting from the first script tag to the last one.
An example of JavaScript code embedded within the <script> and </script> tags can be seen below:
The output of the HTML document with the JavaScript code can be seen below.
Below are the attributes for the <script> tag.
Attribute | Description |
---|---|
async | Specifies that the external script will be run asynchronously. |
charset | Specifies the character encoding used with an external script file. |
defer | Specifies that the external script will be run once the page has finished parsing. |
src | Specifies the URL of an external script file. |
type | Sets the media type of the script. |
Src | Specifies the URL of the audio file. |
HTML5 does not require the 'type' attribute as the default language is JavaScript in the <script> tag. But, it is still required in HTML4.
If so, it is important that you tell me as soon as possible on this page.
Network Services Network Setups Network Standards Network Hardware Network Identifiers Network Software Internet Protocols Internet Organisations Data Transmission Technologies Web Development Web Design Web Advertising Web Applications Web Organisations Web Technologies Web Services SEO Threats To Systems, Data & Information Security Mechanisms & Technologies Computer Hardware Computer Software Ethics & Sustainability Legislation & User Data Protection