For example, the code below displays an alert to the screen.
I would recomend you download NotePad++. It’s free. You use it for editing your code. Although you can use NotePad but NotePad++ have more features. Download Notepad++ from here.
Open NotePad++ and enter the code.
Now, Save it as Prog1.html.(you can also use another name). In the Save As type, choose Hypertext Markup Language. Save it in a new folder.
Open the location you saved the file and double-click to open it.
You will notice, it opens a web page and displays an alert
Attribute of the Script Tag
The script tag has two important attributes: Language and Type.
So if we rewrite our program, we would have:
The document.write() function is used to write a text to the html document. This is the text the user will see in the html page. The code below uses document.write(). Create a new html file with the following content:
You can enclose comments using /* and */. This can also be multiple line comment
Single-line comment can be specified using //
I recommend you try this out.
Other Things to Note
Although you use semicolons at the end of a line, you can well not use them. They are optional.