Accent colour
 
Shortcuts: press ?
 

HTML Explained — The Language That Structures Every Web Page

Muhammad Tahir November 26, 2026

Introduction

Open any web page, right-click, and choose "View page source". What you see is mostly plain English words wrapped in angle brackets. That is HTML. It is not a secret code, and it is not really a programming language either, though plenty of people call it one by mistake. It is a way of labelling pieces of text so a browser knows what each piece is: this is a heading, this is a paragraph, this is a link, this is a picture.

Every page you have ever visited — a news article, a shop, a bank login, a recipe blog — is built on HTML. The colours, the layout, the animations and the buttons that do things all sit on top of it, but the HTML comes first. Without it, a browser would just have a lump of unlabelled text and no idea where one thing ends and another begins.

This article explains HTML the way you would explain it to a friend who has never written a line of code: what it is, where it came from, how its pieces fit together, and the mistakes beginners make most often. No prior knowledge needed, and no jargon left unexplained.

What HTML Actually Is

HTML stands for HyperText Markup Language. The name sounds grand, but each word is doing ordinary work. "HyperText" means text with links in it — words you can click to jump somewhere else. "Markup" means labels added to text to say what it is. "Language" just means it has rules.

Think of it like the stage directions in a play script. The actors' lines are the content; the directions in brackets tell everyone how the lines should be treated. HTML tags are those directions. The words <h1>Welcome to my bakery</h1> are not shown with the brackets on the page; the browser reads the tags and shows "Welcome to my bakery" as a big heading instead. That is the whole trick: you write text, wrap the parts that need meaning in tags, and the browser does the rest.

A Short History: From a Lab in Switzerland to Every Screen

HTML was invented by Tim Berners-Lee, a physicist working at CERN, the European physics lab near Geneva. In 1989 he wrote a proposal for a system that would let researchers share documents over the network, with links between them. The first version of HTML appeared in 1991, along with the first web page, and it had just eighteen tags. Headings, paragraphs, links, lists — the basics were there from the start.

The web grew fast, and HTML grew with it, messily. HTML 2.0 arrived in 1995 as the first formal standard. HTML 4.01 followed in 1999 and stayed in use for years. In between, browser makers added their own tags to outdo each other, which meant a page could look fine in one browser and broken in another.

There was also a detour. In the early 2000s, a stricter version called XHTML tried to force HTML to follow the rigid rules of XML — every tag closed, every attribute quoted. It never really took hold for everyday pages, because browsers had to keep accepting sloppy pages anyway, and most authors found the strictness more trouble than it was worth.

The fix came from the browser makers themselves. In 2004, a group at the WHATWG — the Web Hypertext Application Technology Working Group, formed by people from Apple, Mozilla and Opera — started work on what became HTML5. The W3C published HTML5 as a standard in October 2014, adding new tags for video, audio and page structure. Today HTML is maintained as a "living standard" by the WHATWG, updated continuously rather than in big numbered releases. There will probably never be an HTML6.

Tags, Elements and Attributes: The Basic Grammar

Almost everything in HTML follows one pattern. An opening tag, some content, and a closing tag with a forward slash:

<p>This is a paragraph.</p>

The opening tag, the content and the closing tag together make an element. The tag name tells the browser what kind of element it is. <p> is a paragraph. <h2> is a second-level heading. <a> is a link. <strong> is strongly emphasised text, usually shown bold.

Some elements have no content and no closing tag. An image, for instance, is written as <img src="cat.jpg" alt="A tabby cat asleep on a sofa"> and that is the whole element. These are called void elements, and they include line breaks (<br>), horizontal rules (<hr>) and form inputs (<input>).

Tags can carry extra information in attributes. An attribute sits inside the opening tag as a name and a value in quotes. In the image example above, src says where the picture file lives and alt gives a text description of it. In a link, href says where the link goes: <a href="https://example.com">Visit our shop</a>. The value is always in quotes — single or double, it does not matter, as long as they match.

Elements nest inside each other, like boxes inside boxes. A list item sits inside a list; a link can sit inside a paragraph; a bold word can sit inside a heading. The one hard rule is that nesting must close in reverse order. If you open a paragraph and then open a bold tag inside it, the bold tag closes first:

<p>Our shop opens at <strong>nine in the morning</strong> every day.</p>

The Skeleton of Every Page

Every HTML page, from a one-line test file to the front page of a newspaper, has the same skeleton. It looks like this:

<!DOCTYPE html>

<html lang="en">

<head>

<title>My Bakery — Fresh Bread Every Morning</title>

<meta charset="utf-8">

</head>

<body>

<h1>Welcome to my bakery</h1>

<p>We bake sourdough every morning at six.</p>

</body>

</html>

The first line, <!DOCTYPE html>, is not a tag. It is a declaration that tells the browser "this is a modern HTML page, render it in standards mode". Leave it out and older browsers fall back to a quirks mode that mimics the bugs of the 1990s. It costs one line, and there is no reason to skip it.

