Prerequisite
- Simple text editor ( We like Sublime )
- Browser
Create a file helloworld.html (you can call it anything)
$ touch helloworld.html
Copy following content into your helloworld.html
<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
</head>
<body>
</body>
</html>
If you open this file in the browser, you would not see anything! Don’t worry, we’ll make it say ‘Hello, World!’ in couple of minutes.
Now open your html file with a text editor and add following code inside <body> tag
<script>
alert('Hello, World!');
</script>
Your file should look as below:
<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
</head>
<body>
<script>
alert('Hello, World!');
</script>
</body>
</html>
Now just refresh the page in the browser and Voila you should see ‘Hello, World!’ as below: