0% found this document useful (0 votes)
52 views54 pages

Yash Pratap HTML

This document is a practical file submitted by Yash Partap Singh for the Bachelor of Computer Application degree, focusing on the introduction to HTML, CSS, and XML. It includes sections on the basics of the internet, web technologies, and various protocols, as well as acknowledgments and a certificate of completion. The content covers essential concepts such as static and dynamic websites, client-side and server-side scripting, and the role of different programming languages and protocols in web development.

Uploaded by

mkk93042
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views54 pages

Yash Pratap HTML

This document is a practical file submitted by Yash Partap Singh for the Bachelor of Computer Application degree, focusing on the introduction to HTML, CSS, and XML. It includes sections on the basics of the internet, web technologies, and various protocols, as well as acknowledgments and a certificate of completion. The content covers essential concepts such as static and dynamic websites, client-side and server-side scripting, and the role of different programming languages and protocols in web development.

Uploaded by

mkk93042
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Practical File

on
“INTRODUCTION TO HTML,CSS - XML”
SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENT FOR THE
AWARD OF THE DEGREE
Of

Bachelor Of Computer
Application
(B.C.A. 1stsem )
( Batch : 2024 – 2027 )

Submitted By Submitted to
Yash Partap Singh Mr Ajay Kumar
2523361050108 (Head,Dept.of C.S,G.C.M.T)

DEPARTMENT OF COMPUTER SCIENCE


GAGAN COLLEGE OF MANAGEMENT & TECHNOLOGY
ALIGARH
Session 2024-25

DEPARTMENT OF COMPUTER SCIENCE


GAGAN COLLEGE OF MANAGEMENT & TECHNOLOGY,
ALIGARH
[Affiliated to Raja Mahendra Pratap Singh State University, Aligarh]

CERTIFICATE
THIS IS TO CERTIFY THAT YASH PARTAP SINGH BEARING ROLL NUMBER
2523361050108 BACHELOR OF COMPUTER SCIENCE HAVE WORKED
FOR THE PREPARATION OF THE PRACTICAL FILE ENTITLED;
“INTRODUCTION TO HTML, CSS - XML”.

This practical file is submitted in partial fulfillment of the requirement


of the award of the degree of BCA.

This is to certify that above statement is correct to the best of my


knowledge and belief.
Mr. Ajay Kumar Mr. Girish C. Sharma
(Head, Dept. of C.S.) ( DEAN,G.C.M.T.)
ACKNOWLEDGEMENT
In the praise of GOD the most merciful and beneficent who showed us
the path of rightness and blessed us to get the strength to embark
upon this task.

We would like to express my sincere gratitude towards the director of


“Gagan College of Management & Technology, “Mr. Gagan Sharma”
for providing me an opportunity to work and learn through this end-
term project.

Words are always in short when we wish to show our gratitude. While
presenting this report we wish to thank all those who took special
pain during its preparation.

It gives us immense pleasure to express my profound gratitude and


sincere thank to Mr. Girish C. Sharma (DEAN), Mr. Akhil Sharma(Asst.
Professor, Dept. Of C.S., G.C.M.T.) , Mr.Ajay Kumar(Head, Dept. of
C.S., G.C.M.T.) and Ms.Mitali Varshney (Asst. Professor, Dept. Of C.S.,
G.C.M.T.) for their excellent guidance, sympathetic and inspiring
attitude and constant encouragement throughout the course of this
study. It is indeed his commitment and dedication that made me able
to write this project.

We shall always remain thankful to all our faculty members for their
kind support. We are greatly indebted to our parents and friends for
their love and affection-their wishes have been the source of
encouragement throughout our study.

(Yash Partap Singh)

Roll No 2523361050108
INDEX
1. BASICS OF INTERNET AND WEB 1-9

2. DHTML 10-11

3. INTRODUCTION TO HTML 12-30

4. CSS 31-40

5. XML 41-49
1

1. BASICS OF INTERNET AND WEB

What is the Internet ?


The Internet is a short form for an interconnected network. It has become a vital part of our
lives, helping us connect with people worldwide. The Internet is made of a large number of
independently operated networks. It is fully distributed with no central control. Each
independently-operated system is motivated to ensure that there is end-to-end connectivity of
every part of the network.

History of the Internet

The first question that pops into your mind is


probably, “Who started the internet?”. The Internet
was developed by Bob Kahn and Vint Cerf in the
1970s. They began the design of what we today
know as the ‘internet.’ It was the result of another
research experiment which was called ARPANET,
Vinton Gray which stands for Advanced Research Projects Robert Elliot
Cerf Kahn
Agency Network. This was initially supposed to be
a communications system for the Defense Team of the United States of America - a network
that would also survive a nuclear attack. It eventually became a successful nationwide
experimental packet network. But when was the first Internet started? It is believed that on 6
August 1991, when the World Wide Web opened to the public.

How Does the Internet Work?

Computers that we use every day are called clients because they are indirectly connected to
the Internet through an internet service provider. When you open a webpage on your
computer, you connect to the webpage, and then you can access it. Computers break the
information into smaller pieces called packets, which are reassembled in their original order.

The below are the steps for how the message is transferred.

 First, Computer1 sends a message by IP address to Computer2


 The message sent by Computer1 is broken into small pieces- packets.
 These small pieces- packets are transferred concerning Transfer Protocol so that the
quality is maintained.
2

 Finally, these small pieces- packets reach Computer2 and are reassembled at their IP
address.

The Internet works in a more complex manner than these above-given steps, but this might
give a basic idea of how the internet works.

Advantages of Internet
Internet technology has numerous advantages. You can connect with anyone in this world
without facing any errors. The internet has brought the world close to each other. Have a look
at some essential benefits of internet.

 Source of Information
 Source of Entertainment
 Keep Informed
 Online Shopping
 Communication
 Social Networking
 Learning
 Earn Money from the Internet
 Online Banking
 Accessibility
