HTML5 Tutorial for Beginners

Learn the Language of the Web

Every web page you have ever read is built with HTML. It is simpler than most people expect, and you can write your first page today.

This tutorial starts at the very beginning. It explains what HTML is, how it grew into HTML5, how to spot an outdated book, what the 30 most useful tags do, and how one page can fit a phone and a PC screen equally well.

<h1>Hello, world!</h1>
<p>This is my
first web page.</p>
<a href="next.html">
  Keep going
</a>

Part 1

What HTML Is

HTML stands for HyperText Markup Language. It is a way of labeling ordinary text so that a web browser knows what each part is. One label says that a line is a heading, another says that a block is a paragraph, and another says that a word is a link to a different page. The browser reads the labels and draws the page.

HTML is a markup language, not a programming language. It does not calculate anything or make decisions. It describes what the content is. Before computers, editors marked up a typed manuscript with notes for the typesetter, such as "make this a heading" or "set this in italics." HTML does the same job for a web browser.

"HyperText" means text that contains links. You click a link, and you jump to another page. Those links, joined together across millions of computers, are what make the web a web.

🏗️

HTML builds the structure.

HTML says what is on the page: headings, paragraphs, pictures, lists, links, and forms. Think of it as the frame and rooms of a house.

🎨

CSS sets the look.

CSS, which stands for Cascading Style Sheets, sets the colors, fonts, spacing, and layout. It is the paint, wallpaper, and furniture.

This page uses a shared style sheet named n-series.css.

⚡

JavaScript adds action.

JavaScript makes the page respond, such as opening a menu when you click it. It is the wiring and the light switches.

The Parts of a Tag

The labels in HTML are called tags. People sometimes call them commands, but they do not command anything. They simply name each part of the page. Most tags come in pairs that wrap around the content, like a pair of brackets.

The parts of an HTML element The line a href equals next.html, Keep going, closing a, is labeled to show the opening tag, the attribute name, the attribute value, the content, and the closing tag. All of it together is called an element. <a href = "next.html" > Keep going </a> Opening tag Content Closing tag Attribute name Attribute value The whole thing is called an element.
The closing tag has a forward slash. An attribute adds extra information, such as where a link should go.

A few tags stand alone. Tags such as <img> and <meta> have no content to wrap, so they have no closing tag. Older books wrote them as <img /> with a slash. HTML5 accepts that form, but it does not require the slash.

Part 2

What HTML Has Become

HTML began as a simple way for scientists to share papers. Over thirty years it grew into the foundation for nearly everything we do online, from banking to video calls. Here is how it got there.

  1. 1991
    The web is born.

    Tim Berners-Lee, a physicist at CERN in Switzerland, invented HTML so that researchers could link their documents together. The first version had fewer than twenty tags.

  2. 1995
    HTML 2.0 becomes a standard.

    The web was growing fast, so the rules were written down. Browsers such as Netscape began adding their own tags, and pages started to look different in each browser.

  3. 1997
    HTML 3.2 and HTML 4 arrive.

    Tables, colors, and fonts were added. The W3C, the World Wide Web Consortium, took charge of the standard. HTML 4.01 followed in 1999 and lasted for more than a decade.

  4. 2000
    XHTML tries strict rules.

    XHTML rewrote HTML with strict rules taken from XML. One small mistake could stop a page from showing. Many books from the 2000s teach XHTML.

  5. 2004
    Browser makers start HTML5.

    Apple, Mozilla, and Opera formed a group called the WHATWG. They wanted HTML to handle real web applications, not just documents.

  6. 2014
    HTML5 becomes the official standard.

    HTML5 added tags that describe the parts of a page, built-in video and audio, drawing with canvas, and better forms. Plug-ins such as Flash were no longer needed.

  7. 2019
    HTML becomes a living standard.

    The W3C and the WHATWG agreed to keep one version of HTML that is improved continually. There will be no HTML6. When people say HTML5 today, they mean modern HTML.

📱

One page fits every screen.

A single page adjusts itself for a phone, a tablet, or a large monitor.

🎬

Video and sound are built in.

The video and audio tags play media without any extra software.

🧭

Tags describe meaning.

