What is HTML and how does a web page work
Learn what HTML is, how a browser turns tags into a page, and write your first live edit.
In this lesson you will
- Explain what HTML does in one sentence
- Tell HTML, CSS and JavaScript apart
- Read an element, a tag and an attribute
- Edit a real page in the live editor
About 9 minutes
What HTML actually is
HTML stands for HyperText Markup Language. Every web page you have ever opened, from a search result to an online shop to this lesson, is built on it. HTML is the part of a page that says what things are: this is a heading, this is a paragraph, this is a link, this is a picture.
It is a markup language, not a programming language. You do not write instructions such as “if this, then that”. You wrap your content in labels called tags, and the browser reads those labels and decides how to show the content. That is why HTML is the gentlest place to start. There is no maths, no hidden logic, and you see the result the moment you save the file.
The three languages of the web
A page is almost always made from three technologies that work together. Think of a house.
| Language | Job | House comparison |
|---|---|---|
| HTML | Structure and content | The walls, rooms and doors |
| CSS | Looks: colour, spacing, fonts, layout | Paint, furniture and decoration |
| JavaScript | Behaviour: things that react to the visitor | Electricity, lights and the doorbell |
You will learn all three on this site, and HTML always comes first because CSS and JavaScript both need something to style and control. A page with only HTML still works. A page with only CSS shows nothing at all.
What a browser does with your HTML
When you type an address and press Enter, a server sends your browser a plain text file. The browser reads it from top to bottom, builds an internal map of every element called the DOM (Document Object Model), and paints that map on the screen. If you change the file and refresh, the browser repeats the process. That is the whole loop: write text, save, refresh, look.
- You write HTML in a plain text file ending in
.html. - The browser reads the file from the top and spots every tag.
- It builds the DOM, a tree of boxes: the page contains a body, the body contains a heading, and so on.
- It adds default styling, then any CSS you wrote, and draws the result.
Anatomy of a tag
Most HTML elements have an opening tag, some content, and a closing tag. The closing tag looks the same as the opening one with a forward slash added.
<p>Hello, world.</p>
Here <p> opens a paragraph, Hello, world. is the content, and </p> closes it. Together the three parts are called an element. Some elements carry extra information inside the opening tag in the form of attributes:
<a href="https://example.com" target="_blank">Visit the example site</a>
The attribute href holds the destination, and target says to open it in a new tab. An attribute is always a name, an equals sign, and a value in quotes. A few elements, such as the line break <br> and the image <img>, have no content and no closing tag. They are called void elements.
Browsers accept <P> and <p> equally. Almost every professional project uses lower case, so build the habit from day one and your code will look like theirs.
Elements can sit inside other elements
Elements nest like boxes inside boxes. The inner box must be fully closed before the outer one closes. This is the rule beginners break most often, so study this example carefully.
<p>I love <strong>learning HTML</strong> every day.</p>
<p>I love <strong>learning HTML</p></strong>
Always close the inside element first. Think of it as taking off your shoes before your socks in reverse order: whatever you opened last gets closed first. Browsers try to guess what you meant when tags overlap, but the guess is often wrong and different browsers can guess differently.
Your first live edit
Below is a working editor. The panel on the right is a real browser rendering whatever you type, and it updates as you type. Nothing you do here can break anything, and the Reset button restores the starting code.
Change the text inside the heading to your own name, then add a second paragraph below it that says what you want to learn.
<h1>Hello, world</h1>
<p>This is my very first web page.</p>
A paragraph is a <p> element. Type a new line after the existing paragraph and write <p>Your sentence</p>.
<h1>Hello, I am Sam</h1>
<p>This is my very first web page.</p>
<p>I want to learn how to build websites.</p>
What you can build with HTML
HTML on its own can produce a lot more than most people expect. Articles, documentation, résumés, recipe pages, event invitations, simple portfolios, and email templates are all HTML at heart. Add CSS and you can make any of them look professional. Add JavaScript and they become interactive apps. The skills compound, and the career paths are real: front-end developer, WordPress developer, email developer, technical writer, and freelance web designer all start with exactly what you are learning today.
What you will need
- A computer, tablet or even a phone. The editors in these lessons run in your browser.
- A modern browser such as Chrome, Edge, Firefox or Safari.
- A plain text editor for the next lesson. Visual Studio Code is free and is what most professionals use.
- About fifteen minutes a day. Short, regular practice beats one long weekend session.
You do not need to memorise every tag. Working developers look things up all day. What matters is understanding the pattern: opening tag, content, closing tag, attributes in the opening tag. Once that is second nature, any new element is easy.
Five facts to carry forward
- HTML describes the meaning and structure of content. It does not make decisions.
- Tags such as
<h1>and<p>label parts of the page. - Elements nest, and inner elements must close before outer ones.
- Attributes add extra information to an element, always inside the opening tag.
- The browser reads top to bottom and draws what it finds.
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What does HTML describe?
- How a page looks, such as colours and fonts
- The structure and meaning of the content
- What happens when a visitor clicks a button
- How fast a page loads
HTML labels the content: this is a heading, this is a paragraph. Colours are CSS and behaviour is JavaScript.
Which is a complete HTML element?
<p>HelloHello</p><p>Hello</p>p Hello p
An element is the opening tag, the content and the closing tag together.
Which tag is NOT correctly nested?
<p>a <b>b</b></p><p>a <b>b</p></b><div><p>a</p></div><ul><li>a</li></ul>
The <b> was opened inside the paragraph, so it must be closed before the paragraph closes.
In <a href="x.html">Go</a>, what is href?
- A tag
- An attribute
- An element
- A comment
Attributes live inside the opening tag and take the form name=”value”.
Which language makes a page react when a visitor clicks something?
- HTML
- CSS
- JavaScript
- XML
JavaScript adds behaviour. HTML gives structure and CSS gives style.
Summary
- HTML marks up content so a browser knows what each part is.
- An element is an opening tag, content and a closing tag.
- Attributes add detail and sit in the opening tag.
- CSS styles a page and JavaScript makes it interactive; HTML is the foundation.
Questions
Is HTML a programming language?
No. HTML describes structure and meaning, and has no logic such as loops or conditions. That is why it is a friendly first step, and why you will usually pair it with JavaScript later.
Do I need to pay for any software?
No. A browser and a free editor such as Visual Studio Code are enough, and you can practise right here in the lesson editors without installing anything.
How long does it take to learn HTML?
Most people grasp the basics in a week of short daily sessions and can build a simple, good-looking page within a month once CSS is added.
What is the DOM?
The Document Object Model is the tree of elements the browser builds from your HTML. JavaScript can read and change it, which is how pages become interactive.