Disadvantages of Internet
The internet has many conveniences, but excessive usage of the internet can affect you in a
variety of ways. There are a lot of uses and limitations of the internet. So, let's explore
the drawbacks of the internet.

 A Waste of time
 Not Safe Place for Children
 Privacy Exposure
 Money Frauds
 Virus/Malware
 Online Threatening or Harassment
 Cyberbullying
 Wrong Information
 Health Issue
3

Common Internet protocols--


Common Internet protocols include TCP/IP (Transmission Control Protocol/Internet
Protocol), UDP/IP (User Datagram Protocol/Internet Protocol), HTTP (HyperText Transfer
Protocol) and FTP (File Transfer Protocol).

TCP/IP
TCP/IP is a stream protocol. This means that a connection is negotiated between a client and
a server. Any data transmitted between these two endpoints is guaranteed to arrive, thus it is a
so-called lossless protocol. Since the TCP protocol (as it is also referred to in short form) can
only connect two endpoints, it is also called a peer-to-peer protocol.

HTTP
HTTP is the protocol used to transmit all data present on the World Wide Web. This includes
text, multimedia and graphics. It is the protocol used to transmit HTML, the language that
makes all the fancy decorations in your browser. It works upon TCP/IP.
FTP
FTP is the protocol used to transmit files between computers connected to each other by a
TCP/IP network, such as the Internet.
What is an IP Address ?

An IP address is a unique address that identifies a device on the internet or a local network.
IP stands for "Internet Protocol," which is the set of rules governing the format of data sent
via the internet or local network.
In essence, IP addresses are the identifier that allows information to be sent between devices
on a network: they contain location information and make devices accessible for
communication. The internet needs a way to differentiate between different computers,
routers, and websites. IP addresses provide a way of doing so and form an essential part of
how the internet works.

What is World Wide Web ?

World Wide Web, which is also known as a Web, is a collection of websites or web pages
stored in web servers and connected to local computers through the internet. These websites
contain text pages, digital images, audios, videos, etc. Users can access the content of these
sites from any part of the world over the internet using their devices such as computers,
4

laptops, cell phones, etc. The WWW, along with internet, enables the retrieval and display of
text and media to your device.
What is a Website ?

A collection of web pages and media over the internet is called a website. The website can be
published on at least one web server and can be identified by a common domain name, for
example - google.com, youtube.com.

A website can be of two types:

 Static Website
 Dynamic Website

Static website
Static website is the basic type of website that is easy to create. You don't need the
knowledge of web programming and database design to create a static website. Its web pages
are coded in HTML.

SERVER CLIENT/BROWSER

Dynamic website
Dynamic website is a collection of dynamic web pages whose content changes dynamically.
It accesses content from a database or Content Management System (CMS). Therefore, when
you alter or update the content of the database, the content of the website is also altered or
updated.
Dynamic website uses client-side scripting or server-side scripting, or both to generate
dynamic content.
5

SERVER DATABASE (S) CLIENT/BROWSER

Webpage
A web page is a single hypertext document available on World Wide Web (WWW). It is
composed of HTML elements and displayed on the user's browser such as Chrome , Mozilla,
Firefox etc. It is also referred to as "Page."
Home page
The homepage or home page is the name of the main page of a website where visitors can
find hyperlinks to other pages on the site.
SMTP
 SMTP stands for Simple Mail Transfer Protocol.
 SMTP is a set of communication guidelines that allow software to transmit an electronic
mail over the internet is called Simple Mail Transfer Protocol.
 It is a program used for sending messages to other computer users based on e-mail
addresses.
 It provides a mail exchange between users on the same or different computers, and it also
supports:
 It can send a single message to one or more recipients.
 Sending message can include text, voice, video or graphics.
 It can also send the messages on networks outside the internet.
Simple Network Management Protocol (SNMP)
SNMP is an application layer protocol that uses UDP port number 161/162.SNMP is used to
monitor the network, detect network faults, and sometimes even used to configure remote
devices.
SNMP components :
There are 3 components of SNMP:
SNMP Manager
It is a centralized system used to monitor network. It is also known as Network Management
Station (NMS)
6

SNMP agent
It is a software management software module installed on a managed device. Managed
devices can be network devices like PC, routers, switches, servers, etc.

Management Information Base


MIB consists of information on resources that are to be managed. This information is
organized hierarchically. It consists of objects instances which are essentially variables.

Trivial File Transfer Protocol (TFTP)


Trivial File Transfer Protocol (TFTP) is a simple protocol used for transferring files. TFTP
uses the User Datagram Protocol (UDP) to transport data from one end to another. TFTP is
mostly used to read and write files/mail to or from a remote server.
Trivial File Transfer Protocol is very simple in design and has limited features as compared
to File Transfer Protocol (FTP). TFTP provides no authentication and security while
transferring files. As a result, it is usually used for transferring boot files or configuration
files between machines in a local setup. Because of its simple design, it is rarely used
interactively by users in a computer network. Its lack of security also makes it dangerous for
use over the Internet.

Client-side scripting language :


Web browsers execute client-side scripting. It is used when browsers have all code. Source
code is used to transfer from webserver to user’s computer over the internet and run directly
on browsers. It is also used for validations and functionality for user events.

Server-side scripting language :


Web servers are used to execute server-side scripting. They are basically used to create
dynamic pages. It can also access the file system residing at the webserver. A server-side
environment that runs on a scripting language is a web server.

What is VBScript ?
7

VBScript (Visual Basic Script) is developed by Microsoft with the intention of developing
dynamic web pages. It is client-side scripting language like JavaScript. VBScript is a light
version of Microsoft Visual Basic. The syntax of VBScript is very similar to that of Visual
Basic. If you want your webpage to be more lively and interactive, then you can incorporate
VBScript in your code.
VBScript is just a scripting language. So, it cannot run its code on its own. It needs a bigger
programming language to host it.

there are 3 environments where VB Scripts can run.

 IIS (Internet Information Server) – Microsoft’s web server


 WSH (Windows Script Host)– The native hosting environment of the Windows OS
 IE (Internet Explorer)– The simplest hosting environment we can use to run VBScript