Tags such as header, nav, and article tell browsers, search engines, and screen readers what each part is.

🧩

Pages can be programs.

Email, maps, and word processors now run inside a browser, all built on HTML.

Part 3

How to Spot an Outdated Book

Used bookstores and library sales are full of HTML books, and many of them are badly out of date. If a book was published before 2014, it probably teaches HTML 4 or XHTML. It will not cover the tags that describe a page's parts, media queries, or responsive design. Look for books and guides published in 2015 or later, and check for the signs below.

📕

Signs that a book is obsolete

  • It opens pages with a long header that mentions "XHTML 1.0 Transitional" or "HTML 4.01."
  • It uses <font>, <center>, or <big> to change how text looks.
  • It builds page layouts out of tables.
  • It teaches frames with <frameset>.
  • It recommends Flash for video or animation.
  • It designs pages for one screen size, such as 800 by 600 pixels.
  • It shows blinking or scrolling text with <blink> or <marquee>.
📗

Signs that a book is up to date

  • Every page starts with the short line <!DOCTYPE html>.
  • It uses <header>, <nav>, <main>, and <footer>.
  • It leaves all the styling to CSS.
  • It includes the viewport meta tag for phones.
  • It teaches media queries, Flexbox, and Grid for layout.
  • It uses <video> and <audio> for media.
  • It was published in 2015 or later.

Old books are not completely useless. Headings, paragraphs, links, images, and lists work almost exactly as they did in 1995. The parts that have changed are page layout, styling, and media. If you already own an old book, use it for the basics, and use the websites at the end of this page for everything else.

Part 4

The Basic Structure of an HTML5 Page

Every HTML5 page follows the same pattern. You can copy this outline, save it as a file ending in .html, and fill in your own content. The notes beside it explain each part.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0">
  <title>My Web Page</title>
</head>
<body>
  <header>Header content</header>
  <nav>Navigation links</nav>
  <main>
    <article>Main content</article>
    <aside>Sidebar info</aside>
  </main>
  <footer>Footer information</footer>
</body>
</html>
  1. The doctype tells the browser that this is a modern HTML5 page. Older pages needed a long, complicated line here.
  2. The html tag wraps the whole page. The lang attribute says the page is in English, which helps screen readers pronounce words correctly.
  3. The head holds information about the page that visitors do not see on the page itself.
  4. The charset line sets the character set to UTF-8, which handles every alphabet, accented letters, and emoji.
  5. The viewport line tells phones to show the page at the phone's true width instead of shrinking a desktop page down. Part 6 explains why this matters so much.
  6. The title appears on the browser tab and in search results.
  7. The body holds everything that visitors see. Inside it, the header, nav, main, article, aside, and footer tags name the parts of the page.

Part 5

The 30 Most Useful HTML5 Tags

These 30 tags will build almost any page you want to make. They are grouped by the job they do. Each one has a plain description and a short example that you can copy.

The page itself

These tags set up the document and its behind-the-scenes information.

<html>
The html tag is the root element. It wraps everything on the page except the doctype line.
<html lang="en"> ... </html>
<head>
The head is a container for information about the page, such as its title, its character set, and its style sheets. Nothing in the head appears on the page itself.
<head> ... </head>
<title>
The title is the name of the page. It shows on the browser tab, in bookmarks, and in search results.
<title>My Garden Notes</title>
<meta>
The meta tag gives the browser extra information, such as the character set, the viewport setting, or a short description for search engines. It has no closing tag.
<meta charset="UTF-8">
<link>
The link tag connects the page to an outside file. Its most common job is attaching a CSS style sheet.
<link rel="stylesheet" href="style.css">
<style>
The style tag holds CSS written directly inside the page. It is handy for styles that only one page uses.
<style> h1 { color: navy; } </style>
<script>
The script tag holds JavaScript code, or points to a JavaScript file. It is usually placed at the end of the body.
<script src="menu.js"></script>
<body>
The body holds all the content that visitors actually see, including text, pictures, links, and forms.
<body> ... </body>

The parts of a page

These are the new HTML5 tags that name each region of a page.

