Introduction to HTML, XML, and Web Development
Introduction to HTML, XML, and Web Development
Lecture 1
Web consists of billions of clients and server connected through wires and wireless
networks. The web clients make requests to web server. The web server receives the
request, finds the resources and returns the response to the client. When a server
answers a request, it usually sends some type of content to the client. The client uses
web browser to send request to the server. The server often sends response to the
browser with a set of instructions written in HTML (Hypertext Mark-up Language).
All browsers know how to display HTML page to the client.
1
top browser. That same year, Book Link Technologies introduced Internetworks,
the first browser with tabs.
By the mid-1990s, millions of people were using the Web. Microsoft entered the
scene with Internet
Explorer (IE) in 1995, based on Mosaic, and included it in Windows 95. This made
IE the most popular browser, reducing competition like Netscape.
Apple launched Safari in 2003 as the default browser for Macintosh computers, and
later for iPhones (2007) and iPads (2010). Safari 2.0 in 2005 introduced Private
Browsing, which did not save website history, downloaded files, or personal
information.
1.1.3 The Web Extends
Only a few people had access to the first Web browser, which ran on a NeXT
computer. To make it more accessible, Nicola Pellow created a simpler browser
called the ‘line-mode’ browser. This browser could run on any system.
In 1991, Tim Berners-Lee released his WWW software. It included the ‘line-mode’
browser, Web server software, and a library for developers. In March 1991, the
software was available to CERN colleagues. By August 1991, Berners-Lee
announced the WWW software on Internet newsgroups, and interest in the project
spread worldwide.
● World Wide Web (WWW): The World Wide Web is based on several
different technologies: Web browsers, Hypertext Markup Language
(HTML), and Hypertext Transfer Protocol (HTTP).
● Web Browser: The web browser is an application software to explore
www (World Wide Web). It provides an interface between the server
and the client and requests to the server for web documents and
services.
● Web Server: Web server is a program which processes the network
requests of the users and serves them with files that create web pages.
This exchange takes place using Hypertext Transfer Protocol (HTTP).
● Web Pages: A webpage is a digital document that is linked to the
World Wide Web and viewable by anyone connected to the internet
has a web browser.
● Web Development: Web development refers to the building, creating,
and maintaining of websites. It includes aspects such as web design,
web publishing, web programming, and database management. It is the
creation of an application that works over the internet i.e. websites.
Lecture 2
3
a. Communication
Protocols allow devices to communicate with each other by establishing rules for how
data is structured and exchanged. This allows devices to communicate even if they have
different software, hardware, or internal processes. For example, the Internet Protocol (IP)
allows computers to communicate with each other, even if they use different software and
hardware.
[Link]
Protocols can make processes transparent, which can help to avoid bias and duplication.
c. Peer review
Protocols can allow for peer review by reviewers with expertise in the area.
d. Coding
Protocols can be used in coding to improve code. For example, statically typed languages
check types at compile time, so issues with types are avoided at runtime.
Internet Protocols are of different types having different uses. These are
mentioned below:
These are a set of standard rules that allows different types of computers to
communicate with each other. The IP protocol ensures that each computer that is
connected to the Internet is having a specific serial number called the IP address.
TCP specifies how data is exchanged over the internet and how it should be broken
into IP packets. It also makes sure that the packets have information about the source
of the message data, the destination of the message data, the sequence in which the
message data should be re-assembled, and checks if the message has been sent
correctly to the specific destination. The TCP is also known as a connection-oriented
protocol.
These protocols are important for sending and distributing outgoing emails. This
protocol uses the header of the mail to get the email id of the receiver and enters the
mail into the queue of outgoing mail. And as soon as it delivers the mail to the
receiving email id, it removes the email from the outgoing list. The message or the
electronic mail may consider the text, video, image, etc. It helps in setting up some
communication server rules.
3. PPP(Point-to-Point Protocol)
4
For example, A user connects his PC to the server of an Internet Service Provider
and also uses PPP. Similarly, for connecting two routers for direct communication
it uses PPP.
This protocol is used for transferring files from one system to the other. This works
on a client-server model. When a machine requests for file transfer from another
machine, the FTO sets up a connection between the two and authenticates each other
using their ID and Password. And, the desired file transfer takes place between the
machines.
SFTP which is also known as SSH FTP refers to File Transfer Protocol (FTP) over
Secure Shell (SSH) as it encrypts both commands and data while in transmission.
SFTP acts as an extension to SSH and encrypts files and data then sends them over
a secure shell data stream. This protocol is used to remotely connect to other systems
while executing commands from the command line.
This protocol is used to transfer hypertexts over the internet and it is defined by the
www(world wide web) for information transfer. This protocol defines how the
information needs to be formatted and transmitted. And, it also defines the various
actions the web browsers should take in response to the calls made to access a
particular web page. Whenever a user opens their web browser, the user will
indirectly use HTTP as this is the protocol that is being used to share text, images,
and other multimedia files on the World Wide Web.
Note: Hypertext refers to the special format of the text that can contain
TELNET is a standard TCP/IP protocol used for virtual terminal service given by
5
ISO. This enables one local machine to connect with another. The computer which
is being connected is called a remote computer and which is connecting is called the
local computer. TELNET operation lets us display anything being performed on the
remote computer in the local computer. This operates on the client/server principle.
The local computer uses the telnet client program whereas the remote computer uses
the telnet server program.
POP3 stands for Post Office Protocol version 3. It has two Message Access Agents
(MAAs) where one is client MAA (Message Access Agent) and another is server
MAA (Message Access Agent) for accessing the messages from the mailbox. This
protocol helps us to retrieve and manage emails from the mailbox on the receiver
mail server to the receiver’s computer. This is implied between the receiver and the
receiver mail server. It can also be called a one-way client-server protocol. The
POP3 WORKS ON THE 2 PORTS I.E. PORT 110 AND PORT 995.
Lecture 3
6
● VoIP: It stands for Voice over Internet Protocol, which describes how to make
and receive phone calls over the internet. A larger number of people believe
VoIP is a viable alternative to traditional landlines. VoIP (Voice over Internet
Protocol) is a technique that helps us make voice calls via the Internet rather
than over a traditional (or analog) phone line. Some VoIP services may let
you call only other VoIP users, while others may let you call anyone with a
phone number, including long-distance, mobile, and local/international lines.
If you have an internet connection you can easily call anyone without using a
local phone service because VoIP solutions are based on open standards, they
can be used on any computer. More than just setting up calls is what VoIP
service providers do. Outgoing and incoming calls are routed through
existing telephone networks by them.
● List Server (LISTSERV): Delivers a group of email recipients’ content-
specific emails.
● E-Mail: Used to send electronic mail via the internet. It is a paperless method
for sending text, images, documents, videos, etc from one person to another
via the internet.
3. File Transfer: The exchange of data files across computer systems is referred to as
file transfer. Using the network or internet connection to transfer or shift a file from one
computer to another is known as file transfer. To share, transfer, or send a file or logical
data item across several users and/or machines, both locally and remotely, we use file
transfer. Data files include – documents, multimedia, pictures, text, and PDFs and they
can be shared by uploading or downloading them. To retrieve information from the
internet, there are various services available such as:
4. Web services: Web services are software that uses defined messaging protocols and
are made accessible for usage by a client or other web-based programs through an
application service provider’s web server. Web services allow information to be
exchanged across web-based applications. Using Utility Computing, web services can be
provided.
5. World Wide Web: The internet is a vast network of interconnected computers. Using
this network, you can connect to the World Wide Web (abbreviated as ‘www’ or ‘web’)
is a collection of web pages. The web browser lets you access the web via the internet.
● DNS (Domain Number System): This server provides DNS. The mappings
of computer hostnames and other types of domain names to IP addresses are
stored on a DNS server.
● LDAP (Lightweight Directory Access Protocol): It is a set of open protocols
that are used for obtaining network access to stored data centrally. It is a
cross-platform authentication protocol for directory services and also allows
users to interact with other directory services servers.
● ping: The ping command is a Command Prompt command that is used to see
if a source can communicate with a specific destination & get all the possible
paths between them.
● traceroute: To find the path between two connections, use the trace route
command.
9. Time Services: Using facilities included in the operating system, you may set your
computer clock via the Internet. Some services are :
10. Usenet: The ‘User’s Network’ is also known as Usenet. It is a network of online
discussion groups. It’s one of the first networks where users may upload files to news
servers and others can view them.
11. News Group: It is a lively Online Discussion Forum that is easily accessible via
Usenet. Each newsgroup contains conversations on a certain topic, as indicated by the
newsgroup name. Users can use newsreader software to browse and follow the
newsgroup as well as comment on the posts. A newsgroup is a debate about a certain
topic made up of notes posted to a central Internet site and distributed over Usenet, a
global network of news discussion groups. It uses Network News Transfer Protocol
(NNTP).
Lecture 4
9
1.6 Client Server Computing
In client server computing, the clients requests a resource and the server provides
that resource. A server may serve multiple clients at the same time while a client
is in contact with only one server. Both the client and server usually communicate
via a computer network but sometimes they may reside in the same system.
10
● An example of a client server computing system is a web server. It returns
the web pages to the clients that requested them.
The major differences between client server computing and peer to peer
computing are as follows:
In client server computing, a server is a central node that services many client
nodes. On the other hand, in a peer to peer system, the nodes collectively use their
resources and communicate with each other.
In client server computing the server is the one that communicates with the other
nodes. In peer to peer to computing, all the nodes are equal and share data with
each other directly. Client Server computing is believed to be a subcategory of
the peer to peer computing.
Example: A client (browser) sends an HTTP request to the server; then the server
returns a response to the client. The response contains status information about
the request and may also contain the requested content.
The following table compares the two HTTP methods: GET and POST.
12
GET POST
Restrictions on data Yes, when sending data, the GET method No restrictions
length adds the data to the URL; and the length of a
URL is limited (maximum URL length is
2048 characters)
13
Security GET is less secure compared to POST POST is a little safer
because data sent is part of the URL than GET because the
parameters are not stored
in browser history or in
web server logs
Never use GET when sending passwords or
other sensitive information!
Lecture-5
HTML stands for Hypertext Mark-up Language, and it's a code that's used to structure and define the
content of a web page:
1991 Tim Berners-Lee created HyperText Markup Language but it was not officially released.
Tim Berners-Lee created the first version of HTML that was published and available to the
1993
public.
1995 HTML 2.0 was released with a few additional features along with the existing features.
There was an attempt to extend HTML with HTML 3.0, but it was replaced by the more
1997
practical HTML 3.2.
The W3C (World Wide Web Consortium) decided to shift focus to an XML-based HTML
1998
equivalent called XHTML.
14
HTML 4.01, which became an official standard in December 1999, was the most widely used
1999
version in the early 2000s.
The introduction of XForms reignited interest in evolving HTML itself rather than replacing it
2003 with new technologies. This new theory recognized that XML was better suited for new
technologies like RSS and Atom, while HTML remained the cornerstone of the web.
A W3C workshop took place to explore reopening HTML's evolution. Mozilla and Opera
2004
jointly presented the principles that later influenced HTML5.
The W3C expressed interest in HTML5 development and formed a working group to
2006 collaborate with the WHATWG. The W3C aimed to publish a "finished" HTML5 version,
whereas the WHATWG focused on a Living Standard, continuously evolving HTML.
HTML5 can be seen as an extended version of HTML 4.01, which was officially published in
2012
2012.
Evolution of HTML Features: From HTML 1.2 to HTML 5
With the introduction of new versions of HTML, support for additional features was added, and the user
experience was enhanced. The following table shows the features introduced in later versions of HTML:
Type of HTML HTML HTML
Description
Content 1.2 4.01 5
15
Table is used to organize data
Table No Yes Yes
into rows and columns
Enables introduction of
Canvas No No Yes
graphics elements to webpage.
Physical tags on the other hand provide specific instructions on how to display the text
they enclose. Examples of physical tags include:
16
• <b>: Makes the text bold.
• <big>: Makes the text usually one size bigger than what is around it. • <i>:
Makes text italic
Physical tags were invented to add style to HTML pages because style sheets were not
around, though the original intention of HTML was to not have physical tags. Rather than
use physical tags to style your HTML pages, you should use style sheets.
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>
The purpose of the <b>tag is to define an HTML element that should be displayed
<body>
This HTML element starts with the start tag <body>,and ends with the end tag </body>. The
purpose of the <body>tag is to define the HTML element that contains the body of the
HTML document.
This tag defines an HTML table: <table>. With an added border attribute, you can tell the
browser thatthe table should have no borders: <table border="0">. Attributes always come
in name/value pairs like this: name="value". Attributes are always added to the start tag of
an HTML element and the value is surroundedby quotes.
The most important tags in HTML are tags that define headings, paragraphs and line breaks.
Headings
Headings are defined with the <h1>to <h6>tags. <h1>defines the largest heading while
<h6>defines the smallest.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
HTML automatically adds an extra blank line before and after a heading. A useful
heading attribute isalign.
<h5 align="left">I can align headings </h5>
<h5 align="center">This is a
centered heading </h5>
19
Paragraphs
Paragraphs are defined with the <p> tag. Think of a paragraph as a block of text. You
can use the align attribute with a paragraph tag as well.
Important: You must indicate paragraphs with <p> elements. A browser ignores any
indentations or blank lines in the source text. Without <p> elements, the document
becomes one large paragraph. HTML automatically adds an extra blank line before and
after a paragraph.
Line Breaks
The <br>tag is used when you want to start a new line, but don't want to start a new
paragraph. The
<br>tag forces a line break wherever you place it. It is similar to single spacing in a
document.
Horizontal Rule
The <hr>element is used for horizontal rules that act as dividers between sections, like
this:The horizontal rule does not have a closing tag. It takes attributes such as align and
width.
<p> This html comment would <!-- This HTML comment would be
This is a comment --> be displayed displayed like this.
like this.</p>
Notice you don't see the text between the tags <!-- and -->. If you look at the source
code, you would see the comment. To view the source code for this page, in your
browser window, select Viewand then selectSource.
Note: You need an exclamation point after the opening bracket <!--
but not before the closingbracket -->.
20
1.8.8 HTML Lists
HTML provides a simple way to show unordered lists (bullet lists) or ordered lists (numbered
lists).
Unordered Lists
An unordered list is a list of items marked with bullets (typically small black circles).
An unordered list starts with the <ul>tag. Each list item starts with the <li>tag.
Would Display
This Code
<ul> • Coffee
<li>Coffee</li> • Milk
<li>Milk</li>
</ul>
Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers. An
ordered list startswiththe <ol>tag. Each list item starts with the <li>tag.
This Would
Code Display
<ol> • Coffee
<li>Coffee</li> • Milk
<li>Milk</li>
</ol>
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
Definition Lists
Definition lists consist of two parts: a term and a description. To mark up a definition
list, you need three HTML elements; a container <dl>, a definition term <dt>, and a
definition description <dd>.
This Would
Code Display
21
<dl> Cascading Style Sheets
<dt>Cascading Style Sheets</dt> Style sheets are used to
<dd>Style sheets are used to provide presentational
provide presentational suggestions suggestions for documents
for marked up in HTML.
documentsmarked up in HTML.
</dd>
</dl>
Inside a definition-list definition (the <dd> tag) you can put paragraphs, line
breaks, images, links,other lists,etc
Try It Out
Open your text editor and type the following:
<html>
<head>
<title>My First Webpage</title>
</head>
<body bgcolor="#EDDD9E">
<h1 align="center">My First Webpage</h1>
<p>Welcome to my <strong>first</strong> webpage. I am writing this page using
a texteditor and plain oldhtml.</p>
<p>By learning html, I'll be able to create web pages like a pro..................................<br>
which I am of
course.</p>
Here's what
I've learned:
<ul>
<li>How to use HTML tags</li>
<li>How to use HTML colors</li>
<li>How to create Lists</li>
</ul>
</body>
</html>
Save your page as [Link] and view it in your browser. To see how your page
should look visitthisweb page:
[Link]
HTML uses the <a>anchor tag to create a link to another document or web
22
page. The Anchor Tag and the Href Attribute
An anchor can point to any resource on the Web: an HTML page, an image, a sound file,
a movie, [Link] of creating an anchor:
The <a> tag is used to create an anchor to link from, the href attribute is used to tell the
address of the document or page we are linking to, and the words between the open and
close of the anchor tag will be displayed as a hyperlink.
Email Links
To create an email link, you will use mailto: plus your email address. Here is a link to
ACC's Help Desk:
To add a subject for the email message, you would add ?subject= after the email address. For
example:
<a href= HYPERLINK
23
"[Link]
HYPERLINK "[Link]
HYPERLINK "[Link] Assistance">Email Help
The name attribute is used to create a named anchor. When using named anchors we can
create linksthat can jump directly to a specific section on a page, instead of letting the
user scroll around to find what he/she is looking for. Unlike an anchor that uses href, a
named anchor doesn't change the appearance of the text (unless you set styles for that
anchor) or indicate in any way that there is anything special about the text. Below is the
syntax of a named anchor:
<img src="graphics/[Link]">
Not only does the source attribute specify what image to use, but where the image
is located. The Above Image, graphics/[Link], means that the browser will look
for the image name [Link] in graphics
The alt attribute tells the reader what he or she is missing on a page if the browser
can't load images. The browser will then display the alternate text instead of the
image. It is a good practice to include the alt attribute for each image on a page, to
improve the display and usefulness of your document for people who have text-only
24
browsers or use screen readers.
Image Dimensions
When you have an image, the browser usually figures out how big the image is all by
itself. If you put in the image dimensions in pixels however, the browser simply reserves
a space for the image, then loads the rest of the page. Once the entire page is loads it can
go back and fill in the images. Without dimensions, when it runs into an image, the
browser has to pause loading the page, load the image, then continue loading the page.
The chef image would then be:
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1 align="center">My First Web page</h1>
<p>Welcome to my first webpage. I am writing this page using a text editor and plain
old html.</p>
<p>By learning html, I'll be able to create web pages like a
pro...........<br> which I am of course.</p>
<!-- Who would have guessed how easy this would be :) -->
<p><img src="graphics/[Link]" width="130" height="101" alt="Smiling
Happy Chef"align="center"></p>
<p align="center">This is my Chef</p>
</body>
</html>
Save your page as [Link] and view it in your browser. To see how your
page should look visitthisweb page:
[Link]
Tables are defined with the <table>tag. A table is divided into rows (with the <tr>tag),
and each row is divided into data cells (with the <td> tag). The letters td stands for
table data, which is the content of a datacell. A data cell can contain text, images, lists,
paragraphs, forms, horizontal rules, tables, etc.
25
<table> row 1, cell 1 row 1, cell 2
<tr> row 2, cell 1 row 2, cell 2
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
and....
This Code Would Display
Open up your text editor. Type in your <html>, <head>and <body>tags. From here on I
will only be writing what goes between the <body>tags. Type in the following:
<table border="1">
<tr>
<td>Tables can be used to layout information</td>
<td> <img src= HYPERLINK
"[Link]
26
<table border="1">
<tr>
<td>some text</td>
<td>some text</td>
</tr>
<tr>
<td>some text</td>
<td>some text</td>
</tr>
</table>
Save your page as [Link] and view it in your browser. To see how
your page should look visit this web page:
[Link]
Headings in a Table
Heading Another
Heading
27
some some
text text
some some
text text
Cellspacing is the pixel width between the individual data cells in the table (The
thickness of the lines making the table grid). The default is zero. If the border is set at
0, the cellspacing lines will be invisible.
This Code Would Display
<table border="1"
cellspacing="5"> <tr>
<td>some text</td>
<td>some text</td>
</tr><tr>
<td>some text</td>
<td>some text</td>
</tr>
</table>
Cellpadding is the pixel space between the cell contents and the cell border. The default
for this property is also zero. This feature is not used often, but sometimes comes in
handy when you have your borders turned on and you want the contents to be away from
the border a bit for easy viewing. Cellpadding is invisible, even with the border property
turned on. Cellpadding can be handled in a stylesheet.
28
This Code Would Display
<table border="1" cellpadding="10">
<tr>
<td>some text</td>
<td>some text</td>
</tr><tr>
<td>some text</td>
<td>some text</td>
</tr>
</table>
Table Tags
Tag Description
<col> Defines the attribute values for one or more columns in a table
Table Size
Table Width -
The width attribute can be used to define the width of your table. It can be defined as a
fixed width or a relative width. A fixed table width is one where the width of the table
is specified in pixels. For example,this code, <table width="550">, will produce a table
that is 550 pixels wide. A relative table width is specified as a percentage of the width
of the visitor's viewing window. Hence this code, <table width="80%">, will produce
a table that occupies 80 percent of the screen.
There are arguments in favor of giving your tables a relative width because such table
widths yield pages that work regardless of the visitor's screen resolution. For
example, a table width of 100% will always span the entire width of the browser
window whether the visitor has a 800x600 display or a 1024x768 display (etc). Your
visitor never needs to scroll horizontally to read your page, something that is
regarded by most people as being very annoying.
Lecture 6
29
1.8.12 HTML Frames
HTML frames are used to divide your browser window into multiple sections where each section
can load a separate HTML document. A collection of frames in the browser window is known as
a frameset. The window is divided into frames in a similar way the tables are organized: into rows
and columns.
Disadvantages of Frames
There are few drawbacks with using frames, so it's never recommended to use frames in your
webpages
● Some smaller devices cannot cope with frames often because their screen is not big enough to be
divided up.
● Sometimes your page will be displayed differently on different computers due to different screen
resolution.
● The browser's back button might not work as the user hopes. There are still few browsers that do
not support frame technology.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The <frameset> tag defines
how to divide the window into frames. The rows attribute of <frameset> tag defines horizontal frames
and cols attribute defines vertical frames. Each frame is indicated by <frame> tag and it defines which
HTML document shall open into the frame.
Example
Following is the example to create three horizontal frames:
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows="10%,80%,10%">
<frame name="top" src="/html/top_frame.htm" />
<frame name="main" src="/html/main_frame.htm" />
<frame name="bottom" src="/html/bottom_frame.htm" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
</html>
30
Browser Support for Frames
● If a user is using any old browser or any browser which does not support frames then
<noframes> element should be displayed to the user.
● So you must place a <body> element inside the <noframes> element because the
<frameset> element is
● supposed to replace the <body> element, but if a browser does not understand
● <frameset> element then it should understand what is inside the <body> element which is
contained in a <noframes> element.
You can put some nice message for your user having old browsers. For example Sorry!! your
browser does not support frames. as shown in the above example.
Frame's name and target attributes
One of the most popular uses of frames is to place navigation bars in one frame and then load
main pages into a separate frame.
Let's see following example where a [Link] file has following code:
31
<!DOCTYPE html>
<html>
<head>
<title>HTML Target Frames</title>
</head>
<frameset cols="200, *">
<frame src="/html/[Link]" name="menu_page" />
<frame src="/html/[Link]" name="main_page" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
</html>
Here we have created two columns to fill with two frames. The first frame is 200 pixels wide and
will contain the navigation menu bar implemented by [Link] file. The second column fills in
remaining space and will contain the main part of the page and it is implemented by [Link]
file. For all the three links available in menu bar, we have mentioned target frame as main_page,
so whenever you click any of the links in menu bar, available link will open in main_page.
Following is the content of [Link] file
<!DOCTYPE html>
<html>
<body bgcolor="#4a7d49">
<a href="[Link] target="main_page">Google</a>
<br /><br />
<a href="[Link] target="main_page">Microsoft</a>
<br /><br />
<a href="[Link] target="main_page">BBC News</a>
</body>
</html>
HTML iframes
● HTML Iframe is used to display a nested webpage (a webpage within a webpage). The
HTML <iframe> tag defines an inline frame, hence it is also called an Inline frame.
● An HTML iframe embeds another document within the current HTML document in the
rectangular region.
● The webpage content and iframe contents can interact with each other using JavaScript.
● Iframe Syntax:
● An HTML iframe is defined with the <iframe> tag:
● <iframe src="URL"></iframe>
● Here, "src" attribute specifies the web address (URL) of the inline frame page.
● Set Width and Height of iframe
32
You can set the width and height of the iframe by using "width" and "height" attributes.
By default, the attribute values are specified in pixels but you can also set them in percent. i.e.
50%, 60% etc.
Example: (Pixels)
<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframes example</h2>
<p>Use the height and width attributes to specify the size of the iframe:</p>
<iframe src="[Link] height="300" width="400"></iframe>
</body>
</html>
HTML Forms use the <form> tag to collect user input through various interactive
controls. These controls range from text fields, numeric inputs, and email fields to
password fields, checkboxes, radio buttons, and submit buttons.
~These controls range from text fields, numeric inputs, email fields, password fields, to
checkboxes, radio buttons, and submit buttons. In essence, an HTML Form serves as a
versatile container for numerous input elements, thereby enhancing user interaction.
Syntax:
<form>
<!--form elements-->
</form>
Form Elements
The HTML <form> comprises several elements, each serving a unique purpose. For
instance, the <label> element is used to define labels for other <form> elements. The
<input> element, on the other hand, is versatile and can be used to capture various types
of input data such as text, password, email, and more, simply by altering its type
attribute. Now, let’s all the list of HTML Form Elements one by one:
33
Elements Descriptions
<input> It is used to get input data from the form in various types
such as text, password, email, etc by changing its type.
34
<select> It is used to create a drop-down list.
<legend>
It defines a caption for fieldset elements
<datalist>
It is used to specify pre-defined list options for input controls.
35
<optgroup> It is used to define group-related options in a drop-down list.
36
Input Type Description
37
<input type=”email“> Validates that the input is a valid email
address.
<input type=”number“> Allows the user to enter a number. You can specify
min, max, and step attributes for range.
<input type=”date“>
38
<input type=”file“> Allows the user to select a file to upload.
Example: This HTML forms collects the user personal information such as
username and password with the button to submit the form.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Html Forms</title>
</head>
<body>
<h2>HTML Forms</h2>
<form>
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"><br><br>
Features:
39
HTML Coding Practices :
1. Use Proper Document Structure With Doctype
HTML has a nature that will still render your markup correctly even if you forget to mention some
elements such as <html>, <head>, <body>, and <!DOCTYPE html>. You will see the correct
result in your browser as you want but that doesn’t mean you will find the same result in every
browser. To avoid this issue it’s a good habit to follow a proper document structure with the correct
doctype. Doctype is the first thing to mention in an HTML document. You can choose the right
doctype from the importance of doctype.
Example:
HTML
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Welcome Programmers</h1>
</body>
</html>
40
<div> Missing close div -->
41
<p style="color: #393; font-size: 24px;">Thank you!</p>
42
HTML
<h1>Topmost heading</h1>
<h2>Sub-heading underneath the topmost heading.</h2>
<h3>Sub-heading underneath the h2 heading.</h3>
XML stands for Extensible Markup Language and is a text-based markup language derived
from Standard Generalized Markup Language (SGML).
XML is a software- and hardware-independent tool for storing and transporting data.
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. XMLis 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, orlanguage, that
suits your application.
XML carries the data, does not present it: XML allows you to store the datairrespective of how
it will be presented.
XML is a public standard: XML was developed by an organization called theWorld Wide
Web Consortium (W3C) and is available as an open standard.
44
1.9.1 XML Usage
● XML can work behind the scenes to simplify the creation of HTML documents for web sites.
● XML can be used to exchange 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
<?xml version="1.0"?>
<contact_info>
<name>Rajesh</name>
<company>TCS</company>
<phone>9333332354</phone>
</contact_info>
You can notice there are two kinds of information in the above example:
version="1.0" encoding="UTF-8"?>
Where version is the XML version and encoding specifies the character encoding usedin the
document.
● The XML declaration is case sensitive and must begin with "<?xml>" where"xml" is
45
written in lower-case.
● The XML declaration strictly needs to be the first statement in the XML document.
● An HTTP protocol can override the value of encoding that you put in the
XMLdeclaration.
An XML file is structured by several XML-elements, also called XML-nodes or XML- tags.
XML elements' names are enclosed by triangular brackets < > as shown below:
<element>...........</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.
<?xml version="1.0"?>
<contact_info>
<company>TCS</company>
<contact_info>
46
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>
<root>
<x>...</x>
<y>...</y>
</root>
Case sensitivity:
The names of XML-elements are case-sensitive. That means the name of the startand the end
elements need to be exactly in the same case.
<a href="[Link]
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:
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.
47
Figure 1.2 XML Rules
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 & where amp is the name. The name refers to a predefined string of text
and/or markup.
Character References: These contain references, such as A, 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 the 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 UnicodeUTF-8 or
UTF-16 files.
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:
48
not allowed character replacement-entity character description
An XML tree starts at a root element and branches from the root to child [Link] elements
<root>
<child>
<sub child>. ............ </sub child>
</child>
</root>
The terms parent, child, and sibling are used to describe the relationships between elements.
Parents have children. Children have parents. Siblings are children on the same level (brothers
and sisters).
XML Namespaces
Name Conflicts
52
In XML, element names are defined by the developer. This often results in a conflict when trying
to mix XML documents from different XML applications.
<table>
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
If these XML fragments were added together, there would be a name conflict. Both Contain a
<table> element, but the elements have different content and meaning.
A user or an XML application will not know how to handle these differences.
This XML carries information about an HTML table, and a piece of furniture:
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
In the example above, there will be no conflict because the two <table> elements have different
names.
When using prefixes in XML, a namespace for the prefix must be defined.
The namespace can be defined by an xmlns attribute in the start tag of an [Link]
53
namespace declaration has the following syntax. xmlns:prefix="URI".
<root>
<h:table xmlns:h="[Link]
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table xmlns:f="[Link]
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
The xmlns attribute in the first <table> element gives the h: prefix a qualified namespace. The
xmlns attribute in the second <table> element gives the f: prefix a qualified namespace.
When a namespace is defined for an element, all child elements with the same prefix are associated
with the same namespace.
XML Validator
● An XML document with correct syntax is called "Well Formed".The syntax rules were
● XML documents must have a root element XML elements must have a closing tag XML
Example 1:
<?xml version=”1.0”?>
54
<book>
<title>Java</Title>
<author>James</book>
<pirce>570
</author>
The above XML document is not a well formed document. Reasons given below... tags are not
matching <title> … </Title>
There is no proper nesting <author>….</book>
Tag doesn’t closed <price>
Example 2:
<?xml version=”1.0”?>
<book>
<title>Java</title>
<author>James</author>
<price>500</price>
</book>
A "well formed" XML document is not the same as a "valid" XML document.
"valid" XML document must be well formed. In addition, it must conform to a documenttype
definition.
There are two different document type definitions that can be used with XML:
<!DOCTYPE book[
55
<!ELEMENT book (title,author,price)>
<!ELEMENT title (#PCDATA)> <!ELEMENT
author(#PCDATA)> <!ELEMENT price
(#PCDATA)> ]>
!DOCTYPE book defines that the root element of the document is book
!ELEMENT book defines that the book element must contain the elements: "title, author,
price”
!ELEMENT title defines the title element to be of type "#PCDATA"
!ELEMENT author defines the author element to be of type "#PCDATA"
!ELEMENT price defines the price element to be of type "#PCDATA"Note: PCDATA:
Parsable Character Data, CDATA: Character Data. There are two types of DTDs:
2) External DTD.
1) Internal / Embedded DTD.
<student>
<id>543</id>
<name>Ravi</name>
<age>21</age>
<addr>Guntur</addr>
<email>nsr@[Link]</email>
<ph>9855555</ph>
<gender>male</gender>
</student>
2) External DTD.
In the above example we are using <!DOCTYPE student SYSTEM "[Link]">which is used
to provide “[Link]” code in our “[Link]” file.
If the above xml code follows the exact rules defined in DTD then we can concludethat our xml
document is a valid document. Otherwise it is an invalid document.
With a DTD, independent groups of people can agree to use a standard DTD for
interchanging data.
With a DTD, you can verify that the data you receive from the outside world is valid.
You can also use a DTD to verify your own data.
An XML Schema describes the structure of an XML document, just like a [Link] XML
document with correct syntax is called "Well Formed".
An XML document validated against an XML Schema is both "Well Formed" and"Valid".
XML Schema is commonly known as XML Schema Definition (XSD). It is used to describe and
validate the structure and the content of XML data. XML schema defines the elements, attributes
and data types. Schema element supports Namespaces. It is similar to a database schema that
describes the data in a database.
Syntax
You need to declare a schema in your XML document as follows:
<xs:schema>
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="price" type="xs:integer"/>
57
<xs:element name="edition" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Example:
“[Link]” as follows…
If the above xml code follows the exact rules defined in “[Link]” then we can conclude that
our xml document is a valid document. Otherwise it is an invalid document.
Lecture-8
The HTML DOM defines a standard way for accessing and manipulating HTML [Link]
presents an HTML document as a tree-structure.
The XML DOM defines a standard way for accessing and manipulating XML documents.
Itpresents an XML document as a tree-structure.
<button type="button"
onclick="[Link]('demo').innerHTML = 'Hello World!'">Click Me!
</button>
</body>
</html>
59
XML DOM is:
Programming Interface
The DOM models XML as a set of node objects. The nodes can be accessed withJavaScript or
other programming languages.
The programming interface to the DOM is defined by a set of standard properties and methods.
Properties are often referred to as something that is (i.e. nodename is "book"). Methods are often
referred to as something that is done (i.e. delete "book").
DOM Example:
<html>
<body>
<script>
function myfun()
{
var text, parser, xmlDoc;
text = "<bookstore><book>"
+"<title>Java</title>" +
"<author>James</author>" +
"<year>1991</year>" +
"<book>" +
"<title>DBMS</title>" +
"<author>Raghu</author>" +
"<year>1970</year>" +
60
"</book>"+
"</book></bookstore>";
[Link]("demo").innerHTML =
[Link]("year")[0].childNodes[0].nodeValue;
}
</script>
</body>
</html>
Output:
1991
Example Explained
1.9.7 SAX
SAX is a way of reading data from an XML document that is an alternative to the Document Object
Model’s mechanism (DOM). Whereas the DOM works on the document as a whole, creating the
whole abstract syntax tree of an XML document for the user’s convenience, SAX parsers work
on each element of the XML document sequentially, issuing parsing events while passing through
the input stream in a single pass. Unlike DOM, SAX does not have a formal specification.
It is a programming interface for processing XML files based on events. The DOM’s counterpart,
SAX, has a very different way of reading XML code. The Java implementation of SAX is regarded
as the de-facto standard. SAX processes documents state-independently, in contrast to DOM
which is used for state-dependent processing of XML documents.
Parsers are used to process XML documents. The parser examines the XML document, checks
for errors, and then validates it against a schema or DTD if it’s a validating parser. The next step
is determined by the parser in use. It may copy the data into a data structure native to the
computer language you’re using on occasion. It may also apply styling to the data or convert it
into a presentation format.
Apart from triggering certain events, the SAX parser does nothing with the data. It is up to the
SAX parser’s user to decide. The SAX events include (among others) as follows:
It is called a Simple API for XML Parsing. It is called a Document Object Model.
SAX Parser is slower than DOM Parser. DOM Parser is faster than SAX Parser.
Best for the larger sizes of files. Best for the smaller size of files.
It is suitable for making XML files in Java. It is not good at making XML files in low memory.
The internal structure can not be The internal structure can be created by DOM Parser.
created by SAX Parser.
In the SAX parser backward In DOM parser backward and forward search is
navigation is not possible. possible
62
Unit -1 Important & Previous year Questions
[Link] Protocol. Provide the name of protocols governing the web.
[Link] is a web project? Explain web development strategies. Also explain Web Team?
[Link] is the client server relationship? How is it implemented? How is the client server paradigm
different from peer to peer paradigm?
4. Differentiate between the Internet and WWW? What are the different services provided by the
Internet?
5. Create an HTML code to create a web page that contains the user registration form with
following details: user name, user date of birth, user address, user gender, user email id, user
mobile number.
[Link] do you understand about hyperlinks in HTML? Write mark-up for an image hyperlink
[Link] HTML code to design “a form for online Railway Reservation Website” (Make
Assumptions). OR Write the HTML code to design a Student registration form. (Assume fields).
10. Discuss a frame and its advantages. Design HTML document that divides the browser screen
into two frames. The frame on the left will be a menu consisting of hyperlinks. Clicking on any one
of these links will lead to a new page open in the target frame on right hand side. Differentiate
between HTML and XML
11. Explain <iframe> and frameset. Explain the anchor and table tag in HTML?
[Link] an example of XML DTD. What are the rules for writing DTD? Explain with the help of an
example of a book catalog details. What is DTD? Discuss its differences with XML Schema.
[Link] suitable XML markup to display the data of books with title, author, publisher and price.
Explain well formed and valid xml? Differentiate between SAX and DOM parsers in detail.
63
Practice Questions
1. What will be output of the following code.
<!DOCTYPE html>
<html>
<style>
table, th, td {
border:1px solid black;
}
</style>
<body>
<table style="width:100%">
<tr>
<th>Person 1</th>
<th>Person 2</th>
<th>Person 3</th>
</tr>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
<p>To understand the example better, we have added borders to the table.</p>
</body>
</html>
[Link] will be output of the following code
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
64
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th>Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>555-1234</td>
</tr>
<tr>
<td>555-8745</td>
</tr>
</table>
</body>
</html>
[Link] will be output of the following code.
<!DOCTYPE html>
<html>
<head>
<title>table</title>
<style>
table{
border-collapse: collapse;
width: 100%;
}
th,td{
border: 2px solid green;
padding: 15px;
}
</style>
</head>
<body>
<table>
<tr>
<th>1 header</th>
<th>1 header</th>
<th>1 header</th>
</tr>
65
<tr>
<td>1data</td>
<td>1data</td>
<td>1data</td>
</tr>
<tr>
<td>2 data</td>
<td>2 data</td>
<td>2 data</td>
</tr>
<tr>
<td>3 data</td>
<td>3 data</td>
<td>3 data</td>
</tr>
</table>
</body>
</html>
66