HOW-TO

How to create an HTML file (Windows, Mac, or with an AI tool)

An HTML file is plain text saved with the .html extension. How to make one on Windows or a Mac with tools you already have, the save mistakes that break it, and how to turn it into a link other people can open.

4 min read·

An HTML file is a plain text file whose name ends in .html. Any plain text editor can make one, and any browser can open it. The two things that go wrong are saving it as rich text and saving it with a hidden .txt on the end.

Starter code to paste

Paste these five lines into the editor, then change the title and the text inside the body tags:

<!doctype html>

<html lang="en">

<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>My page</title></head>

<body><h1>Hello</h1><p>My first page.</p></body>

</html>

The viewport line makes the page fit phone screens. The charset line keeps quotes, accents and emoji from turning into odd symbols.

On Windows with Notepad

  • ✓Open Notepad from the Start menu and paste the code.
  • ✓Choose File > Save as. Set Save as type to All files, and type a name ending in .html, for example index.html.
  • ✓Keep Encoding as UTF-8 and click Save.
  • ✓Double-click the saved file. It should open in Edge or your default browser. If it opens in Notepad, see opening an HTML file on Windows.

On a Mac with TextEdit

Double-click the file to open it in Safari, or see opening an HTML file on a Mac.

  • ✓Open TextEdit and start a new document.
  • ✓Choose Format > Make Plain Text before pasting. A rich text document saves formatting codes, not your HTML.
  • ✓Paste the code, choose File > Save, and name it index.html. If asked, click Use .html.
  • ✓If TextEdit later shows the page instead of the code when you reopen it, go to TextEdit > Settings > Open and Save and tick Display HTML files as HTML code.

With a code editor

Visual Studio Code is free on Windows, Mac and Linux. Choose File > New File, save it as index.html, then type ! and press Tab to get the starter code automatically. Colour highlighting and auto-closing tags make edits easier; editing an HTML file covers the rest.

With an AI tool

Ask Claude, ChatGPT or Gemini for "a single HTML file with the CSS and JavaScript inline" and describe the page. Copy the code into one of the editors above and save it as .html, or use the download button where the tool has one. See downloading a Claude artifact and sharing a ChatGPT canvas.

Asking for everything inline keeps it to one file, which is easier to open and to share. Making an HTML file self-contained explains why.

Common mistakes

  • ✓The file is called index.html.txt. Windows and macOS hide extensions by default. Turn them on, rename the file, and remove .txt.
  • ✓The page shows the code instead of the page. The file was saved as rich text or as .txt. Save again as plain text with .html.
  • ✓Images do not appear. The image path in the code must match a file beside the .html file, with the same capitals. Keep them in one folder.
  • ✓Odd characters like é appear. Save with UTF-8 encoding and keep the meta charset line.

Share the page as a link

The file works on your computer. Sent as an email or chat attachment, it often arrives as a download, or without its images. A hosted page opens at an https:// address on any device.

With FileShare Pro: upload the .html file from the dashboard, copy the link and send it. The person opening it needs no account. Sign up free to share your first page.

Frequently asked

How do I create an HTML file?

Open a plain text editor such as Notepad or TextEdit in plain text mode, paste or write HTML, and save the file with a name ending in .html. Double-click it to open it in a browser.

Why does my HTML file open as text?

It was probably saved as .html.txt or as rich text. Show file extensions, remove .txt, and in TextEdit use Format > Make Plain Text before saving.

Do I need special software to make an HTML file?

No. Notepad on Windows and TextEdit on a Mac are enough. A free code editor such as VS Code makes editing easier but is optional.

How do I let someone else see my HTML file?

Upload it to a host and send the link. An attachment often arrives as a download or without its images; a link opens as a working page on phones and computers.

Got a page to share?

Drop the file, copy the link — live in seconds, free plan included.

Start sharing free