<header>
The header is the top section of a page or of an article. It usually holds a logo, a title, or an introduction.
<header><h1>Deepermind</h1></header>
<nav>
The nav tag holds the main navigation links, such as a site menu.
<nav><a href="index.html">Home</a></nav>
<main>
The main tag holds the primary content of the page. A page should have only one main.
<main> ... </main>
<article>
An article is a self-contained piece that would make sense on its own, such as a blog post, a news story, or a recipe.
<article><h2>Planting Tomatoes</h2> ... </article>
<section>
A section groups content on one theme, usually with its own heading. A long article might have several sections.
<section><h2>Watering</h2> ... </section>
<aside>
An aside holds content related to the main text but not part of it, such as a sidebar, a tip, or a callout box.
<aside>Tip: water in the morning.</aside>
<footer>
The footer is the bottom section of a page or of an article. It usually holds contact information, copyright notes, or related links.
<footer>&copy; 2026 Deepermind</footer>

Why do these tags matter if they look like plain boxes? They tell the browser what each part means. Search engines use them to find the main content, and screen readers for blind visitors use them to jump straight to the menu or the article. Old pages used a generic <div> for everything, which told the browser nothing.

Text and links

These tags carry the words on the page.

<h1> to <h6>
These six tags are headings. The h1 tag is the main title, h2 tags mark the major sections, and h3 through h6 mark smaller and smaller subsections. Use them in order, like an outline, and use them for structure rather than for size.
<h1>My Garden</h1>
<h2>Spring Planting</h2>
<p>
The p tag marks a paragraph. The browser adds space above and below it automatically.
<p>Tomatoes love the Texas sun.</p>
<a>
The a tag, short for anchor, makes a link to another page, another place on the same page, a file, or an email address. The href attribute says where the link goes.
<a href="https://www.deepermind.com">Visit Deepermind</a>
<a href="#tags">Jump to the tags</a>

Pictures and lists

These tags show images and organize items into lists.

<img>
The img tag shows a picture. The src attribute names the file, and the alt attribute describes the picture for anyone who cannot see it. The style in this example lets the picture shrink on a small screen but never grow past 400 pixels wide.
<img src="pic.jpg" alt="My Picture"
     style="width:100%; max-width:400px;">
<ul>
The ul tag makes an unordered list, which is a list with bullets. Use it when the order of the items does not matter.
<ul>
  <li>Basil</li>
  <li>Rosemary</li>
</ul>
<ol>
The ol tag makes an ordered list, which is a numbered list. Use it for steps that must happen in order.
<ol>
  <li>Dig the hole.</li>
  <li>Plant the seed.</li>
</ol>
<li>
The li tag marks one list item. It always sits inside a ul or an ol.
<li>Water twice a week.</li>

Tables

These tags arrange data into rows and columns.

<table>
The table tag holds a data table, such as a schedule or a price list. In HTML5, tables are for data only and should not be used to lay out a page.
<table> ... </table>
<tr>
The tr tag, short for table row, holds one row of cells.
<tr> ... </tr>
<td>
The td tag, short for table data, holds one cell. A related tag, th, marks a heading cell at the top of a column.
<table>
  <tr><th>Club</th><th>Meets</th></tr>
  <tr><td>Plano</td><td>3rd Monday</td></tr>
</table>

Forms

These tags let visitors type information and send it.

<form>
The form tag wraps a group of input fields and says where to send the answers when the visitor presses the button.
<form action="/send" method="post"> ... </form>
<input>
The input tag makes a field where the visitor types or chooses something. HTML5 added many types, such as email, date, and number, and phones show a matching keyboard for each one.
<input type="email" id="email" required>
<button>
The button tag makes a clickable button. Inside a form, it sends the form.
<button type="submit">Send</button>
<label>
The label tag names an input field. Its for attribute matches the input's id, so clicking the label puts the cursor in the field.
<label for="email">Your email</label>

Drawing

This tag gives JavaScript a surface to draw on.

<canvas>
The canvas tag is a blank drawing surface. JavaScript draws shapes, pictures, charts, and even games on it. The next section shows a working example.
<canvas id="myCanvas" width="400" height="200"></canvas>

How the Canvas Tag Works

The canvas tag lets JavaScript draw shapes, images, and text. You set the size of the canvas in HTML, and then you draw on it with JavaScript. The code on the left is running right now and drew the picture on the right.

