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


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>

Updated on: 12-Sep-2019

135 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements