HTML beginner's tutorial: Build a webpage from scratch with HTML
Hunter Johnson
Posted on March 23, 2023
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 on to 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:
- What is HTML?
- Key HTML terms and formatting
- How to build your own web page with HTML
- What to learn next
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:
<p><strong>These tags are nested properly.</strong></p>
<p>This tag is not nested.</p>
Output:
These tags are nested properly
this tag is not nested
Attributes and hyperlinks
HTML attributes provide additional information about our elements. Think of these as 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 embedding images, adding color, declaring the language of a page, or adding a title. For example, we can add color to our text using the following format.
<h1 style="color:green">Hello, World!</h1>
Output:
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 the font size.
<h1>Heading Level 1</h1>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<h4>Heading Level 4</h4>
<h5>Heading Level 5</h5>
<h6>Heading Level 6</h6>
Output:
If we want to list items, either as a bulleted or numbered list, we use the <li>
tag. We can either create an unordered list (bulleted), or an ordered list (numbered).
- Unordered lists begin with the
<ul>
tag and the nested<li>
tags for each item. - Ordered lists begin with the
<ol>
tag and the nested<li>
tags for each item.
Unordered List with <ul>
tag:
<h1>Grocery Items</h1>
<ul>
<li>Eggs</li>
<li>Apples</li>
<li>Carrots</li>
<li>Noddles</li>
Output:
Ordered List with <ol>
tag:
<h1>Shopping Instructions</h1>
<ol>
<li>Go to the store.</li>
<li>Locate eggs, apples, carrots, and noodles.</li>
<li>Go to checkout counter.</li>
<li>Scan and purchase items.</li>
Output:
Add images: <img>
tag
We can add images to our webpage using the <img>
tag. We need to add an 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.
<h1>Waterfall Photography 101</h1>
<div class="imgContainer">
<img src="/udata/DErqVR5q0Pv/longexposurewaterfall1.jpg" alt="Long Exposure Waterfall">
<h4 class="caption">Learn how to take stunning waterfall pictures!</h4>
Output:
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 CSS language.
<table>
<tr>
<th>Name</th>
<th>Date of Birth</th>
<th>Weight</th>
</tr>
<tr>
<td>Khalid</td>
<td>12/13/1994</td>
<td>130</td>
</tr>
</table>
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.
<DOCTYPE! html>
<html>
<head>
<title>A Basic Web Page</title>
</head>
<body>
<h1>First HTML File</h1>
<p>Congratulations! You're learning how to create a webpage.</p>
</body>
</html>
Output:
The first line, <DOCTYPE! html>
, is called the doctype declaration. This indicates to the 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 provide 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.
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, we recommend using a simple text editor like TextEdit (Mac), Notepad (PC), or Atom. Most text editors are free to download.
We will use Educative's built-in text editor widget, where you can explore HTML without downloading anything. You may 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 basic structure of an HTML page. Try writing the basic structure yourself 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 solution:
<DOCTYPE! html>
<html>
<head>
<title>My HTML Webpage: Your Name</title>
</head>
<body>
<h1>About Me: Your Name</h1>
<p>A description of myself.</p>
</body>
</html>
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 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 solution:
<DOCTYPE! html>
<html>
<head>
<title>My HTML Webpage: Your Name</title>
</head>
<body>
<h1>About Me: Your Name</h1>
<p>A description of myself.</p>
<a href="https://www.link.com">Link Name</a>
</body>
</html>
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 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 solution:
<DOCTYPE! html>
<html>
<head>
<title>My HTML Webpage: Your Name</title>
</head>
<body>
<h1>About Me: Your Name</h1>
<p>A description of myself.</p>
<a href="https://www.link.com">Link Name</a>
<h3>My Skills<h3>
<ul>
<li>Skill 1</li>
<li>Skill 2</li>
<li>Skill 3</li>
<li>Skill 4</li>
<li>Skill 5</li>
</ul>
</body>
</html>
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
Example solution:
<DOCTYPE! html>
<html>
<head>
<title>My HTML Webpage: Your Name</title>
</head>
<body>
<h1>About Me: Your Name</h1>
<p>A description of myself.</p>
<a href="https://www.link.com">Link Name</a>
<h3>My Skills<h3>
<ul>
<li>Skill 1</li>
<li>Skill 2</li>
<li>Skill 3</li>
<li>Skill 4</li>
<li>Skill 5</li>
</ul>
<table>
<tr>
<th>Employer</th>
<th>Job Title</th>
<th>Years</th>
</tr>
<tr>
<td>Employer 1</td>
<td>Job 1</td>
<td>Year 1</td>
</tr>
<tr>
<td>Employer 2</td>
<td>Job 2</td>
<td>Year 2</td>
</tr>
<tr>
<td>Employer 3</td>
<td>Job 3</td>
<td>Year 3</td>
</table>
</body>
</html>
Example Output:
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 simple webpage on your own. You're well on your way to becoming a front-end 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 Zero to Hero in Front-end Web Development Skill Path offers 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 on Educative
- A Beginner's Guide to Web Development
- JavaScript Snake Game Tutorial: build a simple, interactive game
- Animate CSS code: create a panda animation with HTML & CSS
Start a discussion
What web development skill or technology do you want to learn about next? Was this article helpful? Let us know in the comments below!
Posted on March 23, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.