HTML Beginner's Tutorial: build a webpage from scratch with HTML

Aug 11, 2020 - 12 min read
Amanda Fawcett
editor-page-cover

If you are a web dev novice and want to get started with the exciting world of web design, you’ve probably heard of HTML, which is the foundation of every web page online. Any successful web developer or designer must have a strong understanding of HTML.

Today, we will go through a beginner’s tutorial on HTML and build a web page step-by-step. Most web development tutorials talk about CSS and JavaScript right away, but we want to make sure you have a solid understanding of HTML before moving onto the next steps.

We will discuss the basics of HTML that you’ll use throughout your web dev career. No prerequisite knowledge of programming is required, but to be most successful with this article, a basic understanding of programming is helpful. For a quick introduction or refresher, check out The Absolute Beginner’s Guide to Programming.

Today we will cover:



Become a frontend developer for free.

The ideal place to start your journey as a front-end developer. With no prior knowledge needed, you will gain a mastery of HTML, CSS, and JavaScript.

Claim your free COVID scholarship


What is HTML?

Hyper Text Markup Language (HTML) is the markup language we use to make webpages. It is the basis of every website that you encounter on the internet. Think of HTML as the bricks that you need to build anything for the web. Once we write our HTML code, we can add other languages to the page, such as CSS and JavaScript, to add interactivity, style, and more.

Imagine a document that you would create in a word processor. That document will usually use different font sizes to indicate sections of the text, such as headers, main content, footers, table of contents, etc. HTML is the process of building that document and setting the sizes of our text.

HTML provides a website’s structure and layout. We define that structure using various elements. But in order for a browser to appear how we want it, it must be explicitly told what each piece of content is. HTML is how we communicate and tell a computer how to render. The computer can interpret our HTML elements and translate them onto the screen.

Explore HTML on your own.

You can view the HTML source code of any website by right clicking on a rendered page and selecting “View Source”. This will open a page that details the HTML foundations of that site. Try it out with this article!


Key HTML terms and formatting

Now that we know what HTML is, let’s briefly introduce a few key terms before moving onto a step-by-step guide. You will use these basics throughout your entire web dev career!


Tags and elements

An element is an individual component of an HTML document that represents the semantics of that page. For example, the title element translates to the title of a page.

Semantics refers to the meaning of a particular element. Syntax refers to the structure of a programming language.

To create an element, we use tags. Think of these as descriptors for each piece of content you want on your page. Most tags are quite self-explanatory.

  • <p>: used to describe a paragraph
  • <img>: add an image
  • <h1>: set the text to the largest size heading
  • <a>: an anchor will create a hyperlink to other HTML files

To use tags, we wrap the content between an opening and closing tag. The closing tag uses the forward slash /, while the opening tag does not. HTML tags are case not sensitive so <P> is the same as <p>.

<p> This is a paragraph element. </p>

You can nest HTML elements when you want to apply multiple tags. Say you wanted to make a paragraph that is also bold. You could write the following HTML code:

  • HTML

Attributes and hyperlinks

HTML attributes provide additional information about our elements. Think of these like properties of an element. Attributes are placed in the opening tag, use the = sign, and wrap the attribute value in quotation marks " ".

<tagName attribute_name="attribute_value"></tagName>

Attributes can do all sorts of things to our elements such as embed images, add color, declare the language of a page, or add a title. For example, we can add color to our text using the following format.

  • HTML

Note: You can add color using Hex color codes (for specific colors) or one of the 140 text color names built-into HTML.

One of the most common uses of attribute is hyperlinking. We can connect any HTML page to another HTML page using an anchor tag. The href attribute will create a connection between the two sites.

<a href="http://www.google.com">Google</a>

Headings and lists

Headings are how we specify the difference between the main header and sub-headers. The HTML standard has six text heading elements, appropriately named h1 (the largest) through h6 (the smallest).

Note: Headers are used to represent text semantically. This is different than specifying font size. We use CSS to change font size.

  • HTML
  • Output

If we want to list items, either as a bulleted of numbered list, we use the <li> tag. We can either create an unordered list (bulleted) or an ordered list (numbered).

  • Unordered lists begins with the <ul> tag and the nested <li> tags for teach item.
  • Ordered lists begins with the <ol> tag and the nested <li> tags for teach item.
  • HTML
  • Output
Unordered List with <ul> tag
  • HTML
  • Output
Ordered List with <ol> tag

Add images: <img> tag

We can add images to our webpage using the <img> tag. We need to add a src attribute that contains a file path to that image. You will also include an alt attribute, which provides an alternative text description in case the image does not load.

In the example below, we also defined two class attributes. The class attribute is used to identify specific elements with an identifier. This makes it possible to use an elements in a later part of our code. An element can have multiple class values, such as a title and a caption, as we use below.

Note: The image tag does not use a closing tag.

  • HTML

HTML tables

We can add tables to a webpage by translating a table’s data into row and columns. Each row/column pair will have a piece of data associated with it called a table cell. So, how do we build a table in HTML?

First, we declare an HTML table using the <table> tag. Then, we add rows to our table with the<tr> tag. From there, we specify the cells with the <td> tag.

