How to run HTML code in Notepad for Windows 11/10

To run HTML code in Notepad on Windows 11 or Windows 10, type the code, save the file with a .html extension, and open that file in a web browser, because Notepad only edits the code and the browser runs it.

This guide covers a starter HTML template, saving the file correctly, opening it in Edge or Chrome, running it from Command Prompt or PowerShell, Notepad settings that help, and fixes for pages that show raw code.

How to run HTML code in Notepad for Windows 11/10
The Notepad status bar shows the file's encoding, such as UTF-8, which should match the meta charset line in your HTML. (Image: Microsoft)

How to write and run HTML code with Notepad

  1. Open Start, type Notepad and open it.
  2. Type or paste your HTML code. The template in the next section works as a first test.
  3. Select File > Save As (or press Ctrl + Shift + S).
  4. Pick a folder, such as a new folder called first-website on your desktop.
  5. In the File name box, type index.html and select Save.
  6. Open File Explorer, go to that folder and double-click index.html.
  7. The page opens in your default web browser and shows the result of your code.

To see changes, edit the code in Notepad, save with Ctrl + S, and reload the browser tab. The file name must end in .html; the .html extension is what tells Windows to open it in a browser instead of a text editor.

Basic HTML code to test in Notepad

Paste this into an empty Notepad window. It is the minimal structure a browser needs to display a page correctly.

Line of code What it does
<!doctype html> Required first line; makes the browser treat the file as a modern HTML document
<html lang="en-US"> … </html> Wraps the whole page and sets its language
<head> … </head> Holds settings that are not shown on the page, such as the title and character set
<meta charset="utf-8"> Tells the browser the file uses UTF-8, so symbols and accented letters display correctly
<meta name="viewport" content="width=device-width"> Makes the page fit the screen width on phones
<title>My test page</title> Sets the text shown on the browser tab
<body> … </body> Holds everything visible on the page
<h1>Hello from Notepad</h1> A top-level heading inside the body
<p>This page runs from a file on my PC.</p> A paragraph of text

Type the lines in that order, closing each element after its content. Most elements have an opening tag and a closing tag with a slash, such as <p> and </p>.

Basic HTML code to test in Notepad, saved as index.html
Paste this starter template into Notepad; it begins with <!doctype html> and sets a utf-8 charset and a page title. (Image: Mozilla)

Save an HTML file in Notepad with the right name and encoding

Most "HTML won't run" problems come from how the file was saved, not from the code.

  1. Select File > Save As in Notepad.
  2. Type a name in lowercase with no spaces, such as index.html or about-me.html.
  3. Leave the encoding as UTF-8. Notepad uses UTF-8 without a byte order mark for new files, which suits web pages.
  4. Select Save.
  5. Check the Notepad status bar: it shows the file's encoding, and an asterisk in the title bar means there are unsaved changes.

Use hyphens instead of spaces in file names. Spaces turn into %20 in web addresses, and many web servers treat MyPage.html and mypage.html as different files.

Open an HTML file in Edge, Chrome or another browser

  1. Open File Explorer and go to the folder where you saved the file.
  2. Double-click the .html file to open it in your default browser.
  3. To use a different browser, right-click the file, select Open with, and choose the browser.
  4. Keep the browser tab open while you work.
  5. After each save in Notepad, reload the tab to see the change.

The browser shows the file from your PC, so the address bar starts with file:/// rather than https://. Nobody else can see the page until you upload it to a web server.

Run an HTML file from Command Prompt or PowerShell

Windows opens a document in the app associated with its file type when you type the file name as a command, so an .html file opens in your default browser.

start index.html

Run this in Command Prompt from the folder that holds the file (use cd to get there). In PowerShell, Invoke-Item index.html does the same: it performs the default action for the file, which for .html is opening it in the browser.

You should see: Your default browser opens a new tab showing the page.

Run an HTML file from PowerShell with the Invoke-Item command
Invoke-Item performs a file's default action, so Invoke-Item index.html opens the page in your default browser. (Image: Microsoft)

Notepad tips and tricks for Windows users

Notepad has no syntax highlighting or tag completion, but a few settings make it easier to write HTML.

Tip How Why it helps with HTML
Save As shortcut Ctrl + Shift + S Saves a copy under a new .html name quickly
Open a second window Ctrl + Shift + N Keeps two HTML files side by side
Watch the encoding Read the encoding in the status bar Confirms the file is UTF-8, matching the meta charset line
Spot unsaved work Look for the asterisk in the title bar Explains a browser that still shows the old version
Turn off text formatting Disable formatting in Notepad settings (Windows 11) Keeps the file plain text, so no Markdown formatting gets mixed into your code
Use forward slashes in paths Write images/photo.jpg, not images\photo.jpg HTML paths use forward slashes even on Windows
Keep related files together Put images in an images folder next to index.html Short relative paths such as images/logo.png then work

