How to create an HTML page from scratch
To create an HTML file, save a plain text file with the .html extension, such as index.html, and double-click it to open the page in your browser. Steps for Windows, Mac, VS Code, and phones come first, then working code and a CSS link.
What you need: Notepad or VS Code
HTML doesn't require any special software — even plain Notepad on Windows or TextEdit on Mac works. But for a more comfortable workflow, a code editor helps:
- Notepad / TextEdit — works, but no syntax highlighting or suggestions. Fine for a first try.
- VS Code — free, highlights tags, suggests closing elements, shows errors. The recommended option.
The key rule: the file must be saved with a .html extension, not .txt.
How to create an HTML file on Windows, Mac, in VS Code, or on a phone
Pick the way that fits your device.
Windows: Notepad
- Open Notepad and choose File → Save as.
- Set "Save as type" to "All files", or Notepad may add
.txt. - Name the file
index.html, check that the encoding is UTF-8, and click Save.
Mac: TextEdit
- Create a document and choose Format → Make Plain Text. Without this step, TextEdit saves formatting along with your text.
- Choose File → Save and name the file
index.html. - When TextEdit asks about the extension, click Use .html.
VS Code
- Open your project folder with File → Open Folder.
- Create
index.htmlwith the New File button in the file panel. - Type
!and, when the suggestion appears, press Tab to insert a page skeleton.
On a phone, or without installing anything
Open the online HTML editor, paste the code from "Your first code", and tap Download. The file should save as result.html, though on a phone the result depends on the browser.
If the file doesn't open as a page
- The file has a Notepad icon or opens as text: it's probably named
index.html.txtand Windows is hiding the extension. Turn on "File name extensions" in File Explorer, then rename the file. - The browser shows tags or stray symbols instead of a page: the file wasn't saved as plain text. Create it again using the steps above.
Your first code
Paste the basic page skeleton into your new index.html (if VS Code already inserted one, replace it with this code):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My page</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
Save the file and open it directly in a browser (double-click the file) — that's enough, no server needed.
Adding CSS
Create a file named styles.css in the same folder and link it inside <head>:
<link rel="stylesheet" href="styles.css">
Start styles.css with a simple rule:
body {
font-family: sans-serif;
max-width: 700px;
margin: 0 auto;
}
Project file structure
A simple site only needs one folder with this structure:
my-site/
index.html
styles.css
images/
photo.jpg
Paths in HTML are written relative to the location of index.html, e.g. images/photo.jpg.
Common beginner mistakes
- A forgotten closing tag — browsers often "forgive" this, but the layout can still break.
- The file was saved as
index.html.txt— check the extension in the file properties. - An incorrect path to CSS or an image (letter case matters on most servers).
- Special characters show up as garbled text — a missing
<meta charset="UTF-8">.
Related tools
HTML Editor Online
Write HTML with syntax highlighting and line numbers, see a live preview, format or minify it, and open or save .html files — all in your browser.
Learn HTML
A free interactive HTML course for beginners — with code examples and practical exercises.
HTML Document Structure
Lesson 2: what an HTML document is made of — <!DOCTYPE html>, html, head and body, and which parts are visible on the page. Example, task and exercise.
Linking CSS
Lesson 11: three ways to add CSS — an external file via <link rel="stylesheet">, a <style> block in head and the style attribute. Example and task.
How to publish an HTML site online
Practical guide: what "publishing" a site actually means, how hosting and domains work, why HTTPS matters, and why a site sometimes doesn't work after upload.