Before talking about Does HTML have logic? let"s first know what is Hyper Text, Markup language, Web page, and HTML? Then we will talk about Does HTML have logic?

Hyper Text: HyperText simply means "Text within Text." A text has a link within it, is a hypertext. Whenever you click on a link which brings you to a new webpage, you have clicked on a hypertext. HyperText is a way to link two or more web pages (HTML documents) with each other.

Markup language: A markup language is a computer language that is used to apply layout and formatting conventions to a text document. Markup language makes text more interactive and dynamic. It can turn text into images, tables, links, etc.

Web Page: A web page is a document which is commonly written in HTML and translated by a web browser. A web page can be identified by entering an URL. A Web page can be of the static or dynamic type. 

HTML: HTML is an acronym that stands for Hyper Text Markup Language which is used for creating web pages and web applications. Let"s see what is meant by Hypertext Markup Language, and Web page. It defines the structure of webpages and it determines how data is displayed online. What you’re looking at right now is HTML code, read and interpreted by your browser. But this doesn’t make HTML a programming language.

Is it true that HTML doesn’t have logic?

This claim demands that we clarify what “logic” means because the definition might just surprise you. Those who bring this argument to the table seem to misunderstand what it is exactly. I’ve searched a lot and most people said that logic is:

Logic is a sensible reason or way of thinking.

That’s nice if what we’re looking for is a dictionary definition of logic. But we are talking about programming logic, not just logic as a general term. I’ve also found answers like:

Programming languages have variables, conditions, loops, etc. HTML is not a programming language because you can’t use variables or conditions. It has no logic.

This is fine (and definitely better than getting into true/false/AND/OR/etc.), but also incorrect. HTML does have variables — in the form of attributes — and there are control structures that can be used along with those variables/attributes to determine what is displayed.

But how do you control those variables? You need JavaScript!

Wrong again. There are some HTML elements that have internal control logic and don’t require JavaScript or CSS to work. And I’m not talking about things like  or  – which are rudimentary control structures and have been part of the standard for decades. I’m referring to elements that will respond to the user input and perform conditional actions depending on the current state of the element and the value of a variable. Take the / tuple or the  element as examples: when a user clicks on them, they will close if the open attribute is present, and they will open if it is not. No JavaScript required.

HTML code

So just saying alone that HTML isn’t a programming language because it does not have logic is misleading. We know that HTML is indeed capable of making decisions based on user input. HTML has logic, but it is inherently different from the logic of other languages that are designed to manipulate data. We’re going to need a stronger argument than that to prove that HTML isn’t a form of programming.

If you find this article helpful please share it with your friends. Also, love to hear your opinions and thoughts on this. You can find me on Twitter.