Is HTML a programming language?
What is HTML?
MDN Web Docs describes HTML as "a descriptive language that specifies webpage structure." You wrap content in tags that say what each part is. The browser reads those labels and builds the page. Here is a small piece of HTML:
<h1>Shopping list</h1>
<p>Things to buy this week:</p>
<ul>
<li>Milk</li>
<li>Bread</li>
</ul>
<a href="https://example.com/recipes">See recipes</a>This says: here is a main heading, then a paragraph, then a bulleted list with two items, then a link. It doesn't tell the computer to do anything. It describes what the content is. Tim Berners-Lee created HTML in the early 1990s as part of the World Wide Web, and today it is maintained as the HTML Living Standard by the WHATWG.
Why HTML is a markup language, not a programming language
To "mark up" text originally meant adding notes for a printer: make this bold, start a new paragraph here. A markup language does the same for a computer. A programming language instead gives the computer instructions to carry out. Programming languages can do things HTML can't:
| Can it... | HTML | A programming language (e.g. JavaScript) |
|---|---|---|
| Store values in variables? | No | Yes |
| Make decisions (if this, then that)? | No | Yes |
| Repeat steps in a loop? | No | Yes |
| Do calculations? | No | Yes |
| Respond to clicks and typing by itself? | No | Yes |
| Describe the structure of a page? | Yes | Only by creating or changing HTML |
Here is the shopping list again, this time built by JavaScript, so you can see what programming adds. It stores the items in a variable, loops through them, and makes a decision based on how many there are:
const items = ['Milk', 'Bread', 'Eggs'];
const list = document.querySelector('ul');
for (const item of items) {
const li = document.createElement('li');
li.textContent = item;
list.appendChild(li);
}
if (items.length > 2) {
console.log('That is a big shop!');
}HTML on its own has no way to express any of that. Add a fourth item to the array and the JavaScript adds it to the page by itself; in plain HTML you would have to type the new line in.
Code Editor
Write and run code right in your browser
Open the Code Editor above to try both: paste the HTML into the HTML tab, then add the JavaScript in its tab and watch the list change when you run it.
HTML, CSS and JavaScript: who does what
| Language | Kind of language | Its job | If a web page were a house |
|---|---|---|---|
| HTML | Markup language | Structure and meaning of the content | The walls and rooms |
| CSS | Style sheet language | How it looks: colours, fonts, layout | The paint and furniture |
| JavaScript | Programming language | Behaviour: logic, interaction, data | The electrics and plumbing |
Every website uses HTML, and almost all use CSS and JavaScript as well. Our HTML, CSS and JavaScript course teaches all three in order. Try one: this question asks you to write an HTML tag.
Practice: create a H2 tag in some pre-made html with a single line text box for the user to code in
Press Mark to have your answer marked in the HTML, CSS & JavaScript course.
Is writing HTML coding?
Yes. HTML is code: it has strict rules (a syntax), and the browser reads it exactly as written. Writing it well takes real skill, especially making pages that work for people using screen readers, which depends on choosing the right elements. So writing HTML is coding, even though it isn't programming. Programming is the part of coding that writes instructions and logic.
Is CSS a programming language?
CSS is usually called a style sheet language rather than a programming language. It describes how things should look, using rules like "make every heading blue". Modern CSS can do some calculations and respond to screen size, which is why people sometimes argue about it, but it isn't used to write general programs.
Does it matter?
For learning, the label matters less than knowing what each language is for. HTML is the best first step into web development, because you see results straight away and it is the base every other web language works on. Once you are comfortable with it, JavaScript is where programming begins: variables, decisions and loops. In computer science exams, you may be asked to tell markup languages and programming languages apart, so the difference is worth knowing.
Common mistakes
- Calling HTML a programming language on a CV or in an exam answer. Call it a markup language.
- Thinking HTML controls how a page looks. That is CSS's job. HTML gives meaning and structure.
- Thinking JavaScript and Java are related. They are different languages with similar names.
- Using headings just to make text big. Heading tags describe structure; size belongs in CSS.
- Assuming markup languages are only for the web. XML and Markdown are markup languages too.
Common questions
Is HTML a programming language?
What does HTML stand for?
What is the difference between HTML and JavaScript?
Is HTML easy to learn?
Should I learn HTML or Python first?
Is HTML still used?
Revision cards
Read the front, say your answer, then flip to check.
Where to go next
- Solve it
Code Editor
Write and run code right in your browser
Open the tool - Learn it
HTML, CSS & JavaScript
Learn how to think like a web developer from the ground up
Start the course - Test it
AP Computer Science Principles
A new exam-style paper every day, with instant marking and a mark scheme
Start today's paper