The Invent with Python Blog

Writings from the author of Automate the Boring Stuff.

Why Is HTML Not A Programming Language?

Sun 15 December 2013    Al Sweigart

HTML is not a programming language. You can't write a "program" that, say, calculates the average of ten numbers with HTML. While some may point out that HTML is a "markup language", this doesn't clarify how that is different from a programming language. This isn't meant to be a thorough argument, but rather a brief explanation that goes just a bit more in detail than "HTML isn't a programming language but instead a markup language."

But first, an important note: The fact that HTML is not a programming language is often used as a way to devalue it, along with web design or front-end engineering in general. HTML and CSS are valuable skills and like many skills, they are easy to learn at a rudimentary level but take a large effort to master. Many techies argue about the "merits" of their favorite programming language, operating system, or whatever and nine out of ten times they're actually expressing their own opinion or a fact that is largely irrelevant. The point of this blog post isn't denigrate HTML.

Here is a point I'd like to make: HTML is no more a programming language than Microsoft Word is. With Word (or any other word processor software), you can write out text and format it with different fonts, sizes, and colors. Images and tables and bullet points can be added as well. This is all done through the word processor's graphical user interface.

An HTML file is similar, except it does not have a GUI. Instead, it is entirely written out in plaintext, so all the formatting instructions must be typed out as HTML tags (for example, <b> or <center>.) This "language" of tags is how we can format the appearance of a webpage.

Programming languages, on the other hand, can process data and make decisions. You can store data such as text strings and integers, and then manipulate these values to perform calculations. For example, doing some math or sorting text alphabetically are kinds of data processing that you cannot do in HTML.

Programming languages can also make decisions about what instructions they should execute. Depending on if a certain condition is true or false, a set of instructions may be executed or skipped by a program. Here is a Python example of such code:

if password == 'rosebud':

    print('Access granted.')

else:

    print('Access denied.')

Programming languages also have ways of executing instructions over and over again in loops. Loops, if-else statements, and other such instructions are called flow control statements. All programming languages have these flow control statements, but HTML (and Microsoft Word) do not.

JavaScript is a programming language. It has all these features of flow control and data processing. While JavaScript is used in many web pages, it is a distinctly separate thing from HTML. You can write HTML without JavaScript, and you can write JavaScript code without HTML.

Because HTML lacks these features, it isn't a programming language. One does not "program in HTML". You shouldn't list HTML on your resume under "programming languages" anymore (a broader title such as "skills" would be more suitable).


Learn to program for free with my books for beginners:

Sign up for my "Automate the Boring Stuff with Python" online course with this discount link.

Email | Mastodon | Twitter | Twitch | YouTube | GitHub | Blog | Patreon | LinkedIn | Personal Site