Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

What is the difference between “lang” and “type” attributes in a script tag?

How to differentiate between lang and type attributes in a <script> tag. Are they till supported and mandatory to add or is it optional to use?



1 Answer
Arushi

JavaScript lang attribute

This attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute.

JavaScript type attribute

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

Here you can see how it is used:

Live Demo

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

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.