What are ActiveX controls ?

ActiveX controls are component program objects that Microsoft developed to enable
applications to perform specific functions, such as displaying a calendar or playing a video.
An ActiveX control is a small program that other applications can reuse to enable the same
functionality, without the extra development work.

What Are Plugins?

Plugins are software additions that allow for the customization of computer programs, apps,
and web browsers -- as well as the customization of the content offered by websites. While
plugins continue to be used as add-ons to customize programs and apps, their use in web
browsers has decreased somewhat, in favor of using browser extensions instead.

What is an API ?

APIs are mechanisms that enable two software components to communicate with each other
using a set of definitions and protocols. For example, the weather bureau’s software system
contains daily weather data. The weather app on your phone “talks” to this system via APIs
and shows you daily weather updates on your phone.
8

What is common gateway interface (CGI) ?


The Common Gateway Interface (CGI) standard is a data-passing specification used when
a Web server must send or receive data from an application such as a database. A CGI script
passes the request from the Web server to a database, gets the output and returns it to the
Web client.

Web browser
Database

HTTP Request HTTP Response

Query Results

server CGI Program


CGI Gateway

What is ODBC?
Open Database Connectivity (ODBC) is an open standard Application Programming
Interface (API) for accessing a database. In 1992, Microsoft partners with Simba to build the
world’s first ODBC driver; SIMBA.DLL, and standards-based data access was born. By
using ODBC statements in a program, you can access files in a number of different common
databases. In addition to the ODBC software, a separate module or driver is needed for each
database to be accessed.
9

1.
10

2. DHTML

DHTML stands for Dynamic Hypertext Markup language i.e., Dynamic HTML.

Dynamic HTML is not a markup or programming language but it is a term that combines
the features of various web development technologies for creating the web pages dynamic
and interactive.

The DHTML application was introduced by Microsoft with the release of the 4 th version
of IE (Internet Explorer) in 1997.

DHTML consists of the following four components or languages:

 HTML 4.0
 CSS
 JavaScript
 DOM.

HTML 4.0

HTML is a client-side markup language, which is a core component of the DHTML. It


defines the structure of a web page with various defined basic elements or tags.

CSS

CSS stands for Cascading Style Sheet, which allows the web users or developers for
controlling the style and layout of the HTML elements on the web pages.

JavaScript

JavaScript is a scripting language which is done on a client-side. The various browser


supports JavaScript technology. DHTML uses the JavaScript technology for accessing,
controlling, and manipulating the HTML elements. The statements in JavaScript are the
commands which tell the browser for performing an action.

DOM

DOM is the document object model. It is a w3c standard, which is a standard interface of
programming for HTML. It is mainly used for defining the objects and properties of all
elements in HTML.
11

Uses of DHTML

Following are the uses of DHTML (Dynamic HTML):

 It is used for designing the animated and interactive web pages that are developed in real-
time.
 DHTML helps users by animating the text and images in their documents.
 It allows the authors for adding the effects on their pages.
 It also allows the page authors for including the drop-down menus or rollover buttons.
 This term is also used to create various browser-based action games.
 It is also used to add the ticker on various websites, which needs to refresh their content
automatically.

Features of DHTML

Following are the various characteristics or features of DHTML (Dynamic HTML):

 Its simplest and main feature is that we can create the web page dynamically.
 Dynamic Style is a feature, that allows the users to alter the font, size, color, and content
of a web page.
 It provides the facility for using the events, methods, and properties. And, also provides
the feature of code reusability.
 It also provides the feature in browsers for data binding.
 Using DHTML, users can easily create dynamic fonts for their web sites or web pages.
 With the help of DHTML, users can easily change the tags and their properties.
 The web page functionality is enhanced because the DHTML uses low-bandwidth effect.
12

3. INTRODUCTION TO HTML

HTML – OVERVIEW
HTML stands for Hypertext Markup Language, and it is the most widely used language to
write Web Pages.

 Hypertext refers to the way in which Web pages (HTML documents) are linked together.
Thus, the link available on a webpage is called Hypertext
 As its name suggests, HTML is a Markup Language which means you use HTML to
simply "mark-up" a text document with tags that tell a Web browser how to structure it to
display.

Originally, HTML was developed with the intent of defining the structure of documents like
headings, paragraphs, lists, and so forth to facilitate the sharing of scientific information
between researchers. Now, HTML is being widely used to format web pages with the help of
different tags available in HTML language.

Now, HTML is being widely used to format web pages with the help of different tags
available in HTML language.

Basic HTML Document

In its simplest form, following is an example of an HTML document:

<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
Either you can use Try it option available at the top right corner of the code box to check the
result of this HTML code, or let's save it in an HTML file test.htm using your favorite text
13

editor. Finally open it using a web browser like Internet Explorer or Google Chrome, or
Firefox etc. It must show the following output:

HTML Tags

As told earlier, HTML is a markup language and makes use of various tags to format the
content. These tags are enclosed within angle braces <Tag Name>. Except few tags, most of
the tags have their corresponding closing tags. For example, <html> has its closing
tag</html> and <body> tag has its closing tag </body> tag etc.

Above example of HTML document uses the following tags:

Tag Description

<!DOCTYPE...> This tag defines the document type and HTML version.

This tag encloses the complete HTML document and mainly


<html> comprises of document header which is represented by
<head>...</head> and document body which is represented by
<body>...</body> tags.
This tag represents the document's header which can keep other
<head> HTML tags like <title>, <link> etc.

The <title> tag is used inside the <head> tag to mention the
<title> document title.
14

This tag represents the document's body which keeps other


<body> HTML tags like <h1>, <div>, <p> etc.

This tag represents the heading.


<h1>

To learn HTML, you will need to study various tags and understand how they behave, while
formatting a textual document. Learning HTML is simple as users have to learn the usage of
different tags in order to format the text or images to make a beautiful webpage.
World Wide Web Consortium (W3C) recommends to use lowercase tags starting from
HTML 4.

