For the browser to execute the statement, it must be placed inside a <script> element. This element describes which section of the HTML code contains executable code, and will be described in further detail later.
<script> alert("Hello World!"); </script>
<!DOCTYPE html> <html lang="en"> <head> <title>Some Page</title> <script> alert("Hello World!"); </script> </head> <body> <p>The content of the web page.</p> </body> </html>
This basic hello World program can then be used as a starting point for any new programs that you need to create.
Copy and paste the basic program in a file, save it on your hard disk as "exercise 1-1.html". You can run it in two ways:
Save the file above as "exercise 1-2.html". Replace the double quotes in the line alert("Hello World!"); with single quotes, so it reads alert('Hello World!'); and save the result. If you open this file in the browser, what happens?
Manage research, learning and skills at IT1me. Create an account using LinkedIn to manage and organize your IT knowledge. IT1me works like a shopping cart for information -- helping you to save, discuss and share.