The HTML files define the structure of a web page. Thus, to create a web page, the very first step is to write the HTML file for it. In this article, you will learn, how to create an HTML file from scratch.

What exactly an HTML document is

An HTML document is a plain text file with extension .html or .htm. There’s almost no difference between the two, but the .html is more common.

This text file contains the information that the browsers uses to create a structure of the web page.

Tools we need

Now the question is, which tool do we need to create an HTML file.

The easiest way is to use a plain text editor, such as the default text editor of your operating system.

Advanced text editors and IDEs such as Visual Studio Code, Sublime, Atom, or Bracket can help you with syntax suggestions and error highlighting. You can use them to write and manage complex HTML code.

These advanced text editors are free to download and use, and they are available for all popular operating systems like Windows, Linux, and macOS.

Steps to create an HTML document

Now let’s get our hands dirty. Let’s create a simple HTML document.

The steps are as follows:

  • Launch the text editor of your choice and create a new plain text document
  • Put some HTML tags in it. If you’re unfamiliar with the HTML syntax, you can copy-paste the below code in your new blank document. We will learn about tags later. As of now, let’s focus on creating the document
<!DOCTYPE html>
		<title> A Sample Webpage </title>
     <p> Hello World! </p>
  • Once you’re done with writing the code, it’s time to save the document. While saving the document you can give any name, provide .html or .htm as an extension, and UTF-8 as a character encoding system (if asked).

Verify the HTML document using the browser

After saving the file we can verify that it works.

Navigate to the location where you have saved the file. Once you locate the file, double-click on it to open your operating system’s default web browser.

As a result, you should see a black page with the title A Sample Webpage and a single paragraph Hello World! in it.

Thanks for reading!

That’s all about creating an HTML file. Now you can start learning about different HTML tags and attributes we can use in the HTML documents.

Get my free e-book to prepare for the technical interview or start to Learn Full-Stack JavaScript