HTML Beginner
HTML Beginner
Amanda Fawcett
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.
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.
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!
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.
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>.
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
1
2
<p><strong>These tags are nested properly.</strong></p>
<p>This tag is not nested.</p>
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
1
2
<h1 style="color:green">Hello, World!</h1>
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>
Note: Headers are used to represent text semantically. This is different than specifying
font size. We use CSS to change font size.
HTML
Output
1
2
3
4
5
6
<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>
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
1
2
3
4
5
6
7
<h1>Grocery Items</h1>
<ul>
<li>Eggs</li>
<li>Apples</li>
<li>Carrots</li>
<li>Noddles</li>
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.
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
1
2
3
4
5
6
7
8
9
10
11
12
<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>
HTML
1
2
3
4
5
6
7
8
9
10
<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>
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.
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.
Output
Example output
OutputHTML
1
2
3
4
5
6
7
8
9
10
<!-- type your HTMl code here, will require 10 lines of code -->
Test
Show Solution
Output
Example output
OutputHTML
1
2
3
4
5
6
7
8
9
10
11
<!-- type your HTMl code here, will require 11 lines of code, including
what you have above. -->
Test
Show Solution
Output
Example output
OutputHTML
1
2
3
4
5
6
7
8
9
10
<!-- type your HTMl code here, will require 18 lines of code, including
what you created above -->
Test
Show Solution
Output
OutputHTML
1
2
3
4
5
6
7
8
9
10
<!-- type your HTMl code here, will require 40 lines of code, including
what you created above -->
Test
Show Solution
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!