HTML Document Structure


A typical HTML document will have the following structure:

Document declaration tag


<html>
<head>
Document header related tags
</head>
<body>
Document body related tags
</body>
</html>

We will study all the header and body tags in subsequent chapters, but for now let's see what
is document declaration tag.

The <!DOCTYPE> Declaration

The <!DOCTYPE> declaration tag is used by the web browser to understand the version of
the HTML used in the document. Current version of HTML is 5 and it makes use of the
following declaration:
<!DOCTYPE html>

There are many other declaration types which can be used in HTML document depending on
what version of HTML is being used.
15

Heading Tags

Any document starts with a heading. You can use different sizes for your headings. HTML
also has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and
<h6>. While displaying any heading, browser adds one line before and one line after that
heading.

Example :

<!DOCTYPE html>

<html>

<head>

<title>Heading Example</title>

</head>

<body>

<h1>This is heading 1</h1>

<h2>This is heading 2</h2>

<h3>This is heading 3</h3>

<h4>This is heading 4</h4>

<h5>This is heading 5</h5>

<h6>This is heading 6</h6>

</body> </html>

This will produce the following result:


16

Paragraph Tag

The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of
text should go in between an opening <p> and a closing </p> tag as shown below in the
example:

Example:

<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
This will produce the following result:

Here is a first paragraph of text.


Here is a second paragraph of text.
Here is a third paragraph of text.
17

Line Break Tag

Whenever you use the <br /> element, anything following it starts from the next line. This
tag is an example of an empty element, where you do not need opening and closing tags, as
there is nothing to go in between them.

The <br /> tag has a space between the characters br and the forward slash. If you omit this
space, older browsers will have trouble rendering the line break, while if you miss the
forward slash character and just use <br> it is not valid in XHTML.
Example :

<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Mr rajput</p>
</body>
</html>

This will produce the following result:

Hello
You delivered your assignment on time.
Thanks Mr Rajput

Centering Content
You can use <center> tag to put any content in the center of the page or any table
cell.

Example :

<!DOCTYPE html>
<html>
18

<head>
<title>Centring Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>
</body>
</html>
This will produce the following result:

This text is not in the center.


This text is in the center.

Horizontal Lines

Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates a
line from the current position in the document to the right margin and breaks the line
accordingly.

For example, you may want to give a line between two paragraphs as in the given example
below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
This will produce the following result:
19

This is paragraph one and should be on top


This is paragraph two and should be at bottom

Again <hr /> tag is an example of the empty element, where you do not need opening and
closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward slash. If you omit
this space, older browsers will have trouble rendering the horizontal line, while if you miss
the forward slash character and just use <hr> it is not valid in XHTML

Preserve Formatting

Sometimes, you want your text to follow the exact format of how it is written in the HTML
document. In these cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will preserve the
formatting of the source document.
Example

<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
This will produce the following result:

function testFunction( strText ){


alert (strText)
}

Try using the same code without keeping it inside <pre>...</pre> tags
20

Nonbreaking Spaces

Suppose you want to use the phrase "12 Angry Men." Here, you would not want a browser to
split the "12, Angry" and "Men" across two lines:

An example of this technique appears in the movie "12 Angry Men."

In cases, where you do not want the client browser to break text, you should use a
nonbreaking space entity &nbsp; instead of a normal space. For example, when coding the
"12 Angry Men" in a paragraph, you should use something similar to the following code:

Example :

<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
<p>An example of this technique appears in the movie "12&nbsp;Angry&nbsp;Men."</p>
</body>
</html>

HTML – ELEMENTS

An HTML element is defined by a starting tag. If the element contains other content, it ends
with a closing tag, where the element name is preceded by a forward slash as shown below
with few tags:
Start Tag Content End Tag
<p> This is paragraph content. </p>

<h1> This is heading content. </h1>

<div> This is division content. </div>

<br /> This Is Line Breake content

So here <p>....</p> is an HTML element, <h1>...</h1> is another HTML element. There are
some HTML elements which don't need to be closed, such as <img.../>, <hr /> and <br />
elements. These are known as void elements.
21

HTML documents consists of a tree of these elements and they specify how HTML
documents should be built, and what kind of content should be placed in what part of an
HTML document.

HTML Tag vs. Element

An HTML element is defined by a starting tag. If the element contains other content, it ends
with a closing tag.

For example, <p> is starting tag of a paragraph and </p> is closing tag of the same paragraph
but <p>This is paragraph</p> is a paragraph element.

Nested HTML Elements


It is very much allowed to keep one HTML element inside another HTML element:

Example :

<!DOCTYPE html>
<html>
<head>
<title>Nested Elements Example</title>
</head>
<body>
<h1>This is <i>italic</i> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
</body>
</html>

This will display the following result:

This is italic heading


This is underlined paragraph

HTML – ATTRIBUTES

We have seen few HTML tags and their usage like heading tags <h1>, <h2>, paragraph tag
<p> and other tags. We used them so far in their simplest form, but most of the HTML tags
can also have attributes, which are extra bits of information.
22

An attribute is used to define the characteristics of an HTML element and is placed inside the
element's opening tag. All attributes are made up of two parts: a name and a value:

The name is the property you want to set. For example, the paragraph <p> element in the
example carries an attribute whose name is align, which you can use to indicate the alignment
of paragraph on the page.

The value is what you want the value of the property to be set and always put within
quotations. The below example shows three possible values of align attribute: left, center and
right.

Attribute names and attribute values are case-insensitive. However, the World Wide Web
Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4
recommendation.

Example :

<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>
This will display the following result:

This is left aligned


This is center aligned
This is right aligned
23

HTML – FORMATTING
If you use a word processor, you must be familiar with the ability to make text bold,
italicized, or underlined; these are just three of the ten options available to indicate how text
can appear in HTML and XHTML.

Bold Text

Anything that appears within <b>...</b> element, is displayed in bold as shown below:

