The HTML5 script Tag
The HTML5 <script> tag is incorporated within a document to be able to specify a client side script. An example of client side script is JavaScript.
The HTML5 <script> tag has the capacity to contain the scripting statements. Another way of using it is to direct to a script file that is external using the src attribute.
The use of HTML <script> tag has changed from HTML 4.01 to HMTL5. For example, in HTML4.01 it is necessary to use the type attribute. Aside from that some of the HTML4.01 attributes are no longer accepted in HTML5. Plus, HTML5 has adapted the use of async attribute.
The HTML5 <script> tag has the capacity to support the functions of the Global Attributes but there is none for Event Attributes. The major web browsers easily reflect the functions of the HTML5 <script> tag. Hence, it is applicable for Internet Explorer, Google Chrome, Safari, Opera and Firefox.
The attributes for HTML5 <script> tag are the following:
Attribute |
Value |
Description |
async (New) |
Async |
This is the indicator that script is done asynchronously but this is applicable only for external scripts |
defer |
Defer |
Determines that script is executed only if the page has accomplished parsing but this is only for external scripts |
type |
MIME_type |
This is the key in determining the MIME type that is used for the script |
charset |
character_set |
It is used for specifying the character encoding that is utilized in an external script file |
src |
URL |
It is for indicating the URL of script file from external source |
xml:space |
Preserve |
This is no longer accepted and supported in HTML5 |