<canvas id="myCanvas" width="400" height="200"></canvas>

<script>
// Find the canvas and get its 2D drawing tools.
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");

// Fill a red rectangle: left, top, width, height.
ctx.fillStyle = "red";
ctx.fillRect(10, 10, 150, 100);
</script>
Your browser does not support the canvas tag.

The rectangle starts 10 pixels from the left and 10 pixels from the top. It is 150 pixels wide and 100 pixels tall.

Part 6

One Page for Every Screen

In the early days, a web page was designed for one monitor size, and everyone else had to scroll sideways or squint. Today a single page can look at the screen it is on and arrange itself to fit. On a PC monitor it spreads out into columns, and on a cell phone it stacks into one tidy column. This is called responsive design, and HTML5 with CSS3 makes it practical.

The same page on a monitor, a tablet, and a phone On the monitor, three content boxes sit side by side. On the tablet, two boxes sit on top and one below. On the phone, all three boxes stack in a single column. PC monitor: three columns Tablet: two columns Phone: one column
The HTML is exactly the same in all three. Only the CSS rules change with the width of the screen.

The Four Tools of Responsive Design

1

The viewport line tells phones the truth.

Without this line in the head, a phone pretends to be a wide desktop screen and shrinks the whole page until the text is too small to read. With it, the phone shows the page at its real width.

<meta name="viewport"
      content="width=device-width, initial-scale=1">
2

Flexible sizes stretch and shrink.

Use percentages instead of fixed pixels so that content resizes with the screen. Add a maximum width so that text lines never grow too long to read comfortably on a big monitor.

.container {
  width: 90%;
  max-width: 960px;
  margin: auto;
}
img { max-width: 100%; }
3

Flexbox and Grid arrange the boxes.

Flexbox lines items up in a row that can wrap onto new lines. Grid lays items out in rows and columns, like a table that rearranges itself. This rule fits as many columns as the screen allows, each at least 250 pixels wide.

.cards {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}
4

Media queries change the rules.

A media query is an "if" for CSS. It says that when the screen is narrower than a certain width, these other rules apply. Here, three columns become one on any screen narrower than 760 pixels.

.cards { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; }
}

You can try it right here.

These three boxes use the media query from tool 4. On a PC, drag the edge of your browser window to make it narrow, and watch the boxes stack into one column. On a phone, they are already stacked.

Box one
Box two
Box three

Your window is wide, so the boxes sit side by side.Your window is narrow, so the boxes are stacked.

Many designers now start with the phone. This approach is called mobile first. You write the simple one-column layout first, and then you add media queries that spread things out as the screen gets wider. Small screens get a light, fast page, and large screens get the extra columns.

Part 7

Make Your First Page Today

You do not need to buy anything. A free editor and the browser you already have are enough.

1💾

Install a code editor.

Visual Studio Code is free and works on Windows, Mac, and Linux. It colors your tags so mistakes are easy to see. Plain Notepad also works if you want to start right away.

2📁

Make a folder for your site.

Create a new folder, such as My Website, and open it in your editor. Keep every page and picture for the site in this folder.

3📝

Paste in the basic structure.

Copy the outline from Part 4 into a new file and save it as index.html. Change the title, and write a heading and a paragraph inside the body.

4🌐

Open it in your browser.

Double-click the file, and your browser shows the page. In VS Code, the Live Server extension refreshes the page every time you save.

5✅

Check your work.

Paste your code into the W3C Markup Validator, listed below. It points out missing closing tags and other mistakes, and it explains each one.

6📱

Test it on a small screen.

Narrow your browser window, or press F12 in Chrome or Edge and click the phone icon. You will see how the page looks on a cell phone.

Part 8

The Best Websites for Learning HTML

All of these sites teach modern HTML5, and all of them are free to use. If you only pick one, start with the MDN beginner course or web.dev, and keep the MDN reference open while you work.

"HTML is a set of labels that tell a browser what each piece of your writing is. Learn the labels, and you can publish anything to the whole world."

Deepermind

Your First Page Is One File Away

Open an editor, paste in the basic structure, and write a single paragraph. When it appears in your browser, you are a web author.