The <html> element wraps everything. The lang="en" attribute says the page is in English, which helps screen readers pronounce words correctly and helps search engines file the page under the right language.

Inside it there are two parts. The <head> holds information about the page that visitors do not see directly: the title that appears in the browser tab, the character encoding, links to stylesheets, and a description for search results. The <body> holds everything visitors do see: headings, text, pictures, links, buttons.

Two head elements deserve a mention because beginners meet them early. The <meta charset="utf-8"> line tells the browser the page uses UTF-8 encoding, which covers nearly every character in every language — without it, an apostrophe or an accented letter can turn into a black diamond with a question mark. And the viewport tag, <meta name="viewport" content="width=device-width, initial-scale=1">, tells phones to show the page at its real width instead of shrinking a desktop layout down to fit.

Headings, Paragraphs and Links: The Everyday Workhorses

Most of the words on most pages live inside just three kinds of element. Learn these and you can build a readable page.

Headings run from <h1> down to <h6>. The <h1> is the main title of the page, and there should be exactly one of it. Then <h2> marks the big sections, <h3> marks subsections inside those, and so on down. The numbers are about importance and structure, not size — you can make an <h2> look any size you like with styling later. Skipping from an <h1> straight to an <h4> because you liked the size is a common beginner mistake, and it confuses screen readers, which use headings as a table of contents.

Paragraphs are <p>. One idea, one paragraph. Browsers put a gap between paragraphs automatically. If you want a line break inside a paragraph without starting a new one — an address, for instance, or a line of a poem — use <br>. But a <br> is not a substitute for a new paragraph, and a run of empty paragraphs is not a substitute for proper spacing.

Links are <a>, short for anchor, with the destination in the href attribute. A link can point to another page on your own site, to a page on another site, to a spot further down the same page, or to an email address. The clickable text — the part between the tags — should say where the link goes. "Read our delivery information" is a good link. "Click here" is a bad one, because a person using a screen reader, which often reads out a list of links on their own, hears "click here, click here, click here" and learns nothing.

Images and Lists

A page of unbroken text is hard work to read, so HTML gives you a few ways to break it up. Images are the obvious one. The <img> tag needs two attributes at minimum: src, the address of the image file, and alt, a short description of what the picture shows.

The alt text matters more than most beginners think. If the image fails to load, the browser shows the alt text instead. A screen reader reads it aloud to someone who cannot see the picture. A search engine uses it to understand what the image is about. So write it as if you were describing the picture to someone on the phone: "A loaf of sourdough on a wooden board" is useful; "image" is not. If a picture is purely decorative, give it an empty alt attribute, alt="", which tells a screen reader to skip it.

Lists come in two kinds. An unordered list, <ul>, is for items with no particular order, shown with bullet points. An ordered list, <ol>, is for items where the order matters — steps in a recipe, for example — and the browser numbers them for you. Each item goes in an <li> tag. Lists are used far more often than beginners expect: navigation menus are usually lists, and so are the bullet points in a product description.

Forms: Where Pages Talk Back

Everything so far has been one-way: the page shows you things. Forms are where the page asks you something back. A search box, a login, a checkout, a newsletter signup — all forms.

A form is wrapped in a <form> element, and inside it sit the controls: text boxes, dropdowns, checkboxes, radio buttons, and a submit button. The most common control is <input>, whose type attribute says what kind of input it is. A text field is type="text". An email field is type="email", and the browser will check that what was typed looks like an email address before the form is sent. A password field is type="password", which hides the characters as they are typed. A date picker is type="date". Picking the right type gets you free checking and a better keyboard on phones — an email field brings up a keyboard with an @ key, for instance — without writing any extra code.

Every input needs a <label> attached to it, and this is where most forms go wrong. A label is the text next to the box — "Your email address", "Delivery postcode" — linked to its input with a for attribute matching the input's id. That link does two useful things: clicking the label puts the cursor in the box, and a screen reader announces the label when the user reaches the field. A box with no label is a guessing game.

Two small attributes do a lot of heavy lifting in forms. required stops the form being sent until the field is filled in. placeholder shows a hint inside an empty box, like "name@example.com" — but a placeholder is a hint, not a label, because it disappears the moment someone starts typing.

Semantic HTML: Giving Meaning, Not Just Looks

For years, web pages were built almost entirely out of <div> elements — plain boxes with no meaning of their own — with class names doing all the work: <div class="header">, <div class="nav">, <div class="footer">. It worked, but the browser had no idea what any of those boxes were. To a screen reader or a search engine, a page was one big pile of divs.

HTML5 added semantic tags: elements whose names say what they are. A <header> is the top of a page or a section. A <nav> holds navigation links. A <main> holds the central content of the page, and there is only one of it. An <article> is a self-contained piece of content, like a blog post or a news story. A <section> groups related content under a heading. An <aside> holds content related to the main content but not part of it, like a sidebar. A <footer> is the bottom of a page or a section.

