The quickest way to save HTML code

To save an HTML file, open a plain text editor (like Notepad on Windows or TextEdit on Mac), paste or type your HTML code, then go to File > Save As, choose a location on your computer, name the file with .html at the end, and click Save. The .html extension tells your computer this is a web page file.

The file will then open in your default web browser when you double-click it. You can edit it anytime by right-clicking the file, selecting Open With, and choosing your text editor again.

Key Takeaways

  • Always use a plain text editor like Notepad, not Word or Google Docs, because those add invisible formatting that breaks HTML code.
  • The filename must end in .html or .htm for your computer to recognize it as a web page file.
  • Save the file to a folder you can find later — your Desktop or Documents folder works well for learning.
  • After saving, double-click the file to see how it looks in your browser, then edit it by opening it in your text editor again.

Using Notepad on Windows

Open Notepad by pressing Windows key + R, typing notepad, and pressing Enter. Paste your HTML code into the blank window. Go to File > Save As at the top left.

In the Save As window, type your filename followed by .html — for example, mypage.html. Make sure the Save as type dropdown at the bottom shows All Files (*.*), not Text Documents. If it says Text Documents, click the dropdown and change it. Choose where to save (Desktop is easiest to find), then click Save.

Using TextEdit on Mac

Open TextEdit from your Applications folder or by pressing Command + Space, typing TextEdit, and pressing Enter. Go to Format at the top and select Make Plain Text — this is the critical step that most people miss. If you skip this, TextEdit will add invisible formatting that breaks your HTML.

Paste your HTML code into the window. Go to File > Save. Type your filename with .html at the end, like mypage.html. Choose a location (Desktop works well), then click Save. If a dialog appears asking about the file extension, click Use .html.

What to do if your file opens as text instead of a web page

If you double-click your HTML file and it opens in Notepad or TextEdit instead of your browser, right-click the file (or Control-click on Mac). Select Open With and choose your web browser — Chrome, Firefox, Safari, or Edge. Check the box that says Always use this app to open .html files so it remembers your choice next time.

This usually happens because your computer's default app for HTML files is set to a text editor. Changing it once fixes the problem permanently.

Editing your HTML file after saving

To make changes to your HTML, right-click the file and select Open With, then choose your text editor. Make your changes and go to File > Save (not Save As). Close the editor and refresh your browser to see the changes — press F5 on Windows or Command + R on Mac.

Keep both your text editor and browser open while you work. Make a change, save the file, switch to the browser, and refresh. This workflow lets you see your code and the result side by side.

Choosing a better text editor as you progress

Notepad and TextEdit work fine for learning, but as you write more HTML, a code editor makes the work faster. Free options include Visual Studio Code, Sublime Text (free trial, optional paid license), and Atom. These editors highlight your code in different colors so mistakes stand out, auto-complete common tags, and show you line numbers.

Download any of these from their official websites, install it like any other program, and use it the same way you used Notepad — open it, paste your code, go to File > Save As, and save with the .html extension. The main difference is that these editors understand HTML and make writing it less error-prone.

Frequently Asked Questions

Can I save an HTML file with a different extension like .txt or .web?

No. Your computer and web browsers specifically look for .html or .htm to recognize a file as a web page. Other extensions will cause the file to open as plain text or fail to open at all. Always use .html.

What happens if I save HTML in Microsoft Word instead of Notepad?

Word adds invisible formatting codes that break your HTML. When you try to open it in a browser, the code won't work correctly. Always use a plain text editor — Notepad, TextEdit, or a code editor — never a word processor.

Can I save an HTML file to a USB drive or cloud storage?

Yes. When you click Save As, you can navigate to your USB drive or a cloud folder like OneDrive or Google Drive instead of your local computer. The file works the same way. Just make sure the filename still ends in .html.

Do I need internet to save or view an HTML file?

No. HTML files are just text files stored on your computer. You can save them, edit them, and view them in your browser without any internet connection. Internet is only needed if your HTML code links to images or resources hosted online.

What if I want to save HTML from a website I'm viewing?

Right-click anywhere on the webpage and select Save Page As (or Save As on some browsers). Choose a location and click Save. Your browser will download the HTML file and any images it needs. This saves the page as it appears right now, but links to other pages may not work if you're offline.