Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

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

  • Last Updated : 18 May, 2021

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.

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

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
Recommended Articles
Page :