None of these tags looks any different from a <div> on its own — they are plain boxes until styled. The difference is what they tell machines. A screen reader can offer a shortcut: jump straight to the main content, skip the navigation, list all the articles. A search engine can tell the headline of an article from a heading in a sidebar. That is why the choice of tag matters even when the page looks the same either way, and it is a large part of what web accessibility means in practice.

The <div> still has a place. When you need a box purely for styling — to group things for layout, with no meaning of its own — a div is the right tool. The mistake is using divs for everything. A good rule of thumb: if there is a tag that says what the thing is, use that tag.

HTML, CSS and JavaScript: Three Jobs, Not One

Beginners often ask whether they should learn HTML or CSS first, as if it were a choice. It is not a choice; they are three parts of the same page, each with a job the others cannot do.

HTML gives the page its structure and meaning. CSS — Cascading Style Sheets — gives it its looks: colours, fonts, spacing, layout. JavaScript gives it behaviour: things that happen when you click, type or scroll. A page with only HTML is readable but plain, like a typed letter. Add CSS and it becomes a designed document. Add JavaScript and it can respond.

Keeping the three separate makes pages easier to fix. If the text is wrong, you change the HTML. If the colour is wrong, you change the CSS. If a button does nothing when clicked, you look at the JavaScript. When beginners mix them — writing a page where every paragraph carries its own font and colour written into the HTML — a small change means editing every paragraph by hand. A single stylesheet can change the look of a thousand pages at once.

What HTML Cannot Do, and the Mistakes Beginners Make

HTML's limits are worth knowing, because they save you from blaming the wrong tool. HTML cannot remember anything. Close the page and everything you typed into a form is gone, unless something else — usually JavaScript talking to a server — saved it. HTML cannot check that a password is correct, take a payment, or send an email. It can build the form that collects the details, but the work after the submit button belongs elsewhere.

The mistakes beginners make are mostly the same few, and they are all easy to avoid once you know them:

  • Forgetting to close a tag, so everything after it gets swallowed into the wrong element.
  • Using a heading because of its size instead of its place in the structure.
  • Writing "click here" as a link, or leaving images without alt text.
  • Copying and pasting from a word processor, which brings along a pile of hidden formatting that breaks the page.
  • Building a whole layout out of tables, or out of divs when semantic tags would say what things are.

None of these will break the web. Browsers are remarkably forgiving — a page with mistakes usually still shows something. But forgiving is not the same as fine. A page with broken structure is harder for search engines to understand, harder for assistive technology to read, and harder for the next person to fix. Clean HTML is a kindness to everyone who meets the page after you, including future you.

Frequently Asked Questions

Is HTML a programming language?

Strictly speaking, no. Programming languages have logic: conditions, loops, variables. HTML has none of those. It is a markup language, which means it labels and structures content. That distinction matters less than people think — you still have to learn it properly to build a web page — but it explains why HTML is a good first step into web development and why it is usually learned alongside CSS and JavaScript rather than on its own.

Do I need to memorise every HTML tag?

No, and working developers do not. There are around a hundred tags in total, but most pages are built from about twenty of them: headings, paragraphs, links, images, lists, forms, and the semantic tags for page structure. The rest you look up when you need them, which is what every developer does. What matters is understanding how elements, attributes and nesting work, because that pattern is the same for every tag.

What is the difference between HTML and HTML5?

HTML5 is simply the current version of HTML, standardised in 2014. It added new tags for video, audio and page structure, and it tidied up a lot of old habits. When people say "HTML" today they almost always mean HTML5, and the WHATWG now maintains it as a living standard that is updated continuously instead of in numbered releases. There is no separate language to learn.

Why does my page look different in different browsers?

Mostly because of CSS, not HTML. Browsers agree closely on what HTML means, but each has its own default styles — slightly different margins, font sizes and spacing — so the same page can look a little different from one browser to another. Old browsers can also be missing newer features. The practical fixes are to test in more than one browser, to write clean standard HTML, and to let CSS handle the appearance rather than relying on browser defaults.

The Bottom Line

HTML is the quiet foundation of the web. It is not glamorous — it has no colours, no animation, no logic — but every page you visit depends on it. It turns a lump of text into a document with headings and paragraphs, links and pictures, forms and lists, and it labels each piece so browsers, search engines and screen readers can make sense of it.

It is also the most approachable part of web development. The first version had eighteen tags, and the core idea has not changed since 1991: wrap text in tags that say what it is, nest them properly, and let the browser do the rest. The rest — styling, behaviour, servers, databases — all sits on top of that simple idea.

If you remember one thing, make it this: HTML is about meaning, not looks. Choose the tag that says what something is, write it cleanly, and give every image its alt text and every form field its label. Do that, and you have already written better HTML than most of the web.

Was this article helpful?

Muhammad Tahir

Author

 

Get new articles by email

 

Comments