<script> tag in HTML
The <script> tag is used to declare a client-side script within HTML document OR It is used to refer to JavaScript code within HTML document.
Important Description
- Open and close tag required of <script>.
- The "async" attribute is added new in HTML5.
How to import script? & Example
<script> Tag Browser Support
Element |
Chrome |
Edge |
Firefox |
Safari |
Opera |
<script> |
Yes |
Yes |
Yes |
Yes |
Yes |
Global Attributes
Attributes
The "xml:space" attributed is not Supported in HTML5.
Attribute |
Value |
Description |
async |
async |
Defines that the script is executed asynchronously |
charset |
charset |
Defines the character encoding used in an external script file |
defer |
defer |
Defines the script is executed when the page has finished parsing |
src |
URL |
Defines the resource URL of external script |
type |
media_type |
Defines the media type of the script |