JavaScript Tutorial – Getting Started

Unlike HTML, you have to let browsers know in advance if you want to type in JavaScript.

Where to place JavaScript Code

JavaScript can be placed in the <body> and the <head> sections of an HTML page. When placing the JavaScript in the HTML, it must be inserted between <script> and </script> tags.

JavaScript Hello World Example With Our Online HTML Editor

<!DOCTYPE html>

<script type="text/javascript">
document.write("Hello World!");

Try it yourself »

Note: above example is using <script type="text/javascript"> instead of <script>. Both syntax are valid, but first one is the standard.

Play with the above example by clicking on the Try It Yourself button and change the text from “Hello World!” to something like “JavaScript Tutorial for beginner” and see the result. Keep in mind that the quickest way to learn JavaScript is practice what you learned though coding, this is why each chapter in this tutorial is accompanied by at least one example like the above. With our online HTML editor, you can edit the HTML, and click on a button to view the result.