Example :

<!DOCTYPE html>
<html>
<head>
<title>Bold Text Example</title>
</head>
<body>
<p>The following word uses a <b>bold</b> typeface.</p>
</body>
</html>
This will produce the following result:

The following word uses a bold typeface.

Italic Text

Anything that appears within <i>...</i> element is displayed in italicized as shown below:

Example :

<!DOCTYPE html>
<html>
<head>
<title>Italic Text Example</title>
</head>
<body>
24

<p>The following word uses a <i>italicized</i> typeface.</p>


</body>
</html>

This will produce the following result:

The following word uses an italicized typeface.

Underlined Text

Anything that appears within <u>...</u> element, is displayed with underline as shown
below:

Example :

<!DOCTYPE html>
<html>
<head>
<title>Underlined Text Example</title>
</head>
<body>
<p>The following word uses a <u>underlined</u> typeface.</p>
</body>
</html>
This will produce the following result:

The following word uses an underlined typeface.

Strike Text
Anything that appears within <strike>...</strike> element is displayed with strikethrough,
which is a thin line through the text as shown below:

Example :

<!DOCTYPE html>
25

<html>
<head>
<title>Strike Text Example</title>
</head>
<body>
<p>The following word uses a <strike>strikethrough</strike> typeface.</p>
</body>
</html>
This will produce the following result:

The following word uses a strikethrough typeface.

Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size used is the
same size as the characters surrounding it but is displayed half a character's height above the
other characters.
Example :

<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a <sup>superscript</sup> typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a superscript typeface.
26

Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the same
as the characters surrounding it, but is displayed half a character's height beneath the other
characters.

Example :

<!DOCTYPE html>
<html>
<head>
<title>Subscript Text Example</title>
</head>
<body>
<p>The following word uses a <sub>subscript</sub> typeface.</p>
</body>
</html>

This will produce the following result:

The following word uses a subscript typeface.

Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.

Example:

<!DOCTYPE html>
<html>
<head>
<title>Deleted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
27

This will produce the following result:

Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest of the
text surrounding it as shown below:
Example :

<!DOCTYPE html>
<html>
<head>
<title>Larger Text Example</title>
</head>
<body>
<p>The following word uses a <big>big</big> typeface.</p>
</body>
</html>

This will produce the following result:

The following word uses a big typeface.

Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than the rest
of the text surrounding it as shown below:
Example :

<!DOCTYPE html>
<html>
<head>
<title>Smaller Text Example</title>
</head>
<body>
<p>The following word uses a <small>small</small> typeface.</p>
28

</body>
</html>

This will produce the following result:

The following word uses a small typeface.

HTML – PHRASE TAGS


The phrase tags have been desicolgned for specific purposes, though they are displayed in a
similar way as other basic tags like <b>, <i>, <pre>, and <tt>, you have seen in previous
chapter. This chapter will take you through all the important phrase tags, so let's start seeing
them one by one.

Emphasized Text
Anything that appears within <em>...</em> element is displayed as emphasized text.

Example :

<!DOCTYPE html>
<html>
<head>
<title>Emphasized Text Example</title>
</head>
<body>
<p>The following word uses a <em>emphasized</em> typeface.</p>
</body>
</html>

This will produce the following result:

The following word uses an emphasized typeface.

Marked Text
Anything that appears with-in <mark>...</mark> element, is displayed as marked with yellow
ink.
29

Example :

<!DOCTYPE html>
<html>
<head>
<title>Marked Text Example</title>
</head>
<body>
<p>The following word has been <mark>marked</mark> with yellow</p>
</body>
</html>
This will produce the following result:

The following word has been marked with yellow.

Strong Text
Anything that appears within <strong>...</strong> element is displayed as important text.
Example :

<!DOCTYPE html>
<html>
<head>
<title>Strong Text Example</title>
</head>
<body>
<p>The following word uses a <strong>strong</strong> typeface.</p>
</body>
</html>

This will produce the following result:

The following word uses a strong typeface.


30

Address Text
The <address>...</address> element is used to contain any address.
Example :

<!DOCTYPE html>
<html>
<head>
<title>Address Example</title>
</head>
<body>
<address>388A, Road No 22, Jubilee Hills - Hyderabad</address>
</body>
</html>

This will produce the following result:

388A, Road No 22, Jubilee Hills – Hyderabad


31

4. CSS

What is CSS ?
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to
simplify the process of making web pages presentable.

CSS handles the look and feel part of a web page. Using CSS, you can control the color of
the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid
out, what background images or colors are used, as well as a variety of other effects.

CSS is easy to learn and understand but it provides a powerful control over the presentation
of an HTML document. Most commonly, CSS is combined with the markup languages
HTML or XHTML.

Advantages of CSS
 CSS saves time - You can write CSS once and then reuse the same sheet in multiple
HTML pages. You can define a style for each HTML element and apply it to as many
web pages as you want.
 Pages load faster - If you are using CSS, you do not need to write HTML tag
attributes every time. Just write one CSS rule of a tag and apply it to all the
occurrences of that tag. So, less code means faster download times.
 Easy maintenance - To make a global change, simply change the style, and all the
elements in all the web pages will be updated automatically.
 Superior styles to HTML - CSS has a much wider array of attributes than HTML, so
you can give a far better look to your HTML page in comparison to HTML attributes.
 Multiple Device Compatibility - Style sheets allow content to be optimized for more
than one type of device. By using the same HTML document, different versions of a
website can be presented for handheld devices such as PDAs and cellphones or for
printing.

Who Creates and Maintains CSS?


CSS is created and maintained through a group of people within the W3C called the CSS
Working Group. The CSS Working Group creates documents called specifications. When a
specification has been discussed and officially ratified by the W3C members, it becomes a
recommendation.
32

These ratified specifications are called recommendations because the W3C has no control
over the actual implementation of the language. Independent companies and organizations
create that software.
NOTE: The World Wide Web Consortium or W3C is a group that makes recommendations
about how the Internet works and how it should evolve.

