HTML & XML - Unit 5
HTML & XML - Unit 5
</body>
</html>
Example Explained
The <!DOCTYPE html> declaration defines that this document is an HTML5 document
The <html> element is the root element of an HTML page
The <head> element contains meta information about the HTML page
The <title> element specifies a title for the HTML page (which is shown in the browser's
title bar or in the page's tab)
The <body> element defines the document's body, and is a container for all the visible
contents, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
The <h1> element defines a large heading
The <p> element defines a paragraph
What is an HTML Element?
An HTML element is defined by a start tag, some content, and an end tag:
The HTML element is everything from the start tag to the end tag:
Note: Some HTML elements have no content (like the <br> element). These elements are called
empty elements. Empty elements do not have an end tag!
Web Browsers
The purpose of a web browser (Chrome, Edge, Firefox, Safari) is to read HTML documents and
display them correctly.
A browser does not display the HTML tags, but uses them to determine how to display the
document:
HTML Page Structure
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
Note: The content inside the <body> section (the white area above) will be displayed in a
browser. The content inside the <title> element will be shown in the browser's title bar or in the
page's tab.
A markup language is a computer language that uses tags to define elements within a
document. It is human-readable, meaning markup files contain standard words, rather
than typical programming syntax.
While several markup languages exist, the two most popular are HTML and XML.
HTML is a markup language used for creating webpages.
The contents of each webpage are defined by HTML tags. Basic page tags, such
as <head>, <body>, and <div> define sections of the page,
while tags such as <table>, <form>, <image>, and <a> define elements within the page.
Most elements require a beginning and end tag, with the content placed between the tags.
For example, a link to the TechTerms.com home page may use the following HTML
code:
<a href="https://techterms.com">TechTerms.com</a>
XML is used for storing structured data, rather than formatting information on a page.
While HTML documents use predefined tags (like the examples above),
XML files use custom tags to define elements.
For example, an XML file that stores information about computer models may include
the following section:
<computer>
<manufacturer> Dell </manufacturer>
<model> XPS17 </model>
<components>
<processor> 2.00GHz Intel Core i7</processor>
<ram> 6GB </ram>
<storage> 1TB </storage>
</components>
</computer>
XML is called the "Extensible Markup Language" since custom tags can be used to
support a wide range of elements.
Each XML file is saved in a standard text format, which makes it easy for software
programs to parse or read the data.
Therefore, XML is a common choice for exporting structured data and for sharing data
between multiple programs.
There are three important characteristics of XML that make it useful in a variety of systems and
solutions −
XML is extensible − XML allows you to create your own self-descriptive tags, or
language, that suits your application.
XML carries the data, does not present it − XML allows you to store the data
irrespective of how it will be presented.
XML is a public standard − XML was developed by an organization called the World
Wide Web Consortium (W3C) and is available as an open standard.
XML Usage
XML is a markup language that defines set of rules for encoding documents in a format that is
both human-readable and machine-readable.
More specifically, a markup language is a set of symbols that can be placed in the text of a
document to demarcate and label the parts of that document.
Following example shows how XML markup looks, when embedded in a piece of text −
<message>
<text>Hello, world!</text>
</message>
This snippet includes the markup symbols, or the tags such as <message>...</message> and
<text>... </text>.
The tags <message> and </message> mark the start and the end of the XML code fragment.
The tags <text> and </text> surround the text Hello, world!.