Run HTML code in Notepad, Notepad++ or VS Code

Your situation Use this Why
Quick test, nothing to install Notepad + browser Built into Windows; save as .html and double-click
Want a free source code editor Notepad++ A free Notepad replacement for Windows built for programming languages; saves .html files the same way
Learning web development or building a site Visual Studio Code IntelliSense suggestions, Emmet, Format Document (Shift + Alt + F) and a live preview
No access to install software Notepad + browser Works on any Windows PC with a browser

In VS Code, right-click an HTML file and select Open in Integrated Browser, or select the Show Preview icon in the editor title bar. The preview updates as you type.

Run HTML code in Notepad++, the free source code editor for Windows
Notepad++ adds tabs, a Language menu and line numbers, and saves .html files the same way as Notepad. (Image: notepad-plus-plus.org)

Confirm your HTML code is running in the browser

  1. Look at the browser tab: it should show the text from your title element.
  2. Check the page: headings and paragraphs should appear as formatted text, with no angle brackets visible.
  3. Change the heading text in Notepad, save, and reload the tab; the new text should appear.
  4. Check the address bar shows a file path ending in .html.

HTML code not running from Notepad

Double-clicking the file opens Notepad instead of a browser

The file was saved as index.html.txt, so Windows still sees a text file.

  1. In File Explorer, open Folder options, clear Hide extensions for known file types, and select OK.
  2. Find the file and check whether its name ends in .txt.
  3. Rename it so it ends in .html only, and confirm the extension change.

The browser shows the code as plain text

The file still has a .txt extension, or the code is missing its HTML structure.

  1. Check the extension is .html, as above.
  2. Make sure the file starts with <!doctype html> and contains <html>, <head> and <body> elements.

Changes in Notepad do not show in the browser

The file was not saved, or the browser tab was not reloaded.

  1. Look for an asterisk in the Notepad title bar and press Ctrl + S.
  2. Reload the browser tab.
  3. Confirm you are editing the same file the browser opened.

Accented letters or symbols show as odd characters

The file encoding and the declared character set do not match.

  1. Add <meta charset="utf-8"> inside the head element.
  2. Save the file again with UTF-8 encoding in Notepad's Save As dialog.

Images do not load on the page

The src path or file name does not match the image file.

  1. Put the image in a folder next to the HTML file, for example images.
  2. Use a relative path with forward slashes, such as images/photo.jpg.
  3. Match upper and lower case exactly and keep the image's file extension.

Run HTML code in Notepad FAQ

Can you write HTML in Notepad?

Yes. HTML is plain text, so Notepad can write it. Save the file with a .html extension and UTF-8 encoding, then open it in a browser to see the result. Notepad itself does not display the page.

How do I run HTML code in Notepad on Windows 11?

Type the code in Notepad, choose File > Save As, name the file index.html, and save. Then double-click the file in File Explorer and it opens in your default browser, such as Microsoft Edge.

Which Notepad is best for HTML?

Windows Notepad is enough for small tests. Notepad++ is a free source code editor and Notepad replacement built for programming languages. Visual Studio Code is the stronger choice for real projects, with suggestions as you type, automatic formatting and a live preview.

Is Notepad still available for Windows 11/10?

Yes. Notepad is included with Windows 11 and Windows 10. On Windows 11 the redesigned Notepad has also added spellcheck and optional text formatting.

How do I run HTML code in a browser?

Save the code as a file ending in .html, then open it in the browser by double-clicking it or right-clicking and choosing Open with. Reload the tab after each change to see the new version.

How do I run HTML code in Notepad++?

Write the code, save the file with a .html extension, and open it in your browser from File Explorer the same way as with Windows Notepad. The saved file runs identically whichever editor created it.

How do I run HTML code in VS Code?

Open the .html file in Visual Studio Code, right-click it and select Open in Integrated Browser, or select the Show Preview icon in the editor title bar. The preview updates as you edit.

How do I run HTML code in the terminal on Windows?

Go to the file's folder in Command Prompt and type start index.html, or in PowerShell type Invoke-Item index.html. Both open the file in the default browser, because that is the default action for .html files.

Do I need the internet to run HTML code?

No. A browser opens .html files stored on your PC without an internet connection. You only need a web server or hosting when other people should be able to visit the page.

Notepad or a code editor for running HTML on Windows?

Use Notepad and a browser for a first page or a quick test, and move to Visual Studio Code once you write more than a page or two. Notepad plus any browser already runs HTML with nothing to install, while VS Code adds suggestions, formatting and a live preview that catch mistakes Notepad cannot show.

Code editor for running HTML on Windows: index.html open in VS Code
Visual Studio Code adds line numbers, syntax colours and helpers such as this colour picker that Notepad cannot show. (Image: code.visualstudio.com)

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *