HTML <script> tag represents client-side scripts like JavaScript, jQuery.
The script tag is generally used to handle some client-side events to take some actions or validations like validate email address, password length, passwords comparison etc. It is also used to link some external scripts like JavaScript, jQuery using src attribute of script tag.
The script tag can be used inside HTML <head> tag that is used to represent the head section for web page or <body> tag that is used to represent visible body content for web page.
HTML script Tag Sample Code
<html> <head> <title>HTML/HTML5 script Tag with Example</title> <!--Following statements are invisible for web page but when user action occurs, scripts will called--> <!--To link an external scripts--> <script type="text/javascript" src="jqury.js"></script> <script type="text/javascript" src="script.js"></script> <!--Javascript functions or statements--> <script type="text/javascript"> function alertMessage() { alert('Some text when this script called!!'); } </script> </head> <body> <p>Visible script related page content starts here</p> <script type="text/javascript"> document.write("HTML script tag example in body tag"); </script> </body> </html>
HTML script Tag Sample Result
Visible script related page content starts here
Tag Specific Attributes Support
Following are script tag attributes that are supported by <script> tag.
Attribute | Value | Description |
---|---|---|
src | url | Represents the source path to link external scripts |
type | text/javascript | Represents the type of the script |
Standard Attributes Support
HTML <script> tag does not support HTML Attributes. But you can get more details about available HTML Attributes here.
Event Attributes Support
HTML <script> tag does not support Event Attributes. But you can get more details about available HTML Event Attributes here.