HTML Editors
Learn how to write HTML using Notepad, TextEdit, and VS Code. Create, save, edit, and open your first HTML page with practical examples.
In the previous chapter, you learned what HTML is and how a basic HTML Document is structured.
Now it's time to write your own HTML Code!
To create an HTML Web Page, you need a Text Editor or Code Editor. You can start with a simple application such as Notepad or TextEdit, or use a dedicated Code Editor such as Visual Studio Code.
In this chapter, you will learn how to choose an Editor, create your first HTML File, save it correctly, and view your Web Page in a Browser.
What Is an HTML Editor?
An HTML Editor is an application used to write, modify, and manage HTML Code.
You do not need expensive software to create HTML Pages. Even a basic Text Editor is enough to get started.
There are two common types of Editors:
1. Basic Text Editors
These provide a simple interface for writing plain text and code.
Examples:
- Notepad (Windows)
- TextEdit (macOS, using Plain Text mode)
2. Dedicated Code Editors
These provide additional features that make writing and managing Code easier.
Examples:
- Visual Studio Code (VS Code)
- Sublime Text
- Notepad++
Basic Text Editor vs Code Editor
| Feature | Basic Text Editor | Code Editor |
|---|---|---|
| Write HTML | Yes | Yes |
| Syntax Highlighting | Usually limited | Yes |
| Auto-completion | Usually limited | Commonly available |
| Multiple Files Management | Basic | Advanced |
| Extensions | Usually limited | Often supported |
| Suitable for Beginners | Yes | Yes |
W3PrimeCode Tip: Beginners can use any simple Editor. However, VS Code is a useful choice if you plan to learn HTML, CSS, and JavaScript together.
Writing HTML Using Notepad (Windows)
Follow these steps to create your first HTML Page using Notepad.
Step 1: Open Notepad
Open the Start Menu, search for Notepad, and launch the application.
Step 2: Write HTML Code
Copy or type the following Code:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is my first HTML page.</p>
</body>
</html>Step 3: Save the HTML File
- Click File → Save As.
- Enter
index.htmlas the File Name. - Select
All Filesas the Save as type. - Select
UTF-8as the Encoding, if the option is available. - Choose a Folder and click Save.
Important: Make sure the File is saved as index.html, not index.html.txt.
Step 4: Open the HTML File in a Browser
Locate the saved index.html File and double-click it.
It should open in your default Web Browser.
You can also right-click the File and select Open with to choose a different Browser.
Writing HTML Using TextEdit (macOS)
If you are using a Mac, you can create HTML Files with TextEdit.
Step 1: Open TextEdit
Launch TextEdit from Applications or Spotlight Search.
Step 2: Switch to Plain Text Mode
Select Format → Make Plain Text.
This is important because HTML Code should be saved as plain text rather than Rich Text.
Step 3: Write Your HTML Code
<!DOCTYPE html>
<html>
<head>
<title>My HTML Page</title>
</head>
<body>
<h1>Hello from Mac!</h1>
<p>I created this page using TextEdit.</p>
</body>
</html>Step 4: Save the File
- Select File → Save.
- Enter
index.htmlas the File Name. - If TextEdit asks whether to use
.htmlor.txt, choose.html. - If available, disable the option that automatically adds
.txtto plain text files. - Save the File using UTF-8 Encoding.
Step 5: Open in Browser
Find index.html in Finder and open it with Safari, Chrome, Firefox, or another Web Browser.
Writing HTML Using Visual Studio Code
Visual Studio Code (VS Code) is a popular Code Editor developed by Microsoft.
It provides useful features such as:
- Syntax Highlighting
- Auto-completion
- File and Folder Management
- Integrated Terminal
- Extensions
- Built-in HTML language support
Steps to Create an HTML File
Step 1: Download and install VS Code from its official Website:
https://code.visualstudio.com/
Step 2: Open VS Code.
Step 3: Create a new File using File → New Text File.
Step 4: Save the File as index.html.
Step 5: Write the following HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>Learning HTML</title>
</head>
<body>
<h1>HTML with VS Code</h1>
<p>Learning HTML is fun!</p>
</body>
</html>Step 6: Save your changes.
Step 7: Locate the saved HTML File and open it in your Browser.
Note: VS Code is a Code Editor, not a Web Browser. Saving an HTML File in VS Code does not automatically display its rendered output. Open the File in a Browser to view the Web Page.
Try HTML Online with W3PrimeCode
You can also practice HTML using the W3PrimeCode Code Sandbox Free Online HTML Code Editor
An online HTML Editor allows you to write Code and view the rendered result without manually creating a local HTML File.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Online HTML Example</title>
</head>
<body>
<h1>Hello, W3PrimeCode!</h1>
<p>I am practicing HTML online.</p>
</body>
</html>Try changing the Heading and Paragraph text, then run the Code again.
Understanding HTML File Extensions
An HTML Document is commonly saved using either of these Extensions:
.html.htm
Both are recognized as HTML File Extensions.
For consistency, we will use .html throughout this course.
Examples of valid File Names:
index.html
about.html
contact.html
portfolio.htmlCommon Mistake:
index.html.txtA File with this name has .txt as its final Extension and may open as a Text File instead of an HTML Document.
How to Edit an Existing HTML Page
After saving your first HTML File, you can modify it whenever you want.
Follow these steps:
- Open
index.htmlin your Editor. - Find the Code you want to change.
- Modify the Content.
- Save the File.
- Return to your Browser.
- Refresh the Page to view the updated result.
For example, change:
<h1>Welcome to HTML</h1>To:
<h1>Welcome to W3PrimeCode</h1>After saving and refreshing, the updated Heading will appear in the Browser.
Common Beginner Mistakes
Mistake 1: Saving with the Wrong Extension
Incorrect:
index.html.txtCorrect:
index.htmlMistake 2: Forgetting to Save Changes
If you modify Code but do not save the File, the Browser may continue displaying the previous version.
Always save your changes before refreshing.
Mistake 3: Opening the File Only in an Editor
A Code Editor displays the HTML Source Code.
A Browser interprets the HTML and displays the rendered Web Page.
Use both applications for different purposes.
Mistake 4: Saving HTML as Rich Text
When using TextEdit, switch to Plain Text mode before saving HTML Code.
Mistake 5: Confusing Browser Tab Title with Page Heading
The <title> Element defines the Browser Tab Title.
The <h1> Element defines a Heading displayed inside the Web Page.
Practical Use Case: Create a Personal Welcome Page
Create a new File named welcome.html and add the following Code:
<!DOCTYPE html>
<html>
<head>
<title>My Welcome Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>My name is Alex.</p>
<p>I am learning HTML with W3PrimeCode.</p>
</body>
</html>This simple project demonstrates how an Editor and Browser work together to help you create a Web Page.
Try It Yourself
Create a File named my-profile.html.
Use this Starter Code:
<!DOCTYPE html>
<html>
<head>
<title>My Profile</title>
</head>
<body>
<h1>Your Name</h1>
<p>Your introduction goes here.</p>
</body>
</html>Your Tasks:
- Replace
Your Namewith your name. - Add a sentence about your interests.
- Change the Browser Tab Title.
- Save the File with the
.htmlExtension. - Open the File in your Browser.
- Make another change, save it, and refresh the Page.
Practice Exercises
Exercise 1 — Easy: Name two applications that can be used to write HTML Code.
Exercise 2 — Easy: Which File Extension is commonly used for HTML Documents?
Exercise 3 — Medium: Explain why TextEdit should be switched to Plain Text mode before writing HTML.
Exercise 4 — Medium: Create a File named about.html containing a Heading and Paragraph.
Exercise 5 — Challenge: Create a complete HTML Document, open it in a Browser, change its Heading, save the File, and refresh the Page to display the updated Content.