HTML First Program using Notepad
You do not need any special software to write HTML. A simple text editor like Notepad and a web browser are enough. Follow these steps to make and run your first web page.
Step 1: Open a text editor
- Windows: open Notepad (search for it in the Start menu).
- Mac: open TextEdit, then choose Format > Make Plain Text. Rich text will not work.
- You can also use VS Code or Sublime Text, which colour the code for you.
Step 2: Write the HTML code
Type or copy this code into the editor.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First Program</title>
</head>
<body>
<h1>Welcome to Tutorials Class</h1>
<p>I have created my first web page.</p>
</body>
</html>
Step 3: Save the file
- Choose File > Save As.
- Give a name that ends with
.html, for exampleindex.html. - In Notepad, set “Save as type” to All Files, and the encoding to UTF-8. Otherwise Notepad saves it as
index.html.txtand the browser will show only the code. - Remember the folder where you saved it, for example the Desktop.
Step 4: Open it in a browser
Double click the file, or right click and choose “Open with” and pick your browser. You can also drag the file into an open browser window.
Output in the browser
Welcome to Tutorials Class
I have created my first web page.
Step 5: Change and refresh
Go back to the editor, change the text inside the <h1> tag, and save the file. Then press F5 (refresh) in the browser. The new text will be there. This is the normal way of working: edit, save and refresh.
Note:
If you see strange symbols instead of text, check that you have saved the file as UTF-8 and kept <meta charset="UTF-8"> in the head.
Summary
- HTML files are plain text files with the
.htmlextension. - Write code in a text editor, save, and open in a browser.
- After each change, save the file and refresh the browser.
- Next: understand each part in HTML Page Structure.
Congratulations! Chapter Finished. Learn more about the similar topics:
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |