Ask ten developers whether HTML is a programming language and you'll get ten confident answers, most of them a flat yes or no, and very few of them explained. The trouble usually isn't HTML. It's that each person has a different idea of what a programming language is, and the argument never gets as far as comparing them.
So before we look at HTML or CSS at all, this part sets out what people mean by programming, and turns those meanings into tests we can use for the rest of the debate.
What programming means
Start with the word itself. Here are four definitions: from a dictionary, a teaching site, a coding school and an encyclopaedia.
-
The process or activity of writing computer programs.
Google, from Oxford Languages -
The process of creating a set of instructions that tell a computer how to perform a task.
Khan Academy -
Programming languages involve logical and arithmetic operations along with several algorithms.
Kenzie Academy -
The composition of sequences of instructions, called programs, that computers can follow to perform tasks.
Wikipedia
They don't agree. The first is circular: programming is writing programs, which tells us nothing about what a program is. The second is broad, taking in any set of instructions that tells a computer how to do a task. The third asks for logic. The fourth sits somewhere between. Pick the second and HTML looks like it's in; pick the third and it looks like it's out.
What a programming language is
Definitions of a programming language split the same way. Wikipedia calls it a formal language designed to express computations, which leaves plenty of room to argue over what counts. Authors draw the line between programming languages and the wider family of computer languages in different places:
- Some count only languages that can compute anything (more on that below).
- Others count languages that can't, such as the 1992 version of SQL, the database query language, which is still widely called a programming language.
- The computer scientist John C. Reynolds went further, arguing that even input formats that change how a computer behaves are programming languages, whether or not they can compute anything.
- And some draw the line at markup. Wikipedia's own article says that "a markup language is not a programming language per se".
That last view is worth a second look. It rules HTML out by the kind of language it is, so it answers the question before it has been asked. That isn't much use in a debate, so we'll set it aside and use tests that HTML could pass or fail on its merits.
Four tests
Pull those threads together and most arguments about HTML rest on one of four tests. People rarely say which one they're using, which is why the arguments go round in circles.
1. Can it compute anything?
This is the strictest test, and the one computer scientists reach for first. In 1936 Alan Turing described a very simple imaginary machine: a strip of tape, a head that reads and writes symbols on it, and a table of rules saying what to do next. Simple as it is, a Turing machine can carry out any calculation that any computer can. A language that can imitate one is called Turing-complete.
Almost every general-purpose language is Turing-complete: Python, JavaScript, C#, Kotlin and the rest. Strictly speaking no real computer is, because Turing's tape never runs out and real memory does, so in practice we ask whether the language could compute anything if it had the memory.
HTML on its own clearly fails this test. HTML with CSS is a more interesting case, which we come to in part 4.
2. Does it tell a machine what to do?
This is the loosest test, and it matches the Khan Academy definition: programming is writing instructions that a machine carries out, whether or not those instructions could compute anything.
Plenty of things pass that we'd happily call programmable: the Jacquard loom, which wove patterns from punched cards in the early 1800s, a lathe, a 3D printer, a washing machine. Each follows instructions to automate one kind of task, but none can be made to do any task. The weakness of this test is that it lets in almost anything, including, some would say, a shopping list handed to a robot.
3. Can it decide, and remember?
Between those two sits the test most developers apply without thinking: does the language have logic? Can it choose between outcomes (if this, then that), and can it hold on to a value and use it later? Choices and memory are what turn a fixed list of instructions into something that responds to what's happening.
This is the test behind the familiar complaints that HTML has no if statements and no variables. It's also where CSS gets interesting, because CSS can do both, in its own way.
4. Would people call the result a program?
The last test is less formal, but it's how most people actually decide. Is the language used to build things that run and do a job: tools, games, applications? A database query counts, a spreadsheet formula arguably does, and a web page is the very thing in question.
This test rests on habit as much as on what a language can do, so it shifts over time. That doesn't make it worthless: it's the reason nobody calls a recipe a program, however precisely it's written.
Markup or programming? It can be both
One argument tries to skip the tests altogether: HTML stands for HyperText Markup Language, so it's a markup language, so it isn't a programming language. That only works if the two can't overlap, and they can.
HTML belongs to a family of markup languages descended from SGML, the Standard Generalised Markup Language, alongside XML. XSLT, a language for transforming one XML document into another, is itself written entirely in XML markup, and it's Turing-complete: it passes the strictest test there is. So a language can be markup and programming at the same time. HTML's name tells us what it was designed for, not what it can or can't do.
Describing is not disqualifying
A related argument says HTML only describes things; it doesn't do them. It's true that HTML is declarative: you say what you want on the page, a heading here and a form there, and leave the browser to work out how to draw it. But being declarative doesn't rule a language out. SQL is declarative too: you describe the rows you want, not how to find them, and SQL is widely accepted as a programming language. Describing the result instead of the steps is a style of programming, not the absence of it.
So the useful question isn't whether HTML is declarative, but how much it can declare: whether its declarations can make choices, hold state and compute, or only describe a fixed document.
Where this leaves us
We now have four tests, from the strictest to the loosest:
| Test | The question it asks |
|---|---|
| Computes anything | Given enough time and memory, can it work out anything a computer can? |
| Gives instructions | Does it tell a machine what to do? |
| Decides and remembers | Can it make decisions, and keep track of what has happened? |
| Builds programs | Would people call the things you make with it programs? |
None of them is the one right test, and the rest of this site doesn't pretend otherwise. Instead we'll hold HTML and CSS up to all four: HTML on its own first, then CSS, then the two together. The verdict brings the scores together at the end.