HTML Basics With Cheatsheet
Tags: html, tutorial, beginners, webdev
Published: 2020-09-09 22:43:16

---
title: HTML Basics With Cheatsheet
published: true
date: 2020-08-28 02:05:13 UTC
tags: html, tutorial, beginner, webdev
canonical_url: https://www.risingblock.com/html-basics-with-cheatsheet
series: web-fundamentals
cover-image: https://i.imgur.com/aqHlreo.jpg
---

![](https://www.risingblock.com/wp-content/uploads/2020/08/html-basics-1024x734.jpg)

In this post, we’re going to cover HTML basics. Download the [cheatsheet for HTML basics here](https://www.risingblock.com/html-basics-with-cheatsheet).

## What is HTML? 

HTML is the structure & content of the webpage.

This includes the words, buttons, images, lists, forms and more.

It does not include styling like padding, sizing, grids, margins, fonts, etc.

## HTML Tags

Let’s do a deep dive into the basic HTML tags.

### HTML & Body Tag

All your HTML code should be enclosed in html tags. 

Anything visible on the screen should be enclosed inside a body tag. Otherwise, you could run into some unexpected bugs on some browsers.

So let’s make our basic website like this:

{% codepen https://codepen.io/rising_block/pen/wvGdYLB default-tab=html,result %}

**Remember to save your file in your text editor & refresh your page in your browser after every change.**

### Headings

There are 6 heading tags in HTML. They go from h1 all the way to h6. H1 is the largest heading, think of it as the page title. H2 is the subtitle and so on for h3, h4, h5, h6.

Try adding these headers to your website:

{% codepen https://codepen.io/rising_block/pen/RwaVqbO default-tab=html,result %}

### Divs

Dividers or divs separate your page into different sections. They act as containers to group together HTML elements.

By themselves, they don’t have any visual effect.

Divs can contain any kind or combination of HTML elements. I would say divs are the most used element in HTML.

Let’s modify our website to include some divs.

{% codepen https://codepen.io/rising_block/pen/ZEWKmbJ default-tab=html,result %}

Notice how the spacing of our HTML file now. We do this so it’s easy to read and we can easily tell what’s inside each div. It is recommended you do the same. Atom even has a [beautify plugin](https://atom.io/packages/atom-beautify) to do this for you automatically.

You may think this kind of useless, the website looks the exact same. So I’m going to _cheat a little_ and add some background color so you can visually see why this would be important.

{% codepen https://codepen.io/rising_block/pen/wvGdQMK default-tab=html,result %}

Don’t worry too much about the colors right now – I’ll be teaching you that in the CSS posts.

The main takeaway is that divs allow us to break our web page into different sections.

### Paragraphs 

Paragraphs can be created by using the p tag. They have some space before and after – like a paragraph in word document.

Try adding some paragraphs to your website.

{% codepen https://codepen.io/rising_block/pen/zYqwMqW default-tab=html,result %}

### Spans

Spans are inline elements, unlike paragraphs there is no space before and after them.

It’s used to group elements _inline_ – kind of like an inline div. There is no visual representation of a span by itself.

Try it out:

{% codepen https://codepen.io/rising_block/pen/vYGmQKw default-tab=html,result %}

Like the div, I’m going to cheat a bit and add a background color so you can “see” the span.

{% codepen https://codepen.io/rising_block/pen/wvGdQzM default-tab=html,result %}

Don’t worry, we’ll be covering how to add colors soon.

### Bold

The bold tag is a simple b. It makes text bold.

{% codepen https://codepen.io/rising_block/pen/NWNjEyd default-tab=html,result %}

### Italics

The italics tag is a simple i. Makes text italics.

{% codepen https://codepen.io/rising_block/pen/QWNvJJq default-tab=html,result %}

### Line break

The line break tag is a br. This adds a new line. **This is a special tag because it is “self-closing”**. The opening tag and the closing tag are the same! That’s why we have the slash after the “br”. Note: The self-closing slash is optional. 

{% codepen https://codepen.io/rising_block/pen/OJNmarb default-tab=html,result %}

## Lists

In HTML, there are two kinds of lists, ordered and unordered lists.

### Ordered List

You can think of ordered lists as numbered lists. Just like this:

1. One
2. Two
3. Three

Ordered lists use the tag ol. Lists in HTML must contain list items, which we represent with the li tag.

{% codepen https://codepen.io/rising_block/pen/XWdRyGy default-tab=html,result %}

### Unordered List

You can think of unordered lists as bullet points:

- Just
- Like
- This

Unordered lists use the tag ul. They also contain list items, which use the same tag li.

{% codepen https://codepen.io/rising_block/pen/oNxWQOv default-tab=html,result %}

## Multi-media

### Images

They say an image is worth a thousand words…

Here’s how you add them in HTML. Use the img tag but then set the **attribute src** to the URL. I’m going to use an image I uploaded to [imgur.com](https://imgur.com/) (a free image uploading website).

{% codepen https://codepen.io/rising_block/pen/mdPmQYP default-tab=html,result %}

Notice that the image tag is also self-closing, we add a “/” to the end of the tag.

The direct URL to the image is surrounded in quotes (“”) and set to the src with an equal sign (=).

Note that the image location must be direct and end in an image extension (for example: .jpg, .png, .gif).

To get the direct image link to any image the internet, right click it in your browser and select _Copy Image Address_.

![](https://www.risingblock.com/wp-content/uploads/2020/08/image-2-1024x590.png)

### Videos

To add a video, use the video tag. You’ll have to set the **src** to a direct link to the video. Also, remember to add the **controls** attribute, otherwise, the user will not be able to play the video.

{% codepen https://codepen.io/rising_block/pen/ExKmOBM default-tab=html,result %}

Not all browsers support the video tag. You’ll want to change the video tag from a self-closing one to a normal tag. Inside this video tag, you’ll write an error message if the browser cannot play the video.

{% codepen https://codepen.io/rising_block/pen/vYGmQoL default-tab=html,result %}

## Challenge

Try making a website with all of the HTML elements listed on this page!

Make it about whatever you want, your favorite hobby, or something work-related.

Download the [cheatsheet for HTML basics here](https://www.risingblock.com/html-basics-with-cheatsheet).