Script Element



Script element is used to write a script for e.g. Javascript.
<script type="text/javascript"> document.write("Text") </script>
Element Specific attributes supported by this element are:
asyncasync The external script will be executed on its own. But need to mention the source.
deferdefer Script will be executed, when page has completed the parsing work.
typeMIME_type Denotes the MIME type of the script. But need to mention the source.
charsetcharacter_set Illustrates the character encoding utilized in external script file.
srcURL Refers to the source of the script file.

"Async" attribute has been newly launched in HTML5.

Example Code:


  • To validate the "async and type" attributes, the "src" attribute must be used compulsorily.
  • Do not add any contents inside <script>, in case "src" attribute is used.
It is available in the previous versions of HTML.
It supports both Global Attributes and Event Attributes in HTML5.


It is applicable to all major browsers.

Ask Questions

Ask Question