CSS Versions
Cascading Style Sheets level 1 (CSS1) came out of W3C as a recommendation in
December 1996. This version describes the CSS language as well as a simple visual
formatting model for all the HTML tags.
CSS2 became a W3C recommendation in May 1998 and builds on CSS1. This version adds
support for media-specific style sheets e.g. printers and aural devices, downloadable fonts,
element positioning and tables.

CSS ─ SYNTAX
A CSS comprises of style rules that are interpreted by the browser and then applied to the
corresponding elements in your document. A style rule is made of three parts:
 Selector: A selector is an HTML tag at which a style will be applied. This could be
any tag like <h1> or <table> etc.
 Property: A property is a type of attribute of HTML tag. Put simply, all the HTML
attributes are converted into CSS properties. They could be color, border, etc.

 Value: Values are assigned to properties. For example, color property can have the
value either red or #F1F1F1 etc.
You can put CSS Style Rule Syntax as follows:
selector { property: value }
Example:

You can define a table border as follows:

table{ border :1px solid #C00; }

Here table is a selector and border is a property and the given value 1px solid #C00 is the
value of that property.
You can define selectors in various simple ways based on your comfort. Let me put these
selectors one by one.
The Type Selectors
33

This is the same selector we have seen above. Again, one more example to give a color to
all level 1 headings:
h1 {
color: #36CFFF;
}

The Universal Selectors


Rather than selecting elements of a specific type, the universal selector quite simply
matches the name of any element type:
*{
color: #000000;
}
This rule renders the content of every element in our document in black.

The Descendant Selectors


Suppose you want to apply a style rule to a particular element only when it lies inside a
particular element. As given in the following example, the style rule will apply to <em>
element only when it lies inside the <ul> tag.
ul em {
color: #000000;
}
The Class Selectors
You can define style rules based on the class attribute of the elements. All the elements
having that class will be formatted according to the defined rule.
.black {
color: #000000;
}
This rule renders the content in black for every element with class attribute set to black in
our document. You can make it a bit more particular. For example:
h1.black {
color: #000000;
}
This rule renders the content in black for only <h1> elements with class attribute set to
black.
34

You can apply more than one class selectors to a given element. Consider the following
example:
<p class="center bold">
This para will be styled by the classes center and bold.
</p>

The ID Selectors
You can define style rules based on the id attribute of the elements. All the elements having
that id will be formatted according to the defined rule.
#black {
color: #000000;
}
This rule renders the content in black for every element with id attribute set to black in our
document. You can make it a bit more particular. For example:
h1#black {
color: #000000;
}
This rule renders the content in black for only <h1> elements with id attribute set to black.
The true power of id selectors is when they are used as the foundation for descendant
selectors. For example:
#black h2 {
color: #000000;
}
In this example, all level 2 headings will be displayed in black color when those headings
will lie within tags having id attribute set to black.

The Child Selectors


You have seen the descendant selectors. There is one more type of selector, which is very
similar to descendants but have different functionality. Consider the following example:
body > p {
color: #000000;
}
35

This rule will render all the paragraphs in black if they are a direct child of the <body>
element. Other paragraphs put inside other elements like <div> or <td> would not have any
effect of this rule.

The Attribute Selectors


You can also apply styles to HTML elements with particular attributes. The style rule
below will match all the input elements having a type attribute with a value of text:
input[type="text"]{
color: #000000;
}
The advantage to this method is that the <input type="submit" /> element is unaffected, and
the color applied only to the desired text fields.
There are following rules applied to attribute selector.
 p[lang] - Selects all paragraph elements with a lang attribute.
 p[lang="fr"] - Selects all paragraph elements whose lang attribute has a value of
exactly "fr".
 p[lang~="fr"] - Selects all paragraph elements whose lang attribute contains the
word "fr".
 p[lang|="en"] - Selects all paragraph elements whose lang attribute contains values
that are exactly "en", or begin with "en-".

Multiple Style Rules


You may need to define multiple style rules for a single element. You can define these rules
to combine multiple properties and corresponding values into a single block as defined in
the following example:
h1 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
Here all the property and value pairs are separated by a semicolon (;). You can keep them
in a single line or multiple lines. For better readability, we keep them in separate lines.
36

For a while, don't bother about the properties mentioned in the above block. These
properties will be explained in the coming chapters and you can find the complete detail
about properties in CSS References.
Grouping Selectors
You can apply a style to many selectors if you like. Just separate the selectors with a
comma, as given in the following example:
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
This define style rule will be applicable to h1, h2 and h3 element as well. The order of the
list is irrelevant. All the elements in the selector will have the corresponding declarations
applied to them.
You can combine the various class selectors together as shown below:
#content, #footer, #supplement {
position: absolute;
left: 510px;
width: 200px;
}
CSS ─ INCLUSION
There are four ways to associate styles with your HTML document. Most commonly used
methods are inline CSS and External CSS.

Embedded CSS - The <style> Element


You can put your CSS rules into an HTML document using the <style> element. This tag is
placed inside the <head>...</head> tags. Rules defined using this syntax will be applied to all
the elements available in the document. Here is the generic syntax:
<head>
<style type="text/css" media="...">
Style Rules
............
</style>
</head>
37

Attributes
Attributes associated with <style> elements are:

Attribute Value Description

type text/css Specifies the style sheet


language as a content-type
(MIME type). This is a
required attribute.
media screen tty tv projection Specifies the device, the
handheld print braille document will be displayed
on. Default value is all. This
is an optional attribute.

Example :

Following is an example of embed CSS based on the above syntax:


<head>
<style type="text/css" media="all">
h1{
color: #36C;
}
</style>
</head>

Inline CSS - The style Attribute


You can use style attribute of any HTML element to define style rules. These rules will be
applied to that element only. Here is the generic syntax:
<element style="...style rules....">
<h1 style ="color:#36C;"> This is inline CSS </h1>

It will produce the following result:

This is inline CSS


38

