Script Element
<Script>
Explanation
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:
| Attribute | Value | Description |
| async | async | The external script will be executed on its own. But need to mention the source. |
| defer | defer | Script will be executed, when page has completed the parsing work. |
| type | MIME_type | Denotes the MIME type of the script. But need to mention the source. |
| charset | character_set | Illustrates the character encoding utilized in external script file. |
| src | URL | Refers to the source of the script file. |
"Async" attribute has been newly launched in HTML5.
Example Code:
Result :
- 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.
Limitations:
It is applicable to all major browsers.