Getty Images/iStockphoto
Is HTML a programming language?
Unlike Java, Python or C, HTML is not a programming language because it lacks variables, conditional statements or iterative loops. But so what? HTML has a bigger role to play.
No, HTML is not a computer programming language.
This may ruffle the feathers of web developers and graphic designers who take pride in the webpages they have built. Nevertheless, HTML is not a programming language.
Why is HTML not a programming language?
HTML is not a computer programming language for three reasons:
- It does not allow for the use of variables
- It does not allow for the use of conditional statements
- It does not provide any iterative looping structures
What is a programming language?
To discuss why something is or is not a programming language, we must establish a baseline definition of what a computer programming language is. To do that, we must consider what a computer does, and more specifically, what the CPU does.
At the most basic level, a CPU does three things:
- read data out of memory;
- perform conditional logic on that data; and
- iteratively perform that logic at lightning speed.
For anything to qualify as a computer programming language, it must provide a way to program these aspects of a computer.
HTML does not support any of these functions. That's why HTML is not a programming language.
"HTML doesn't allow for logic, control, data storage and retrieval, looping, or anything else that a programming language does," said JD Lien, a senior web developer at Edmonton Public Library. "It's far from being Turing complete. It's a markup language for structuring documents."
Programming language examples
Python and Rust both qualify as computer programming languages. So do C and Java.
All these languages provide a way to declare variables and assign values to those variables. This is how computer programming languages manage data.
These languages support conditional if..then..else statements. This is how conditional logic is performed.
These languages also support for and while loops. This is how repetitive, iterative logic is performed millions of times per second.
HTML has no equivalent features. HTML can't program a computer. Therefore, HTML is not a computer programming language.
Does HTML combined with CSS qualify as a programming language?
All modern webpages use a combination of CSS and HTML for layout and design. HTML formats text on the page, while CSS structures and styles the page with font faces, page layout and colors.
One question that often arises is if CSS is a programming language, or if the combination of CSS and HTML meets the threshold to qualify as a programming language. Unfortunately, they don't.
You can do impressive things with HTML and CSS. There are several examples on JSFiddle where developers implement the Sieve of Eratosthenes, a way to calculate prime numbers, with HTML and CSS. That is a complicated algorithm, and certainly demonstrates how HTML and CSS can take advantage of the processing power of a CPU.
Unfortunately, the HTML and CSS implementation requires too much hard-coding. In the end, this highlights the shortcomings of HTML and CSS as presumed programming languages, versus their merits.
CSS does provide the ability to declare styles as class elements, but to describe these constructs as variables is a stretch. And yes, a developer can apply styles conditionally with CSS, but not through a traditional if..else syntax. CSS provides only rudimentary ways to perform calculations and implement conditional logic, and it completely lacks an iterative loop structure.
Even combined with CSS, we can't honestly say HTML is a computer programming language.
To further the point, any time complicated processing is required to render an HTML page, a real program must be injected into the mix. This is why we see HTML regularly combined with Java, PERL and PHP on the server, and JavaScript on the client.
HTML is actually a markup language
HTML is not a programming language. It's a markup language. In fact, that is the technology's name: HyperText Markup Language. That self-identified fact alone should settle the debate.
So what if HTML is a programming language or not?
Maybe the real question is this: Does it even matter if HTML fits the technical definition of a programming language or not?
"I'm suspicious why people want to decide this," said Ned Batchelder, a senior software engineer from Boston. "Too often, it's to gatekeep who is a 'real programmer' and who is not. Don't do that."
Batchelder said he can see both sides in the debate. One person could reasonably argue that HTML is a programming language because it's a computer language, structured to tell a computer what to do, specifically how to display a page. "There are rules, and if you break them, it won't do what you want," he said.
Whether HTML is technically a programming language or not doesn't diminish its importance in the world of software development. It doesn't diminish the skills of the people who create amazing websites with HTML.
HTML is the first language you should learn
Even though HTML is not a programming language, it is still the first language anyone who wants to become a programmer should learn.
It's easy to write your first HTML program. All you need is a web browser and a text editor. There is no need to install compilers or interpreters as you might with Java or Python.
Moreover, you get instant feedback. When a program works, you can see the results of your effort in a web browser immediately.
The lessons an aspiring developer learns from HTML will carry forward throughout their programming career. These include:
- the role of HTML in webpage development;
- how code translates into software;
- the importance of program structure;
- how to troubleshoot code; and
- the feeling of satisfaction when a software program works.
Developers who start with HTML create a strong foundation to learn other computer languages, such as Java or Python, Batchelder said. "Computers are dumb and do what you tell them even if you tell them the wrong thing. You learn how to learn about the language. You get comfortable with obscure and strict notation."
HTML and CSS career path
If you want to learn how to program a computer, that's great. Always follow your interests.
But you can have a satisfying and successful career in IT and never learn how compile a Java source file or deploy a NodeJS package.
Freelance web developers with HTML and CSS skills charge $1,000 to build a website and $1,000 a month for ongoing maintenance. With just 10 clients, a freelance web developer can bring in over $120,000 a year. With a little bit of hustle, a good web developer can double that.
If you love HTML development and the visual nature of website design, don't let the programming language debate diminish your love for the craft. It's just a label. And it's a silly one at that.