what exactly a markup language is and how it is different from
programming language and scripting languages
in layman's terms, a markup language is a set of markup tags. according to this:
A markup language is a set of tags and/or a set of rules for creating
tags that can be embedded in digital text to provide additional
information about the text in order to facilitate automated processing
of it, including editing and formatting for display or printing.
HTML (short for Hyper Text Markup Language) is a popular example on markup languages. it's essentially a set of tags for describing the structure of a web page (i.e., how the contents are shown).
A programming language, on the other hand, is a language that provides a set of constructs that enable a programmer to write programs.
a program is a set of instructions that instruct a computer (of some kind) to do something. programs typically process data (input) and produce results (output).
according to Wikipedia:
A scripting language or script language is a programming language that
supports scripts, programs written for a special run-time environment
that can interpret (rather than compile) and automate the execution of
tasks that could alternatively be executed one-by-one by a human
to understand that you need to have a basic understanding of the difference between compiled and interpreted languages.
basically, a program that is written in compiled language is translated into native machine instructions using a tool (a program) called a compiler.
a compiler essentially translates the source code of the program (written in the compiled language) into the corresponding native machine instructions (0s and 1s) that are often referred to as machine code.
it then puts these machine instructions in a separate file via which you can execute (run) the program. this file is often referred to as an executable and contains only machine code.
popular examples on compiled languages are C and C++. popular examples on their compilers are
a program that is written in an interpreted language, on the other hand, is passed to another program called an interpreter.
an interpreter essentially parses the code of the program (written in the interpreted language) one line at a time, translates it into the corresponding machine instructions and executes it on the fly.
notice that an interpreter does not produce a separate executable file.
a program that is written in an interpreted language and saved into a file is often referred to as a script.
Does it need to be compiled down to binary code to run on a machine?
no, a markup language does not need to be compiled and it does not run on a machine (at least in a sense that a program written in some programming language does).
How does it work?
I'll try to be quite abstract here and explain the general idea for the sake of simplicity.
as explained earlier, an HTML page contains HTML code that is used to describe a web page. programs called web browsers are used to render HTML pages on the screen accordingly.
how? well, a web browser simply knows what every HTML tag is supposed to be describing according to a standard. for example, it knows that the
<p> tag is used to describe a paragraph and the
<img> tag is used to describe an image.
so it simply parses the HTML code and renders the elements accordingly. for example, when it finds an
<img> element, it extracts the path to the image (which is the value of the
src attribute of that element), loads the image and displays it in the according position.