What's this all About
Preface
HTML and CSS (because we're considering that too) are undeniably languages used by programmers, although in this context, perhaps better terms would be designers, developers or engineers, but whether they constitute programming languages has divided the community into two camps, each stubbornly defending their position. Mostly I find this debate to be fuelled by trolls who seek to infuriate their peers, or gatekeepers who seek to distinguish between those who are programmers and those who are merely designers.
Given the depth and breadth of this topic, I cannot possibly draw to conclusion whether HTML and CSS are, or are not programming languages, however I would like to draw attention to the evidence, and though comprehensive research and analysis, provide a fair and educational review.
In order to be impartial, this website uses zero lines of JavaScript or WebAssembly! It's also responsive, which in itself demonstrates some level of conditional logic. Even the navigation menu (on mobile devices) is implemented using only HTML and CSS, which is admittedly a bit hacky, goes against web accessibility guidelines and ruins the semantics. Whilst you could argue that this behaviour is attributed to CSS more than it's attributed to HTML, it does prove that conditional and stateful behaviour can be modelled, at least in a limited sense, without resorting to JavaScript or WebAssembly.
Opinion and Conclusion
I believe that HTML sits on the cusp of the debate, where the definitions that constitute programming are so broad and varied that it's really difficult to say that it definitely is, or it definitely isn't a programming language, but if I were to give any sort of conclusion based on the evidence, I'd say that it isn't, more than it is, but I also wouldn't disqualify HTML entirely.
HTML is not general-purpose, and it's not Turing-complete, therefore it's not capable of
performing arbitrary
computation. HTML has no mechanism for declaring variables (and no, the <var>
element doesn't
count), although arguably you can declare constants, since all HTML elements are constant
without the use of DOM
manipulation. HTML has limited capacity to read input using buttons, text boxes, select boxes,
check boxes, radio
buttons, and even files via the <input>
, <select>
,
<button>
and <textarea>
elements, however these are mostly useless without JavaScript,
WebAssembly, CSS,
or a back-end system, and ultimately require user intervention. HTML has limited capacity to
write output using a
video display unit (since many elements are visual, notably the <svg>
element, capable of
arbitrary drawing) or audio output device (since modern HTML has <audio>
and
<video>
elements), but no capacity to write output to storage devices (unless
you consider
printing your web pages and storing them on paper, and no, don't take that seriously, because it
doesn't even
remotely qualify). HTML has no mechanism for performing logical, arithmetic or conditional
operations. HTML can
define lists via the <ol>
and <ul>
elements, but has no
capacity to iterate
over them. Finally, HTML has no mechanism for defining sub-routines, modules, functions, or
procedures. Whilst you
could argue that the <template>
element might be equivalent to creating a
declarative sub-routine
or module, it's useless without JavaScript or WebAssembly.
Whilst HTML is neither general-purpose or Turing-complete, it does constitute a limited, declarative and domain-specific language (DSL) that allows you to declaratively describe the logical order and semantics of an active document. As a declarative language, as opposed to an imperative language, it allows a developer to describe what should go on a web page, rather than describing how to put it there.
HTML is an interpreted language and does not directly execute on the underlying
machine. Instead,
HTML provides a mechanism to declare objects which are interpreted by a web
browser, parsed into a
Document Object Model (DOM) tree which are then executed by the browser, which renders those
objects to a display,
and optionally an audio output device where the document may contain <audio>
or
<video>
elements.
Therefore, HTML does affect the execution state of the underlying machine, but only in an incredibly limited sense. Whilst you cannot do much else with pure HTML, when combined with CSS (which by many is also not considered a programming language), you can begin to build some simple and even interactive programs and algorithms, for which I have provided examples.
About The Author
I am the founder of ONIXLabs and a Principal Software Engineer at R3, working on Distributed Ledger Technology and building software solutions for global financial institutions and regulated markets. I began programming when I was fourteen years old using Microsoft QBasic and Visual Basic, however nowadays my favourite programming languages are C#, Kotlin and TypeScript.