When we talk about
markup languages in programming, we don’t mean that someone is trying to raise the price of something. A
markup is not a price increase. It’s a way of representing data using a particular type of scripting language.
In this guide, we’re going to discuss what markup languages are, how they work, and when you may use a markup language. We’ll also analyze three different markup languages and their use cases, so that you can gain a firm understanding of how markup works.
What is a ‘Markup Language’?
A markup language is a language used by a computer to annotate a document. Markup languages are readable by humans, which means that they are usually written using standard words, instead of technical programming language terminology.
Markup languages define the style and structure of a document so that a computer knows how you want that document to appear.
One way to think about it is that markup is like how teachers “mark” or “mark up” their students’ tests. A teacher will write on the test where the student has made a mistake so that they’ll know how to fix it next time. In fact, the term
markup language came from typesetting, where instructions on how to set up a document were “marked up” alongside the document.
Markup does not have to be its own language. In the last two examples, markup is still being used, but not a markup language. What distinguishes markup and a markup language is that markup languages have a set of rules on how to use that language, and are usually interpreted by computers. Markup, on the other hand, has no defined structure.
The ‘ML’ in Web Development
You’ve probably heard
ML at some point if you’ve ever developed a website. HTML and XML, for example, both end in
ML. Have you ever asked yourself what these mean? Well, ML stands for markup language.
Markup languages are used extensively across web development. They are used to describe how a particular set of data should be represented on a web document.
HTML (HyperText Markup Language) describes the structure of a web page. XML, on the other hand, describes a particular type of data.
How Markup Languages Work
All markup languages have a common feature: they use tags to denote different types of content on the web page. These markup symbols are usually written in angle brackets (<>).
This is because markup languages need a way to distinguish the text they are trying to represent with the instructions that the computer needs to read. Any text that appears within markup tags is interpreted by the machine as an instruction.
Consider this example:
<a href="https://careerkarma.com">Career Karma</a>
This is a link to the Career Karma homepage. We have used an
<a> tag to define this link, and when our link is over we close it with an
These tags tell our computer that we want to render a link, or an
anchor (which is where the “a” comes from). These tags will not appear on our web page; they are instructions for our web browser to read so they know how to show a particular web page.
Markup files are saved as plain text documents. This means you can open them using a standard text editor.
Markup Languages vs. Programming Languages
It’s true: markup language sounds like it should be a programming language. We’re talking about languages after all! Just because these two terms sound the same, it does not mean that they are the same thing.
A programming language is a set of instructions given to a computer that produces various different types of output. Python, Ruby, and Perl are all programming languages. A markup language, on the other hand, is used to describe a document.
Whereas you can run a Python or Ruby program, you can’t “run” a marked up document. HTML documents, for example, are not executed; they are rendered by the browser. XML documents are not run either; they are read by a special type of data reader.
What Markup Languages Are There?
You’ll encounter quite a few markup languages if you go digging. There’s so much data out there that we need multiple languages to cover all the potential use cases. With that said, the most common ones are HTML, XML, and XHTML.
HyperText Markup Language
The HyperText Markup Language, or HTML, is the main language used in web development. Without it, we wouldn’t have websites. It defines the structure of a web page, such as what titles, images, and text should appear on a page, and in what order those features should appear.
HTML is a standard markup language. In HTML, tags are used to define every element on a web page, from titles to images to forms.
The HTML language is governed by the World Wide Web Consortium, or the W3C. This is because HTML is so essential to how the web works that a set of standards are necessary to define how HTML should be written and processed.
The newest version of HTML is HTML5, which includes a number of improvements from its predecessor. With that said, most changes to HTML are incremental because of how important the language is to the web.
eXtensible Markup Language
XML, or the eXtensible Markup Language, is a markup language that was designed to transport and store data. The language is self-descriptive.
This is because there are no limits to what you can name your XML tags – there are no predefined tags – and so you can choose names that precisely describe each point of data within an XML document.
Let’s say you are creating a markup document to keep track of your favorite books. In XML, you could use the following structure:
<book> <title>How to Win Friends and Influence People</title> <author>Dale Carnegie</author> <rating>⅘</rating> </book>
In this example, we’ve created four tags: book, title, author, and rating. The title, author, and rating tags appear within our book tag. The book tag represents one entry in our XML file.
eXtensible HyperText Markup Language
XHTML is a version of HTML4 which meets the XML standard. It’s largely been replaced by HTML5 – which has a more diverse feature set – but it is still in use today in some corners of the internet. Most sites that use XHTML are those developed years ago that haven’t been updated in a while.
XHTML and HTML are very similar, but there are a few differences that you may notice. For instance, HTML attributes must have both a name and a value; you can’t use standalone attributes. In addition, all XHTML tags are written in lowercase. In HTML, you can write using uppercase or lowercase, even though best practices suggest you should use lowercase.
Markup languages are used to define elements within a document. These languages, like HTML and XML, are designed to be readable by humans. This makes it easy for you to understand what data a markup language is representing.
In markup languages, markup instructions to the computer are presented using tags. These tags are usually stored between angle brackets (<>).
Now you’re ready to start talking about markup languages like a web development expert!