Computer >> Computer tutorials >  >> Programming >> Javascript

Do you need text/javascript specified in your <script> tags?


In an HTML page, mostly text/javascript is used in the <script> tag.

Here’s an example

<script type="text/javascript">
</script>

However, the introduction of HTML5 brought some new improvements. JavaScript became the default language for HTML5 and modern browsers. Therefore, now adding text/javascript isn’t required in <script> tag.

<script>
</script>

Example

Let’s see an example in jQuery.

Live Demo

<html>
   <head>
      <title> jQuery Example</title>
      <script src = “https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>
         $(document).ready(function(){
            document.write("Hello, World!");
         });
      </script>
   </head>
   <body>
      <h1>Hello</h1>
   </body>
</html>