HTML Tutorial for Beginners: Your First Web Page
HTML (HyperText Markup Language) describes the structure of a web page: this is a heading, this is a paragraph, this is a link. It is not a programming language; it has no variables or loops. CSS then controls how the page looks, and JavaScript adds behavior. Every page on the web, however complex, is HTML underneath.
Tags and elements
HTML is written with tags in angle brackets. Most come in pairs: <p> opens a paragraph and </p> closes it, with the content in between. The opening tag, content and closing tag together form an element. Elements nest inside each other like boxes, and they must close in the reverse order they opened.
The page skeleton
Every HTML document has the same outline:
<!DOCTYPE html>on the first line tells the browser to use modern standards mode. Without it, browsers fall back to "quirks mode", which imitates very old browsers.<html lang="en">wraps the whole page. Thelangattribute tells screen readers and translation tools which language the text is in.<head>holds information about the page that is not displayed in it: the character encoding and the title shown in the browser tab.<body>holds everything visitors see.
Expected page text
Hello, web! This page was written by hand in HTML.
Press Run to render the page in the preview below the editor. Change the heading text and run again. Notice that the <title> text does not appear in the preview itself; in a real browser it would label the tab.
Making a page on your computer
Open any plain-text editor (VS Code is a popular free choice; avoid word processors), paste the example, and save it as index.html. Double-click the file and it opens in your browser. Edit, save and reload to see changes. That is the whole development loop for a static page.
How browsers read HTML
Browsers are forgiving: a missing closing tag or a misspelled element usually still displays something, because the HTML standard defines exactly how to recover from errors. That forgiveness hides mistakes, though, so write clean markup and check it with a validator such as the W3C one.
Common mistakes
- Saving the file as
index.html.txt. Make sure the extension is.html. - Putting visible content inside
<head>. - Forgetting the doctype, which can make layouts behave strangely.
Summary
- HTML structures content with elements made of tags.
- A page has a doctype, then
<html>containing<head>and<body>. - Only the body is displayed; the head describes the page.
Quiz: Get started