coding180 icon
Coding180
How to insert JavaScript in HTML

How to insert JavaScript in HTML

Home > Tutorials > JavaScript > Getting Started


Let's see, how to write JS code? You only need one step, use the <script> tag to insert the JavaScript code in the HTML page. 

Note that the <script> tags should appear in pairs, and the JavaScript code should be written between <script></script> tags.

type="text/javascript" is to tell the browser that the text inside belongs to the JavaScript language.

Task - Exercise 2

1. Insert the start tag in line 6

<script type="text/javascript">

2. Insert the ending tag in line 8 to complete the code. Now run your program and see the result.

Task Code

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb18030">
        <title>Insert js code - coding180.com</title>
        
        document.write("Start JS journey!");
    
    </head>
    <body>
    </body>
</html>

 


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel