There are many types of app you can use to write HTML code on. You can code HTML in simple text editor such as Notepad in Windows, code editor, or web design software made specifically for HTML and other languages such as Adobe Dreamweaver.
If you prefer to code HTML by hand in Windows, you can quickly do so using only the preinstalled Notepad app in Windows. This guide will show you how to write and run HTML code in Notepad on Windows 11.
Also see: How to Recover Unsaved Notepad in Windows 11
Run HTML Code in Notepad on Windows 11
To run HTML code, you will need to save the code as .html so that web browsers can recognize the file as an HTML file type. If you have a set of HTML code you want to execute, you can write or paste the code in Notepad on Windows 11, and then save it as HTML format. You can then run the HTML file with a web browser to view the result of the codes.
Example – Write and Run HTML code in Notepad
First, open Notepad in Windows 11 and type or paste the HTML code you want to run in the notepad. You can use the sample HTML codes below as a reference.
<html> <head> <title>HTML Sample Page Title</title> </head> <body> <h1>Run Simple HTML Code in Windows 11</h1> <p> <a href="https://www.windowsdigitals.com/how-to-run-html-code-in-notepad-windows-11/">Windows Digital</a> shows you how you can write and run HTML codes in Notepad on Windows 11. </p> </body> </html>
Once you are done entering the HTML code you want to run in Notepad, click File and select Save as.
Next, in the Save as window, type any file name you want, and change the .txt extension to .html instead. Then, click Save to save the file as an HTML file.
If you save the file as a basic text file (.txt), the code inside will only be recognized as plain texts instead of executable HTML code. You need to properly save the code as HTML format in order for relevant software such as web browser to recognize it as an HTML document.
After saving the HTML file, you can run the file in any web browser you want, for example, Google Chrome or Mozilla Firefox. By default, Windows will automatically run any .html file with your default web browser when you double-click to open the file. To manually choose a browser to open the HTML file, right-click the file, select Open with and select the browser you want to use.
The output of the HTML codes will then be displayed in a new tab on the selected browser.
Edit an HTML file with Notepad
In addition, you can also edit any HTML file directly with Notepad. You don’t need to convert it back to .txt just to edit the HTML code in Notepad. To edit an existing .html file with Notepad, right-click the HTML file, select Open with, and then select Choose another app.
When you are prompted to select an app to open the HTML file, scroll down and click More apps. Then, select Notepad and click OK to open the HTML file in Notepad.
Notepad will be able to open the HTML file and display the source code in it. You can then edit the HTML code as you wish. Once you have done editing, you can simply press Ctrl + S to save the file as the original file.