HTML beginner's tutorial: Build a webpage from scratch with HTML
Tags: html, webdev, tutorial, programming
Published: 2023-03-23 17:59:09

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.](https://www.educative.io/blog/learn-how-to-code-beginners-guide?eid=5082902844932096)*

**Today, we will cover:**
* [What is HTML?](#what-is)
* [Key HTML terms and formatting](#terms)
* [How to build your own web page with HTML](#build) 
* [What to learn next](#next-steps)

<a name="what-is"></a>

## What is HTML?

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as8uihqho875p06d7lz1.png)

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!  

<a name="terms"></a>

## 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! 

<br>

### 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>`. 


```html
<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
<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 

<br>

### 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 `" "`.

```html
<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.

```html
 <h1 style="color:green">Hello, World!</h1>
```

**Output:**

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7t0hb2n1dhs0zx4myou9.png)

> **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. 

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

<br>

### 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.

```html
<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:**

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kh4ldt0f2933a2vdq8q9.png)

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/brw4itgwwi4i1hmiqmtf.png)

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:

```html
<h1>Grocery Items</h1>
<ul>
    <li>Eggs</li>
    <li>Apples</li>
    <li>Carrots</li>
    <li>Noddles</li>
```

**Output:**

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7syrs3pet5lfx87faq1.png)

Ordered List with `<ol>` tag:

```html
<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:** 

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v37ullms0q81gl1u0a6h.png)

<br>

### 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.

```html
  <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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6arapvj13039ubeq8tg.png)

<br>

### 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.

```html
<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. 

```CSS
  <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:**

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r0fhvb2s6i8yts03mc7b.png)

<br>

### 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
<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:**

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qbztbi5mmq4urwwa2dja.png)

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.

<a name="build"></a>


## 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 

<br>

### 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. 

<br>

### 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:*

```html
<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:*

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e0z0e9lx897mfmf7gind.png)

<br>

### 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:*

```html
<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:*

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fl6jz4rnuzxt4mx32un7.png)

<br>

### 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:*

```html
<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:*

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itr0ub44vf1h58tdk8hd.png)

<br>

### 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:*

```html
<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:*

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1y989srjnkwmb05iqu0n.png)

<br>

### 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!

![HTML](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qclvqmwqvwm0oom3ogrk.png)

<br>

<a name="next"></a>


## 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](https://www.educative.io/path/zero-to-hero-in-front-end-web-development?utm_campaign=learn_to_code&utm_source=medium&utm_medium=text&utm_content=&utm_term=&eid=5082902844932096)** 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](https://www.educative.io/blog/beginner-guide-to-web-dev?eid=5082902844932096)
* [JavaScript Snake Game Tutorial: build a simple, interactive game](https://www.educative.io/blog/javascript-snake-game-tutorial?eid=5082902844932096)
* [Animate CSS code: create a panda animation with HTML & CSS](https://www.educative.io/blog/animate-css-code?eid=5082902844932096)

### 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!