CodeNewbie Community

Discussion on: What makes HTML a “markup language” and not a “programming language?“

Collapse
reinhart1010 profile image
Reinhart Previano Koentjoro • Edited on

I personally consider HTML as a separate data structure file format (similar to JSON, YAML, and TOML) instead of just a “markup language”, which can then be parsed and used by programming languages to store and load data.

Standard-wise, the HTML itself is originally based/inspired from XML and other SGML-based markup languages. Before JSON were introduced, websites share their data between servers and clients commonly by sending XML data via SOAP. A typical XML document, such as

<response>
  <statusCode>200</statusCode>
  <body>
    <city>Istanbul</city>
    <country>Turkey</country>
  </body>
</response>
Enter fullscreen mode Exit fullscreen mode

can be represented into JSON format such as

{
  "response": 200,
  "body": {
    "city": "Istanbul",
    "country": "Turkey"
  }
}
Enter fullscreen mode Exit fullscreen mode

Certain data structures such as arrays can be emulated in XML by repeatedly using the same tags. In HTML you might create an unordered list (aka. bullet points) this way:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>
Enter fullscreen mode Exit fullscreen mode

Which is similar to this in JSON

{
  "ul": ["Item 1", "Item 2", "Item 3"]
}
Enter fullscreen mode Exit fullscreen mode

Web browsers which are able to render the HTML document will first try to parse the file into a set of data structures understood by web browsers’ programming languages (typically C++ and Rust, in the form of DOM / Document Object Model tree), then try to render the HTML by connecting it with a graphics API or library. Many programming language compilers and intepreters, however, perform more tasks than simply analyze and parse the source code written in that programming language, such as C/C++ which then tries to compile the code into an Assembly format compatible for specific types of processors (x64, ARM, RISC-V, etc.)

Hence, the definition of HTML as a programming language itself depends by people’s opinion, but I still can assure that HTML can be a subset of another programming language. This is true due to the fact that similar markup languages such as XML are often used in defining layouts and user interfaces for other types of software (such as Android app development and even Microsoft Office itself*), while HTML and XML itself is principally similar to other forms of data structure file formats such as JSON, YAML, and TOML.