<table>
    <tr>
    <td>Column 1</td>
    <td>Column 2</td>
    <td>Column 3</td>
  </tr>
</table>

Take a look at this example below, but note that the table is not stylized at all. It will only list the data as it is provided. If we want to add style to the table (background color, padding, borders, etc.), we must use the language CSS.

  • HTML
  • Output

Formatting an HTML document

Now that we know the terms of HTML, let’s discuss the basics of formatting. We will look at a basic HTML file before discussing each part below.

  • HTML

The first line, <DOCTYPE! html>, is called the doctype declaration. This indicates to browser what HTML version the file is written in. This file indicates that it is written in HTML5.

On the second line, we write the opening <html> tag to indicate the root element. From there, we branch off into other elements in a tree-like structure. To properly define an HTML file, we must place <head> and <body> elements within that root.

  • The <head> element contains supporting information about the file. We call this metadata. There must be a <title> to providing a title to the page directly underneath the <head> element.
  • The <body> element contains the main content of our file that will be rendered by a browser. There can be only one <body> element. Most of the HTML code you write will exist here.
  • Within the body element, we then branch off to our highest-level heading <h1> and a paragraph <p>.

As you can see from this example, some elements are inline while others are block-level. Block-level HTML elements take the full width of a webpage and start on a new line. Some of these elements include headings, lists, and paragraphs. Inline elements do not take the full width and are in-line with text content. Some examples include anchors, images, and bolded text.


Become a frontend developer for free.

This is the ideal place to start your journey as a front-end developer with 6 curated modules. With no prior knowledge needed, you will gain a mastery of HTML, CSS, and JavaScript, allowing you to put together beautiful, functional websites and web apps yourself.

Become a Front End Developer


How to build your own webpage with HTML

Alright, now we know the basic terms of HTML and how to format an HTML file properly. But how do you actually make a webpage? Let’s go through a step-by-step guide to learn how it’s done. We will be making a simple “About Me” webpage that includes the following:

  • Title with your name
  • Description of yourself in a paragraph
  • List of your skills
  • Hyperlink to a website you like (or a personal website)
  • Table of your work experience

1. Download and open an HTML editor

Webpages are created using HTML editors. Think of this like a word processor but specifically for creating HTML files. There are many options for text editors that vary in complexity and robustness. If you’re just getting started, I recommend using simple text editor like TextEdit (Mac), Notepad (PC), or Atom. Most text editors are free to download.

Here, we will use Educative’s build-in text editor widget where you can explore HTML without downloading anything. You can also follow along with your own editor of choice.


2. Write a basic HTML file

Once you open your editor, start a new file and write the basics structure of an HTML page. Try writing the basic structure yourself in the code widget below using what we learned above. The answer can be found below if you get stuck. You should include:

  • Document type declaration
  • A page title called “My HTML Webpage: (Your name)”
  • A header (h1) called “About Me: (Your name)”
  • Paragraph with 1-2 sentences about you
  • Proper closing tags
Example output

3. Hyperlink to a website you like (or personal website)

Now, let’s add a link to your personal website or a website of your choosing. Copy the code you wrote from above and continue adding to it below. Try it yourself before checking the solution. We will add this just below your personal description. It should include:

  • The title of the page you are linking to
  • The URL to link to that site
Example output

4. Add a list of your skills

Now, let’s add an unordered list of your skills. Copy what code you have from above and continue adding this next step of HTML code. Try writing the code yourself in the code widget below using what we learned above. The answer can be found below if you get stuck. You should include:

  • A header (h3) called “My Skills”
  • A bulleted list of 5 skills
  • Proper closing tags for the list
Example output

5. Add a table of your work experience

Now, let’s add a table of your work experience. Copy what code you have from above and continue adding this next step of HTML code. Try writing the code yourself in the code widget below using what we learned above. The answer can be found below if you get stuck. You should include:

  • Column headers: Employer, Job Title, Years
  • 3 former jobs with each of the above columns filled in

6. Finish and save your webpage

Once you complete all these steps, you’ll want to save the HTML file on your computer. Select File > Save as in the Notepad or other text editor menu. Name the file your_name.html and set the encoding to UTF-8 (preferred for HTML files).

Once you save the file you can open it in your browser by right clicking on the file, clicking Open with, and selecting your browser. You will see your basic HTML page!


What to learn next

Congrats! You’ve officially made a simply webpage on your own. You’re well on your way to becoming a frontend web developer. There’s still a ton to learn, but HTML is a really important stepping stone. The next steps in your web dev journey are:

  • Advanced HTML
  • CSS (for adding style)
  • JavaScript (for interactivity)
  • Libraries and frameworks (prewritten code)
  • Advanced web dev concepts

To get you started with these concepts, Educative has created a learning path to walk you through all the skills necessary to become a professional web developer. Our Become a Front End Developer Learning Path offer 6 curated modules. You’ll learn how to add style to a webpage, the basics of JavaScript, and even how to deploy your own website!

Happy learning!


Continue reading about web development


WRITTEN BYAmanda Fawcett

A free, bi-monthly email with a roundup of Educative's top articles and coding tips.