05 October, 2020
The script tag takes two important attributes Language
Let us write our class example to print out “Hello World”.
Next, we call a function document .write which writes a string into our HTML document. This function can be used to write text, HTML, or both. So the above code will display the following result: Hello World! Whitespace and Line Breaks
Semicolons are optional
Note It is a good programming practice to use semicolons.
Script in <head> … </head> section
Script in <body> … <.body>
Section Script in <body> …. </body>
and <head> ….. </head> sections.
Script in and external file and then include in <head>--- </head> section.
If you want to have a script run on some event, such as when a user clicks somewhere, then you will place that script in the head as follows: