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.
HTML5 Tutorial for Beginners
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
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 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, 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 makes the page respond, such as opening a menu when you click it. It is the wiring and the light switches.
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.
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
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.
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.
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.
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.
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.
Apple, Mozilla, and Opera formed a group called the WHATWG. They wanted HTML to handle real web applications, not just documents.
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.
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.
A single page adjusts itself for a phone, a tablet, or a large monitor.
The video and audio tags play media without any extra software.
Tags such as header, nav, and article tell browsers, search engines, and screen readers what each part is.
Email, maps, and word processors now run inside a browser, all built on HTML.
Part 3
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.
<font>, <center>, or <big> to change how text looks.<frameset>.<blink> or <marquee>.<!DOCTYPE html>.<header>, <nav>, <main>, and <footer>.<video> and <audio> for media.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
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>
Part 5
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.
These tags set up the document and its behind-the-scenes information.
These are the new HTML5 tags that name each region of a page.
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.
These tags carry the words on the page.
These tags show images and organize items into lists.
These tags arrange data into rows and columns.
These tags let visitors type information and send it.
This tag gives JavaScript a surface to draw on.
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>
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
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.
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">
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%; }
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;
}
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; }
}
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.
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
You do not need to buy anything. A free editor and the browser you already have are enough.
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.
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.
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.
Double-click the file, and your browser shows the page. In VS Code, the Live Server extension refreshes the page every time you save.
Paste your code into the W3C Markup Validator, listed below. It points out missing closing tags and other mistakes, and it explains each one.
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
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."
DeepermindOpen an editor, paste in the basic structure, and write a single paragraph. When it appears in your browser, you are a web author.