What does HTML stand for?
HTML stands for HyperText Markup Language. The name sounds technical, but each word means something simple.
- HyperText is text with links in it that take you to other text. The word is older than the web
(it goes back to the 1960s). Links are the reason the web is a “web” at all. In
<p>See our <a href="menu.html">lunch menu</a>.</p>, the words “lunch menu” become a link to another page. - Markup means labels you put around parts of the text to say what they are. Editors used to mark
up paper manuscripts with notes like “make this a heading”. In HTML the labels are tags:
<h1>Lunch menu</h1>marks “Lunch menu” as the main heading of the page. - Language here means a fixed set of those labels and rules for writing them, so every browser understands the page the same way.
A first HTML page
This is a complete page, with a heading, two paragraphs, a link and an image. The top part of the box is what a browser shows, the dark part is the HTML that makes it. Try changing “Sam” to your own name.
You don’t need to learn every line by heart. What each part does:
| Code | What it does |
|---|---|
<!DOCTYPE html> | Tells the browser this is a modern HTML page. Leave it out and browsers switch to “quirks mode”, which copies old browser bugs from the 1990s. |
<html lang="en"> | Wraps the whole page. lang says the text is English, which helps screen readers and translation. |
<head> | Information about the page that isn’t shown on the page itself. |
<meta charset="utf-8"> | The text encoding. Without it, letters like é or ü can turn into odd symbols. |
<meta name="viewport" …> | Makes the page fit a phone screen instead of showing a tiny zoomed-out desktop page. |
<title> | The name in the browser tab, in bookmarks and usually in search results. It never shows inside the page. |
<body> | Everything people see: text, images, links, forms. |
<h1>, <p> | A main heading and a paragraph. There are six heading levels, <h1> to <h6>. |
<a href="…"> | A link. href is the address it goes to. |
<img src="…" alt="…"> | An image. src is the file, alt describes it for people who can’t see it. |
The examples run in a locked box: scripts are off and your edits go away when you reload. Links in them open inside the box. To keep one, copy it into the HTML Editor, or save it as a file (see how to create an HTML file).
Tags, elements and attributes
These three words come up in every HTML guide, and people mix them up all the time. Take one link apart and you can see all three:
- Start tag
<a …>and end tag</a>: the end tag has a slash. - Attribute
href="…": extra information, written as name="value" inside the start tag. - Content: what sits between the tags.
The whole thing, start tag to end tag, is one element: an a element.
So a tag is the bit in angle brackets you type, and an element is the piece of the
page it makes. Elements can sit inside other elements, like the <li> items inside the list below
and the <strong> inside one of them. That’s called nesting. Close the inner one first:
<li><strong>Milk</strong></li>, not <li><strong>Milk</li></strong>.
- Some elements have no end tag.
<img>,<input>,<br>,<hr>and<meta>can’t hold content, so there’s nothing to close. In<p>Line one<br>Line two</p>the<br>breaks the line and that’s it. You may see it written as<br />; in HTML the slash is optional. - An attribute always goes in the start tag. Change
width="160"in the second example and the image changes size. Some attributes need no value at all:disabledon its own grays out the input. - Tag names don’t care about capitals.
<P>works, but lowercase is what nearly everyone writes. - To show a < on the page, write
<. Otherwise the browser thinks a tag is starting. The HTML Entities page has the codes for that and other symbols.
HTML has more than a hundred elements, but most pages get by with a few dozen. The HTML Tags list has all of them, each with a tiny example.
HTML, CSS and JavaScript
A web page is usually made of three languages, and each one has its own job. HTML is the structure and content. CSS is the look: colors, fonts, spacing, layout. JavaScript is the behavior: what happens when you click, type or scroll. Below is the same small piece of a page, first with HTML only, then with some CSS added on top:
Notice that the words didn’t change, only how they look. The button in both boxes does nothing when you click it, because nothing tells it what to do. That’s JavaScript’s job. Put this under the button and it shows today’s hours on a click:
<p id="today"></p>
<script>
const button = document.querySelector('button');
button.addEventListener('click', () => {
document.querySelector('#today').textContent = 'Today: open 9 to 5';
});
</script> Scripts are off in the example boxes on this page. To see this one work, paste the second example and this code into the HTML Editor, which runs JavaScript.
| Language | Its job | Looks like |
|---|---|---|
| HTML | What’s on the page and what each part is | <h2>Opening hours</h2> |
| CSS | How it looks | h2 { color: green; } |
| JavaScript | What it does when people use it | button.addEventListener(…) |
You can write a page with HTML alone, and it works. CSS and JavaScript need HTML to work on. Next steps for each: how to link CSS to HTML and how to link JavaScript to HTML.
Is HTML a programming language?
No, it’s a markup language. A programming language lets you give the computer instructions: remember this number, add one to it, do this ten times, if the box is empty show a warning. HTML can’t do any of that. It describes what things are, and the browser decides how to show them. Markdown is another markup language you might know.
| Can HTML… | Answer |
|---|---|
| Mark up headings, lists, tables, links and forms? | Yes, that’s what it’s for. |
| Store a value and change it later? | No. That needs JavaScript (or code on a server). |
| Repeat something ten times? | No. You write it out ten times, or a program writes the HTML for you. |
| Decide something with “if this, then that”? | No, HTML has no conditions. |
| Add numbers, or check a password? | No. A form can send the password somewhere, but checking it happens elsewhere. |
Some elements come with behavior the browser already knows. This question opens and closes when you click it,
with no JavaScript at all. That’s built into <details>; you didn’t write any logic for it.
So HTML isn’t programming, but it is coding, and it’s a real skill. Knowing which element fits (a
<button> rather than a clickable <div>, a real <h2> rather
than big bold text) is what makes a page work with a keyboard, a screen reader and search engines.
What is an HTML file?
An HTML file is a plain text file with HTML code in it and a name that ends in .html, like
index.html or about.html. Open it in a text editor and you see the code. Open it in a
browser and you see the page. It’s the same file both times; the program decides what you get. A tiny one,
saved as notes.html, could be only three lines:
<!DOCTYPE html>
<title>Notes</title>
<p>Buy milk and bread.</p> Open it in a browser and you get a tab called “Notes” with one line of text, “Buy milk and bread.”
-
.htmland.htmare the same thing. The short one is left over from old systems where file extensions could only be three letters long. Today.htmlis the usual choice. -
index.htmlis a special name on websites. When an address ends in a folder, likeexample.com/blog/, most web servers send theindex.htmlin that folder. - It has to be plain text. Renaming a Word document to
page.htmldoesn’t make it an HTML file; inside it’s still a Word file. Write the code in a text editor such as Notepad, VS Code, or TextEdit set to plain text. - Double-click it and it usually opens in your default browser. To change it, open it with your text editor instead, save, and reload the browser tab.
The step-by-step version, for Windows, Mac and phones, is in how to create and open an HTML file. If you already have a file and want a quick look at it, drop it on the HTML Viewer.
How a browser reads HTML
The browser reads the file from top to bottom and builds a tree out of the elements, with each element as a branch inside its parent. Developers call this tree the DOM (Document Object Model). The first page from above becomes this:
html
├── head
│ ├── meta
│ ├── meta
│ └── title: "My first page"
└── body
├── h1: "Hi, I'm Sam"
├── p: "This is my first…"
├── p
│ ├── "Here's a "
│ ├── a: "link to…"
│ └── "."
└── img Along the way it fetches whatever the HTML points to (images, CSS files, scripts), works out where every box goes on the screen, and draws it. CSS changes how the tree looks and JavaScript can change the tree itself while the page is open.
Browsers are very forgiving. A missing end tag doesn’t stop the page; the browser guesses what you meant. The guess
isn’t always what you want, though. Here the first <b> is never closed, so the bold carries on
into the next paragraphs:
Mistakes like this don’t stand out when you read the code. The HTML Validator lists them with line numbers, and the HTML Fixer can close the tags for you. To see the HTML of a page that’s already online, read how to see the HTML code of a website.
What HTML is used for
Every web page you open is HTML by the time it reaches your browser, even when the site was built with a big framework or a website builder. Those tools still produce HTML in the end. It turns up in a few places you might not expect, too.
Newsletters and receipts with colors, logos and buttons are HTML emails. They’re written in an older style, with
tables and inline styles, because email apps support less than browsers, so a line of an email often looks like
<table role="presentation"><tr><td>Your order is on its way.</td></tr></table>.
The HTML Email Viewer shows how one looks on desktop and mobile.
Some desktop apps, VS Code and Discord among them, draw their whole window with HTML and CSS running in a built-in browser, and many phone apps show parts of their screens the same way. An EPUB ebook is a zipped bundle of HTML-style pages with CSS, plenty of programs keep their help pages as HTML, and invoices and reports are often laid out in HTML first and then saved as PDF (which is what our HTML to PDF page does).
A very short history
Tim Berners-Lee came up with HTML while working at CERN, the physics lab near Geneva, as part of his idea for the
World Wide Web. The first public description of it, a document called “HTML Tags”, went out in 1991 and listed
18 elements. HTML 2.0 became a standard in 1995, HTML 4.01 followed in 1999, and HTML5 was finished in 2014,
adding things like <video>, <audio> and new form inputs.
Since 2019 there’s one HTML standard, the HTML Living Standard, kept by a group of browser makers called the WHATWG. It’s updated in place as browsers add features, which is why you won’t see an “HTML6”. When people say HTML5 today, they usually mean modern HTML in general.
Where to go next
The best way to learn HTML is to write some. Take the first page above, change it until something breaks. These guides pick up from here, in a good order:
Along the way, the HTML Tags list is handy for looking things up, the
HTML Editor gives you HTML, CSS and JavaScript side by side with a live preview, and the
HTML Starter Template writes the <head> part for you once
you’re tired of typing it. For the small things, there are tutorials on
text color, images,
line breaks and comments.
Questions people ask
What is HTML in simple words?
HTML is the code behind every web page. It labels each part of the page, so the browser knows what it is: <h1> for the main heading, <p> for a paragraph, <a> for a link, <img> for an image. The browser reads those labels and draws the page you see.
What does HTML stand for?
HyperText Markup Language. Hypertext is text with links to other text, markup means tags put around parts of the text to say what they are, and language means a fixed set of those tags and rules, so every browser reads a page the same way.
Is HTML a programming language?
No, it’s a markup language. It describes what is on a page, but it can’t store values, repeat things, add numbers or make decisions with if and else. That’s what JavaScript is for.
What is an HTML file?
A plain text file with HTML code in it and a name ending in .html (or .htm, which is the same thing). Open it in a text editor and you see the code; open it in a browser and you see the page. On a website, index.html is the file most servers send when an address ends in a folder.
What is the difference between a tag and an element?
A tag is what you type in angle brackets, like <p> (the start tag) or </p> (the end tag). An element is the whole thing the tags make: start tag, content and end tag together, so <p>Hello</p> is one p element. A few elements, like <img> and <br>, have only a start tag.
What is an attribute in HTML?
Extra information about an element, written inside its start tag as name="value". In <a href="https://example.com">, href is the attribute and the address is its value. Other common ones are src and alt on images, class and id for CSS, and lang on the html element. Some, like disabled, need no value.
What is the difference between HTML, CSS and JavaScript?
HTML is the structure and content: what’s on the page. CSS is the look: colors, fonts, spacing and layout. JavaScript is the behavior: what happens when someone clicks or types. You can write a page in HTML alone. CSS and JavaScript need some HTML to work on.
What is HTML used for?
Mainly web pages: every site is HTML by the time it reaches your browser, whatever it was built with. It’s also used for HTML emails, the screens of some desktop and phone apps, EPUB ebooks, help pages, and documents that are later saved as PDF.
What is the latest version of HTML?
There are no version numbers any more. Since 2019 there’s one HTML Living Standard, kept by the WHATWG and updated as browsers add features. HTML5, finished in 2014, was the last numbered version, and people still say HTML5 when they mean modern HTML.
Do I need special software to write HTML?
No. Any plain text editor works, such as Notepad on Windows, TextEdit on a Mac (set to plain text) or a free code editor like VS Code. Save the file with a name ending in .html and open it in any browser. You can also paste code into an online HTML viewer or editor to see it right away.
Keep going
Tools that help
- HTML Viewer Paste code or open an .html file and see the page.
- HTML Editor HTML, CSS and JavaScript in one place, with scripts on.
- HTML Tags Every tag with a tiny example.
- HTML Validator Points out unclosed tags and other slips.
- HTML Starter Template Builds the head part of a page for you.
More tutorials
- How to Center Text, a Div or an Image in HTML & CSS
- How to Add a Line Break in HTML
- How to Add Spaces in HTML
- How to Change Text Color in HTML
- How to Change Background Color in HTML
- How to Add an Image in HTML
- What Is a URL? Meaning, Parts and Examples
- How to Redirect a Page in HTML
- How to Get an Image URL
- Canonical URL
- How to Create, Open and Run an HTML File
- How to Link CSS to HTML
- How to See the HTML Code of a Website
- How to Link JavaScript to HTML with the script Tag
- HTML hr Tag
- HTML Comments
- How to Make Text Bold in HTML
- HTML Font and Font Size
- All tutorials