Should I include type=\'text/javascript\' in my SCRIPT tags?



The type attribute in JavaScript is optional since the introduction of HTML5 brought some new improvements. JavaScript became the default language for HTML5 and modern browsers. So, now adding text/javascript isn't required in <script> tag.

This attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript".

Example

Here you can see how it is used:

<html>
   <body>
      <script language="javascript" type="text/javascript">
         <!--
            document.write("Hello World!")
         //-->
      </script>
   </body>
</html>

Output


Alshifa Hasnain
Alshifa Hasnain

Converting Code to Clarity

Updated on: 2025-03-26T12:04:57+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements