Introduction
In this article, we will understand the difference between HTML and XML.
What is HTML?
HTML stands for Hypertext Markup Language. HTML is the most widely used language for developing web applications. HTML5 is the current version and was published in 2012. It is used to create websites and web applications. Let's break it down better to understand the name- Hypertext, or "hypertext," refers to the "text wrapped within a text." It is similar to a hyperlink in that it contains underlying text that, when clicked, redirects to a different webpage. Markup Language, A markup language is not necessarily a programming language.
Instead, it is used to apply formatting and layout to a simple text document. This leads to more interactive and dynamic text content. Web page, A web page is a document that is commonly coded in HTML and rendered by a web browser. A URL identifies every web page and can be static or dynamic according to the requirements. We can create static web pages if we only use HTML for development.
Get started with HTML by reading this detailed article- HTML For Beginners
HTML Tags
<!Doctype html> declaration updates the browser about the HTML version.
<html> tag encapsulates the complete web page content. All other tags are 'nested' in the <html> tag. Any HTML document or web page consists of two main sections.
- <head></head>
- <body></body>
- <title> defines the title that should be displayed on the browser tab.
- <meta> used to specify page description, author of the document, last modified, etc.
- <style> defines style information for the web page.
- <link> defines a link to other documents like CSS.
- <script> defines script like JS.
HTML Elements
There are two types of HTML elements.
Container elements containing start tag < > and end tag </>.
e.g., h1, h2, form, p, div, etc.
Empty elements are those standalone tags that are considered to be self-closing tags. Empty elements will not enclose any content.
e.g., br, img, etc.
HTML Attributes
HTML elements can contain attributes that can be considered an additional feature to set various properties, and they are optional- Some of the attributes can be used with any HTML elements. There can be referred to as "global attributes" Also, some attributes can be used only with particular elements.
All the Attributes can contain properties like name and value which a developer can use to assign respective details for the HTML elements.
Attributes are used only under the start tag.
e.g.
Syntax- <html lang="en-us"> Specifies that the content of the HTML page is written in the US version of English.
<html>
<head>
<title> Test Page </title>
<meta name="description" content="This is a test web page." />
<meta name="keyword" content="HTML, XML" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<p>This is a test web page.</p>
</body>
</html>
What is XML?
XML stands for an extensible markup language. XML is a markup language that defines a set of rules for encoding documents in a human-readable and machine-readable format.
Get a complete understanding of XML with our detailed article- Introduction To XML.
<?xml version="1.0" encoding="UTF-8"?>
<friendsList>
<friend>
<name>Alex</name>
</friend>
<friend>
<name>Mery</name>
</friend>
<friend>
<name>Rachel</name>
</friend>
<bestFriend>
<name>Ana</name>
</bestFriend>
</friendsList>
Let us discuss the above-written XML code. I created a tag called friendsList, which comes inside conical brackets, and then I created an end tag for friendsList. Now, inside this, I have created one more tag called friend. I have a start friend tag and an end friend tag; the end friend tag has a forward slash and the same name as the start friend tag. Inside this, I created a tag for the name and then gave the value to a friend named Alex similarly. I have created data for one more friend, Mary, and then one more for Rachel, so I have created data for three friends.
I have also created a tag for "bestFriend," where I gave her the name Ana. This is a more formatted and structured way of communicating and exchanging data, and it can be used to communicate between applications and is valid XML.
XML is known as a markup language because we use marks, or tags, as we have seen in our example, and the tags are not predefined like in HTML.
We can use tags that can be extended, like friendList, friend, name, etc., so tags are extensible, and therefore we call it extensible markup language.
Data Exchange and Communication In XML
XML can be used for data exchange and communication between two applications. It is possible to have both client and server applications. XML is used to store and transport data, and the rules and specifications of XML come from the World Wide Web Consortium. XML is not dependent on any platform or technology. So we can use two applications built over different platforms and different technology stacks, and they can communicate using XML, which is both human and machine-readable.

Join the conversation! Your thoughts help the community grow.