Skip to content
Related Articles
Open in App
Not now

Related Articles

How to specify the media type of the script in HTML5 ?

Improve Article
Save Article
Like Article
  • Last Updated : 18 May, 2021
Improve Article
Save Article
Like Article

The HTML <script> type attribute specifies the type of script that is being represented. The type attribute identifies the content that appears between the <script> and </script> tags. It specifies the script’s MIME type and identifies the Tag’s content. It has a single value, media type, that specifies the MIME type of the script. It has a default value of “text/javascript.”

Note: JavaScript no longer requires the type attribute in HTML5.

Syntax :

<script type="script_media_type">

This attribute’s value will fall into one of the following categories:

  • <script type=”text/javascript “>
  • <script type=”application/javascript”>
  • <script type=”application/ecmascript”>
  • <script type=”text/ecmascript”>

Example :


<!DOCTYPE html>
<script type="text/javascript">
    let typeValue = document.querySelector('script[type]');
    let id = typeValue.getAttribute('type');
        Specifying the media type of the script in HTML5
    <p>Media Type of Script:
        <strong id="scriptType"></strong>
        document.getElementById("scriptType").innerHTML = id;


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!