External CSS - The <link> Element


The <link> element can be used to include an external stylesheet file in your HTML
document.
An external style sheet is a separate text file with .css extension. You define all the Style
rules within this text file and then you can include this file in any HTML document using
<link> element.
Here is the generic syntax of including external CSS file:
<head>
<link type="text/css" href="..." media="..." />
</head>

CSS Comments
Many times, you may need to put additional comments in your style sheet blocks. So, it is
very easy to comment any part in the style sheet. You can simply put your comments
inside /*.....this is a comment in style sheet.....*/.
You can use /* ....*/ to comment multi-line blocks in similar way you do in C and C++
programming languages.

Example :
/* This is an external style sheet file */
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
/* end of style rules. */

CSS ─ MEASUREMENT UNITS


Before we start the actual exercise, we would like to give a brief idea about the CSS
Measurement Units. CSS supports a number of measurements including absolute units such
as inches, centimeters, points, and so on, as well as relative measures such as percentages and
em units. You need these values while specifying various measurements in your Style rules
e.g. border="1px solid red".
39

We have listed out all the CSS Measurement Units along with proper Examples:

Unit Description Example

Defines a measurement as a p {font-size: 16pt; line-


% percentage relative to another height: 125%;}
value, typically an enclosing
element.
cm Defines a measurement in div {margin-bottom:
centimeters. 2cm;}
A relative measurement for the p {letter-spacing: 7em;}
height of a font in em spaces.
Because an em unit is
em equivalent to the size of a given
font, if you assign a font to
12pt, each "em" unit would be
12pt; thus, 2em would be 24pt.
This value defines a p {font-size: 24pt; line-
measurement relative to a font's height: 3ex;}
ex x-height. The x-height is
determined by the height of the
font's lowercase letter x.
in Defines a measurement in p {word-spacing: .15in;}
inches.
Defines a measurement in p {font-size: 20pc;}
pc picas. A pica is equivalent to 12
points; thus, there are 6 picas
per inch.
pt Defines a measurement in body {font-size: 18pt;}
points. A point is defined as
1/72nd of an inch.
px Defines a measurement in p {padding: 25px;}
screen pixels.

CSS ─ COLORS
40

CSS uses color values to specify a color. Typically, these are used to set a color either for the
foreground of an element (i.e., its text) or for the background of the element. They can also
be used to affect the color of borders and other decorative effects.
You can specify your color values in various formats. Following table lists all the possible
formats:

Format Syntax Example


Hex Code #RRGGBB p{color:#FF0000;}

Short Hex Code #RGB p{color:#6A7;}

RGB % rgb(rrr%,ggg%,bbb%) p{color:rgb(50%,50%,50%)


;}
RGB Absolute rgb(rrr,ggg,bbb) p{color:rgb(0,0,255);}

keyword aqua, black, etc. p{color:teal;}

5. XML
41

XML stands for Extensible Markup Language. It is a text-based markup language


derived from Standard Generalized Markup Language (SGML).
XML tags identify the data and are used to store and organize the data, rather than
specifying how to display it like HTML tags, which are used to display the data. XML is
not going to replace HTML in the near future, but it introduces new possibilities by
adopting many successful features of HTML.

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
A short list of XML usage says it all:
 XML can work behind the scene to simplify the creation of HTML documents for
large web sites.
 XML can be used to exchange the information between organizations and
systems.
 XML can be used for offloading and reloading of databases.
 XML can be used to store and arrange the data, which can customize your data
handling needs.
 XML can easily be merged with style sheets to create almost any desired output.
 Virtually, any type of data can be expressed as an XML document.

What is Markup ?
XML is a markup language that defines set of rules for encoding documents in a format
that is both human-readable and machine-readable. So, what exactly is a markup
language? Markup is information added to a document that enhances its meaning in
certain ways, in that it identifies the parts and how they relate to each other. More
42

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!.

Is XML a Programming Language?


A programming language consists of grammar rules and its own vocabulary which is used
to create computer programs. These programs instruct the computer to perform specific
tasks. XML does not qualify to be a programming language as it does not perform any
computation or algorithms. It is usually stored in a simple text file and is processed by
special software that is capable of interpreting XML.

XML – Syntax
In this chapter, we will discuss the simple syntax rules to write an XML document. Following
is a complete XML document:
<?xml version="1.0"?>
<contact-info>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact-info>
You can notice, there are two kinds of information in the above example:
 Markup, like <contact-info>

 The text, or the character data, Tutorials Point and (040) 123-4567

The following diagram depicts the syntax rules to write different types of markup and text in
an XML document.
43

Let us see each component of the above diagram in detail.

XML Declaration
The XML document can optionally have an XML declaration. It is written as follows:
<?xml version="1.0" encoding="UTF-8"?>
Where version is the XML version and encoding specifies the character encoding used in the
document.

Syntax Rules for XML Declaration


 The XML declaration is case sensitive and must begin with "<?xml>" where "xml" is
written in lower-case.
 If the document contains XML declaration, then it strictly needs to be the first
statement of the XML document.
 The XML declaration strictly needs be the first statement in the XML document.
 An HTTP protocol can override the value of encoding that you put in the XML
declaration.
Tags and Elements
An XML file is structured by several XML-elements, also called XML-nodes or XML-tags.
The names of XML-elements are enclosed in triangular brackets < > as shown below:
<element>
Syntax Rules for Tags and Elements

Element Syntax: Each XML-element needs to be closed either with start or with end
elements as shown below:
44

<element>....</element>
or in simple-cases, just this way:
<element/>
Nesting of Elements: An XML-element can contain multiple XML-elements as its children,
but the children elements must not overlap. i.e., an end tag of an element must have the same
name as that of the most recent unmatched start tag.
The following example shows incorrect nested tags:

<?xml version="1.0"?>
<contact-info>
<company>TutorialsPoint
<contact-info>
</company>
The following example shows correct nested tags:
<?xml version="1.0"?>
<contact-info>
<company>TutorialsPoint</company>
<contact-info>
Root Element: An XML document can have only one root element. For example, following
is not a correct XML document, because both the x and y elements occur at the top level
without a root element:
<x>...</x>
<y>...</y>
The following example shows a correctly formed XML document:
<root>
<x>...</x>
<y>...</y>
</root>
Case Sensitivity: The names of XML-elements are case-sensitive. That means the name of
the start and the end elements need to be exactly in the same case.
For example, <contact-info> is different from <Contact-Info>.

XML Attributes
45

An attribute specifies a single property for the element, using a name/value pair. An XML-
element can have one or more attributes. For example:
<a href="http://www.tutorialspoint.com/">Tutorialspoint!</a>

Here href is the attribute name and http://www.tutorialspoint.com/ is attribute value.

Syntax Rules for XML Attributes

 Attribute names in XML (unlike HTML) are case sensitive. That is, HREF and href
are considered two different XML attributes.
 Same attribute cannot have two values in a syntax. The following example shows
incorrect syntax because the attribute b is specified twice:
<a b="x" c="y" b="z">....</a>

 Attribute names are defined without quotation marks, whereas attribute values must
always appear in quotation marks. Following example demonstrates incorrect xml
syntax:
<a b=x>....</a>

In the above syntax, the attribute value is not defined in quotation marks.

XML References
References usually allow you to add or include additional text or markup in an XML
document. References always begin with the symbol "&" which is a reserved character and
end with the symbol ";". XML has two types of references:

 Entity References: An entity reference contains a name between the start and the end
delimiters. For example, &amp; where amp is name. The name refers to a predefined
string of text and/or markup.
 Character References: These contain references, such as &#65;, contains a hash
mark (“#”) followed by a number. The number always refers to the Unicode code of a
character. In this case, 65 refers to alphabet "A".

XML Text
The names of XML-elements and XML-attributes are case-sensitive, which means the name
of start and end elements need to be written in the same case. To avoid character encoding
problems, all XML files should be saved as Unicode UTF-8 or UTF-16 files.
46

Whitespace characters like blanks, tabs and line-breaks between XML-elements and between
the XML-attributes will be ignored.
Some characters are reserved by the XML syntax itself. Hence, they cannot be used directly.
To use them, some replacement-entities are used, which are listed below:

Not Allowed Character Replacement Entity Character Description

< &lt; less than

> &gt; greater than


& &amp; ampersand
' &apos; apostrophe
" &quot; quotation mark

XML – Documents
An XML document is a basic unit of XML information composed of elements and other
markup in an orderly package. An XML document can contain a wide variety of data. For
example, database of numbers, numbers representing molecular structure or a mathematical
equation.
XML Document Example
A simple document is shown in the following example:
<?xml version="1.0"?>
<contact-info>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact-info>
The following image depicts the parts of XML document.
47

Document Prolog Section


Document Prolog comes at the top of the document, before the root element. This section
contains:
 XML declaration
 Document type declaration

You can learn more about XML declaration in this chapter : XML Declaration.

Document Elements Section


Document Elements are the building blocks of XML. These divide the document into a
hierarchy of sections, each serving a specific purpose. You can separate a document into
multiple sections so that they can be rendered differently, or used by a search engine. The
elements can be containers, with a combination of text and other elements.

XML – Declaration
This chapter covers XML declaration in detail. XML declaration contains details that prepare
an XML processor to parse the XML document. It is optional, but when used, it must appear
in the first line of the XML document.
Syntax:
Following syntax shows XML declaration:
<?xml
version="version_number"
encoding="encoding_declaration"
standalone="standalone_status"
?>
Each parameter consists of a parameter name, an equals sign (=), and parameter value inside
a quote. Following table shows the above syntax in detail:
Parameter Parameter_value Parameter_description

Version 1.0 Specifies the version of the


XML standard used.
UTF-8, UTF-16, ISO- It defines the character encoding
10646-UCS-2, ISO-10646- used in the document. UTF-8 is
Encoding UCS-4, ISO-8859-1 to the default encoding used.
ISO-8859-9, ISO-2022-JP,
Shift_JIS, EUC-JP
It informs the parser whether the
48

document relies on the


information from an external
source, such as external
document type definition (DTD),
Standalone yes or no. for its content. The default value
is set to no. Setting it to yes tells
the processor there are no
external declarations required for
parsing the document.

Rules
An XML declaration should abide with the following rules:

 If the XML declaration is present in the XML, it must be placed as the first line in the
XML document.
 If the XML declaration is included, it must contain version number attribute.
 The parameter names and values are case-sensitive.
 The names are always in lower case.
 The order of placing the parameters is important. The correct order is: version,
encoding and standalone.
 Either single or double quotes may be used.
 The XML declaration has no closing tag, i.e. </?xml>

XML Declaration Examples


Following are few examples of XML declarations:
XML declaration with no parameters:
<?xml >
XML declaration with version definition:
<?xml version="1.0">
XML declaration with all parameters defined:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
XML declaration with all parameters defined in single quotes:
<?xml version='1.0' encoding='iso-8859-1' standalone='no' ?>

XML – Tags
49

Let us learn about one of the most important part of XML, the XML tags. XML tags form
the foundation of XML. They define the scope of an element in XML. They can also be used
to insert comments, declare settings required for parsing the environment, and to insert
special instructions.
We can broadly categorize XML tags as follows:
Start Tag
The beginning of every non-empty XML element is marked by a start-tag. Following is an
example of start-tag:
<address>

End Tag
Every element that has a start tag should end with an end-tag. Following is an example of
end-tag:
</address>
Note, that the end tags include a solidus ("/") before the name of an element.

Empty Tag
The text that appears between start-tag and end-tag is called content. An element which has
no content is termed as empty. An empty element can be represented in two ways as follows:
A start-tag immediately followed by an end-tag as shown below:
<hr></hr>
A complete empty-element tag is as shown below:
<hr />
Empty-element tags may be used for any element which has no content.

You might also like