NOTES

PW NOTES



Unit1 Fundamentals
1.1 A Brief Intro to the Internet
n Internet History
n Internet Protocols
Internet History
1.1.1 Origins
In the 1960s the U.S Department of Defense (DoD) became interested in
developing a new large-scale computer network.
The purposes of this network were communications, program
sharing and remote computer access. One fundamental requirement was
that the network be sufficiently Robust so that even if some network nodes
were lost due to damage or some more reason the network could continue
to function.
The DoD’s Advanced Research Projects Agency (ARPA) funded the
construction of the first such network, and the network the first such
network, and the network was named as ARPAnet in 1969.
The primary use of ARPAnet was simple text-based
communications through e-mail.
A number of other networks were developed during the late 1970’s
and early 1980’s with BITNET and CSNETT among them.
BITNET, which is an acronym for Because It’s Time Network,
developed at City University of NewYork. It was built initially to provide
electronic mail and file transfers CSNET, which is an acronym for
Computer Science Network, connected the university of Delware, Purdue

DEPT. OF CSE, GNDECPage 5
University, RAND corporation and many more universities with initial
purpose was to provide Electronic mail.
For the variety of reasons, neither BITNET not CSNET became a
dominant national network.
A new national network, NSFnet was created in 1986. It was funded
by National Science Foundation (NSF). NSFnet initially connected NSF
supercomputer centers.
By 1990, NSFnet had replaced ARPAnet for most nonmilitary uses.
By 1992 NSFnet connected more than 1 million computers around the
world.
In 1995 a small part of NSFnet returned to being a research network.
The rest is known as the Internet.
As a Summary:
• ARPAnet - late 1960s and early 1970s
• Network reliability
• For ARPA-funded research organizations
• BITnet, CSnet - late 1970s & early 1980s
• email and file transfer for other institutions
• NSFnet - 1986
• Originally for non-DOD funded places
• Initially connected five supercomputer centers
• By 1990, it had replaced ARPAnet for non-military uses
• Soon became the network for all (by the early 1990s)
• NSFnet eventually became known as the Internet
1.1.2 What the Internet is:
• Internet is a huge collection of computers connected in a
communications network.
• It is a network of network rather than a network of computers.
• Using Internet many people can share resources and can communicate
with each other.
• To have Internet service your computer must be connected to the
Internet Service Providers (ISP) through cables modem, phone-line
modem or DSL.
• The Internet employs a set of standardized protocols which allow for the
sharing of resources. These standars are known by the Internet Protocol
Suite.
• At the lowest level, since 1982, all connections use TCP/IP
1.1.3 Internet Protocols (IP) Addresses
n Internet Protocol (IP) Addresses

DEPT. OF CSE, GNDECPage 6
q Every node has a unique numeric address
q Form: 32-bit binary number
n IP address is divided into 2 main part:
q Network number and
q Host number
n IP addresses usually are written as four 8-bit numbers separated by dots
NETWORK NUMBER HOST NUMBER
n Organizations are assigned groups of IPs for their computers
n The are 5 classes of IP address
Sl.no. IP address Class Format Pupose
1. Class A N.H.H.H Few large
organization use this
class addressing
2. Class B N.N.H.H Medium size
organizations use
this addressing
3. Class C N.N.N.H Relatively small
organizations use
this class
Here N stands for Network number and H stands for Host number. For example, a
small organization may be assigned 256 IP addresses, such as 191.28.121.0 to
191.28.121.255
n Problem: By the mid-1980s, several different protocols had been invented and
were being used on the Internet, all with different user interfaces (Telnet, FTP,
Usenet, mailto
1.1.4 Domain names
· Form: host-name.domain-names
· First domain is the smallest; last is the largest
· Last domain specifies the type of organization
· Fully qualified domain name - the host name and all of the domain names
· DNS servers - convert fully qualified domain names to IPs
· Few domains are:
o Edu –Extension for Educational institutions
o Com – Specifies a Company
o Gov – Specifies government
o Org – Other kind of organization
· Even Domain specifies the country name
o in – India
o pk – Pakistan

DEPT. OF CSE, GNDECPage 7
o au – Australia
o us – United states
Domain Name Conversion
IP addresses are the address used internally by the Internet, the fully qualified domain
name of the destination for a message, which is given browser, must be converted to an
IP address before the message can be transmitted on the internet to the destination. These
conversions are done by system software called Name Servers.
Name Servers server a collection of machines on the Internet and are operated by
organizations that are responsible for the part of the Internet to which those machines are
connected.
All documents requested from the browsers are routed to the nearest name server.
If the name server can convert the fully qualified domain name to an IP address. If it
cannot , the name server sends the fully qualified domain name to another name server
for conversion.
The figure 1 shows how fully qualified domain names requested by a browser are
translated into IPs before they are routed to the appropriate web server.
One way to determine the IP address of the website by using telnet.
If we want to know the IP address of www. Google.co.in, go to Dos prompt and
type telnet www.google.co.in
PROTOCOLS
Internet
Name
Server
Internet Web
Server
Domain Name
Domain Name
IP IP
Client System
Fig. Domain Name
Conversion

DEPT. OF CSE, GNDECPage 8
By the mid – 198s, a collection of different protocols that run on top of TCP/IP had been
developed to support a variety of Internet users. Among those the most common were
telnet, ftp, usenet, mailto
Uses:
· telnet – which was developed to allow a user on one computer on the Internet to
log on to and use another computer on the Internet.[Remote Login]
· ftp[file transfer protocol] - which was developed to transfer file among computers
on the Internet.
· usenet – Which was developed to serve as an electronic bulletin board.
· mailto – which was developed to allow messages to be sent from the user of one
computer on the Internet to other users on other computer on the Internet.
Client and Server
n Clients and Servers are programs that communicate with each other over the
Internet
n A Server runs continuously, waiting to be contacted by a Client
q Each Server provides certain services
q Services include providing web pages
n A Client will send a message to a Server requesting the service provided by that
server
q The client will usually provide some information, parameters, with the
request
1.2 The World-Wide Web
n A possible solution to the proliferation of different protocols being used on the
Internet
1.2.1 Origins
q Tim Berners-Lee at CERN proposed the Web in 1989
n Purpose: to allow scientists to have access to many databases of
scientific work through their own computers
q Document form: hypertext
q Pages? Documents? Resources?
n We’ll call them documents
q Hypermedia – more than just text – images, sound, etc.
1.2.2 Web or Internet?
q The Web uses one of the protocols, http, that runs on the Internet--there
are several others (telnet, mailto, etc.)
n The Internet is a massive network of networks, a networking infrastructure. It
connects millions of computers together globally, forming a network in which any
computer can communicate with any other computer as long as they are both

DEPT. OF CSE, GNDECPage 9
connected to the Internet. Information that travels over the Internet does so via a
variety of languages known as protocols.
n The World Wide Web, or simply Web, is a way of accessing information over the
medium of the Internet. The Web uses the HTTP protocol The Web also utilizes
browsers, such as Internet Explorer or Firefox, to access Web documents called
Web pages that are linked to each other via hyperlinks. Web documents also
contain graphics, sounds, text and video.
n The Internet is the large container, and the Web is a part within the container.
n But to be technically precise, the Net is the restaurant, and the Web is the most
popular dish on the menu.
n Browsers are used to connect to the www part of the internet.
Here is a conceptual diagram of the Internet and how it contains many forms of online
communications
The Internet and the Web work together, but they are not the same thing. The Internet
provides the underlying structure, and the Web utilizes that structure to offer content,
documents, multimedia, etc.
The Internet is at its most basic definition an electronic communications network. It is the
structure on which the World Wide Web is based.
1.3 Web Browsers
n Browsers are clients - always initiate, servers react (although sometimes servers
require responses)
n Mosaic - NCSA (Univ. of Illinois), in early 1993
q First to use a GUI, led to explosion of Web use
q Initially for X-Windows, under UNIX, but was ported to other platforms
by late 1993
n Most requests are for existing documents, using HyperText Transfer Protocol
(HTTP)
q But some requests are for program execution, with the output being
returned as a document

DEPT. OF CSE, GNDECPage 10
1.4 Web Servers
n Provide responses to browser requests, either existing documents or dynamically
built documents
n All communications between browsers and servers use Hypertext Transfer
Protocol (HTTP)
n Apache, Microsoft internet information server (IIS)
1.4.1 Web Server Operation
Web servers run as background processes in the operating system
Monitor a communications port on the host, accepting HTTP messages
when they appear
All current Web servers came from either
1. The original from CERN
2. The second one, from NCSA
1.4.2 Web Server Operation Details
Web servers have two main directories:
1. Document root (servable documents)
2. Server root (server system software)
Document root is accessed indirectly by clients
Its actual location is set by the server configuration file
Requests are mapped to the actual location
Path /admin/web/topdocs/xyz.html
Server root – stores server and its support software
Virtual document trees : many servers allow part of the servable document
collection to be stored outside the directory of document root. The secondary
areas from which document can be served are called virtual document trees.
Proxy servers : Some servers can serve documents that are in the document root
of other machines on the web and those servers are called proxy servers.
Difference between apache and IIS
Apache Web Server IIS web Server
1. It is an open source
product.
2. Apache web server
is useful on both
UNIX based
systems and on
windows platform.
3. The apache web
server can be
1. It is a vendorspecific product and
can be used on windows only.
2. IIS web server is used on
windows platform.
3. The IIS server can be controlled
by modifying the window based
management programs called IIS
span-in.
We can access 115 span-in by

DEPT. OF CSE, GNDECPage 11
controlled by
editing the
configuration file
http.conf
going to control panel à
Administrative tools à IIS
admin
1.5 URLs (uniform resource locators)
1.5.1 General form:
scheme: object-address
q The scheme is often a communications protocol, such as telnet or ftp
n For the http protocol, the object-address is: fully qualified domain name/doc path
n For the file protocol, only the doc path is needed
n Host name may include a port number
n URLs cannot include spaces or any of a collection of other special characters
(semicolons, colons, ...)
n The doc path may be abbreviated as a partial path
q The rest is furnished by the server configuration
n If the doc path ends with a slash, it means it is a directory
1.6 Multipurpose Internet Mail Extensions (MIME)
n Originally developed for email
n Used to specify the form of a file returned by the server
n Type specifications
q Form:
type/subtype
q Examples: text/plain, text/html, image/gif, image/jpeg, video/mpeg,
video/rm, video/quicktime
Browser gets the type explicitly from the server
1.7 The HyperText Transfer Protocol
n The protocol used by ALL Web communications
n Current version of HTTP is 1.1
n Consists of 2 phases à request phase
à response phase
http communication[request or response] between a browser and a web server consists of
2 parts à header-consists information about communication and
à body – consists data of communication
1.7.1 Request Phase

DEPT. OF CSE, GNDECPage 12
q Form:
1. HTTP method domain part of URL HTTP ver.
2. Header fields
3. blank line semantics
4. Message body
1.7 The HyperText Transfer Protocol: Methods
n GET - Fetch a document
n POST - Execute the document, using the data in body
n HEAD - Fetch just the header of the document
n PUT - Store a new document on the server
n DELETE - Remove a document from the server
q An example of the first line of a request:
GET /degrees.html HTTP/1.1
n Format of second line header field (optional)
q Field name followed by a colon and the value of the field.
HTTP Headers
n Four categories of header fields:
General, request, response, & entity
n Common request fields:
Accept: text/plain
Accept: text/*
If-Modified_since: date
n Common response fields:
Content-length: 488
Content-type: text/html
- Can communicate with HTTP without a browser
Ø telnet blanca.uccs.edu http
Ø Creates connection to http port on …….. server
http command eg:
GET /respond.html HTTP/1.1
Host: blanca.uccs.edu
1.7.2 Response phase
n Form:
1. Status line
2. Response header fields
3. blank line
4. Response body
n Status line format:
HTTP version status code explanation
n Example: HTTP/1.1 200 OK
(Current version is 1.1)

DEPT. OF CSE, GNDECPage 13
n Status code is a three-digit number; first digit specifies the general status
1 => Informational
2 => Success
3 => Redirection
4 => Client error
5 => Server error
n The header field, Content-type, is required
HTTP Response Example
HTTP/1.1 200 OK
Date: Tues, 18 May 2004 16:45:13 GMT
Server: Apache (Red-Hat/Linux)
Last-modified: Tues, 18 May 2004 16:38:38 GMT
Etag: "841fb-4b-3d1a0179"
Accept-ranges: bytes
Content-length: 364
Connection: close
Content-type: text/html, charset=ISO-8859-1
Both request headers and response headers must be followed by a blank line
1.8 Note on security?
1.9 The Web Programmer’s Toolbox
n Document languages and programming languages that are the building blocks of
the web and web programming
n XHTML
n Plug-ins
n Filters
n XML
n Javascript
n Java, Perl, Ruby, PHP
1.9.1 XHTML
n To describe the general form and layout of documents
n An XHTML document is a mix of content and controls
q Controls are tags and their attributes
n Tags often delimit content and specify something about how the
content should be arranged in the document
n Attributes provide additional information about the content of a tag
1.9.2 Creating XHTML documents
n XHTML editors - make document creation easier
q Shortcuts to typing tag names, spell-checker,
n WYSIWYG XHTML editors
n Need not know XHTML to create XHTML documents
1.9.3 Plugins and Filters

DEPT. OF CSE, GNDECPage 14
n Plug ins
q Integrated into tools like word processors, effectively converting them to
WYSIWYG XHTML editors
n Filters
q Convert documents in other formats to XHTML
Plugins and Filters: Advantages and Disadvantages
n Advantages of both filters and plug-ins:
q Existing documents produced with other tools can be converted to
XHTML documents
q Use a tool you already know to produce XHTML
n Disadvantages of both filters and plug-ins:
q XHTML output of both is not perfect - must be fine tuned
q XHTML may be non-standard
q You have two versions of the document, which are difficult to synchronize
1.9.4 XML
n A meta-markup language
n Used to create a new markup language for a particular purpose or area
n Because the tags are designed for a specific area, they can be meaningful
n No presentation details
n A simple and universal way of representing data of any textual kind
1.9.5 JavaScript
n A client-side HTML-embedded scripting language
n Only related to Java through syntax
n Dynamically typed and not object-oriented
n Provides a way to access elements of HTML documents and dynamically change
them
1.9.6 Java
n General purpose object-oriented programming language
n Based on C++, but simpler and safer
n Our focus is on applets, servlets, and JSP
1.9.7 Perl
n Provides server-side computation for HTML documents, through CGI
n Perl is good for CGI programming because:
q Direct access to operating systems functions
q Powerful character string pattern-matching operations
q Access to database systems
n Perl is highly platform independent, and has been ported to all common platforms
n Perl is not just for CGI
1.9.8 PHP
n A server-side scripting language
n An alternative to CGI

DEPT. OF CSE, GNDECPage 15
n Similar to JavaScript
n Great for form processing and database access through the Web
1.10 Origins and Evolution of HTML
n HTML was defined with SGML
n Original intent of HTML: General layout of documents that could be displayed by
a wide variety of computers
n Recent versions:
q HTML 3.2 – 1997
n Introduced many new features and deprecated many older features
q HTML 4.01 - 1999 - A cleanup of 4.0
q XHTML 1.0 - 2000
n Just 4.01 defined using XML, instead of SGML
q XHTML 1.1 – 2001
n Modularized 1.0, and drops frames
n We’ll stick to 1.1, except for frames
n Reasons to use XHTML, rather than HTML:
1. HTML has lax syntax rules, leading to sloppy and sometime ambiguous
documents
– XHTML syntax is much more strict, leading to clean and clear
documents in a standard form
2. HTML processors do not even enforce the few syntax rule that do exist in
HTML
3. The syntactic correctness of XHTML documents can be validated
1.11 Basic Syntax
n Elements are defined by tags (markers)
q Tag format:
n Opening tag: <name>
n Closing tag: </name>
q The opening tag and its closing tag together specify a container for the
content they enclose
n Not all tags have content
q If a tag has no content, its form is <name />
n The container and its content together are called an element
n If a tag has attributes, they appear between its name and the right bracket of the
opening tag
n Comment form: <!- … ->
n Browsers ignore comments, unrecognizable tags, line breaks, multiple spaces, and
tabs
n Tags are suggestions to the browser, even if they are recognized by the browser

DEPT. OF CSE, GNDECPage 16
1.12 HTML Document Structure
n <html>, <head>, <title>, and <body> are required in every document
n Every XHTML document must begin with:
<?xml version = ″1.0″?>
<!DOCTYPE html PUBLIC ″-//w3c//DTD XHTML 1.1//EN″
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>
n The whole document must have <html> as its root
n html must have the xmlns attribute:
<html xmlns = ″http://www.w3.org/1999/xhtml″
n A document consists of a head and a body
n The <title> tag is used to give the document a title, which is normally displayed in
the browser’s window title bar (at the top of the display)
n Prior to XHTML 1.1, a document could have either a body or a frameset
1.13 Basic Text Markup
n Text is normally placed in paragraph elements
n Paragraph Elements
q The <p> tag breaks the current line and inserts a blank line - the new line
gets the beginning of the content of the paragraph
q The browser puts as many words of the paragraph’s content as will fit in
each line
<?xml version = ″1.0″?>
<!DOCTYPE html PUBLIC ″-//w3c//DTD XHTML 1.1//EN″
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>
<!-- greet.hmtl
A trivial document
-->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Our first document </title>
</head>
<body>
<p>
Greetings from your Webmaster!
</p>
</body>
</html>
n W3C HTML Validation Service
http://validator.w3.org/file-upload.html
n Line breaks
q The effect of the <br /> tag is the same as that of <p>, except for the blank
line

DEPT. OF CSE, GNDECPage 17
n No closing tag!
n Example of paragraphs and line breaks
On the plains of hesitation <p> bleach the
bones of countless millions </p> <br />
who, at the dawn of victory <br /> sat down
to wait, and waiting, died.
n Typical display of this text:
On the plains of hesitation
bleach the bones of countless millions
who, at the dawn of victory
sat down to wait, and waiting, died.
n Headings
q Six sizes, 1 - 6, specified with <h1> to <h6>
q 1, 2, and 3 use font sizes that are larger than the default font size
q 4 uses the default size
q 5 and 6 use smaller font sizes
<!-- headings.html
An example to illustrate headings
-->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Headings </title>
</head>
<body>
<h1> Aidan’s Airplanes (h1) </h1>
<h2> The best in used airplanes (h2) </h2>
<h3> "We’ve got them by the hangarful" (h3)
</h3>
<h4> We’re the guys to see for a good used
airplane (h4) </h4>
<h5> We offer great prices on great planes
(h5) </h5>
<h6> No returns, no guarantees, no refunds,
all sales are final (h6) </h6>
</body>
</html>

DEPT. OF CSE, GNDECPage 18
n Blockquotes
q Content of <blockquote>
q To set a block of text off from the normal flow and appearance of text
q Browsers often indent, and sometimes italicize
n Font Styles and Sizes (can be nested)
q Boldface - <b>
q Italics - <i>
q Larger - <big>
q Smaller - <small>
q Monospace - <tt>
The <big> sleet <big> in <big> <i> Crete
</i><br /> lies </big> completely </big>
in </big> the street
The sleet in Crete
lies completely in the street
n These tags are not affected if they appear in the content of a
<blockquote>, unless there is a conflict (e.g., italics)
q Superscripts and subscripts
n Subscripts with <sub>
n Superscripts with <sup>
Example: x<sub>2</sub><sup>3</sup>
Display: x23
n Inline versus block elements
n All of this font size and font style stuff can be done with style sheets, but these
tags are not yet deprecated
n Character Entities
Char. Entity Meaning
& &amp; Ampersand

DEPT. OF CSE, GNDECPage 19
< &lt; Less than
> &gt; Greater than
” &quot; Double quote
’ &apos; Single quote
¼ &frac14; One quarter
½ &frac12; One half
¾ &frac34; Three quarters
&deg; Degree
(space)&nbsp; Non-breaking space
n Horizontal rules
q <hr /> draws a line across the display, after a line break
n The meta element (for search engines) Used to provide additional
information about a document, with attributes, not content
Images
n GIF (Graphic Interchange Format)
q 8-bit color (256 different colors)
n JPEG (Joint Photographic Experts Group)
q 24-bit color (16 million different colors)
n Both use compression, but JPEG compression is better
n Images are inserted into a document with the <img /> tag with the src
attribute
q The alt attribute is required by XHTML
n Purposes:
1. Non-graphical browsers
2. Browsers with images turned off
<img src = "comets.jpg"
alt = "Picture of comets" />
n The <img> tag has 30 different attributes, including width and height (in
pixels)
n Portable Network Graphics (PNG)
q Relatively new
q Should eventually replace both gif and jpeg
Eg:
<!-- image.html
An example to illustrate an image
-->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Images </title>
</head>
<body>

DEPT. OF CSE, GNDECPage 20
<h1> Aidan's Airplanes </h1>
<h2> The best in used airplanes </h2>
<h3> "We've got them by the hangarful"
</h3>
<h2> Special of the month </h2>
<p>
1960 Cessna 210 <br />
577 hours since major engine overhaul
<br />
1022 hours since prop overhaul
<br /><br />
<img src = "c210new.jpg"
alt = "Picture of a Cessna 210"/>
<br />
Buy this fine airplane today at a
remarkably low price <br />
Call 999-555-1111 today!
</p>
</body>
</html>
2.2 Hypertext Links

DEPT. OF CSE, GNDECPage 21
Hypertext is the essence of the Web!
A link is specified with the href (hypertext reference) attribute of <a> (the
anchor tag)
The content of <a> is the visual link in the document
If the target is a whole document (not the one in which the link
appears), the target need not be specified in the target document as
being the target
Note: Relative addressing of targets is easier to maintain and more portable
than absolute addressing
<!-- link.html
An example to illustrate a link
-->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Links </title>
</head>
<body>
<h1> Aidan's Airplanes </h1>
<h2> The best in used airplanes </h2>
<h3> "We've got them by the hangarful"
</h3>
<h2> Special of the month </h2>
<p>
1960 Cessna 210 <br />
<a href = "C210data.html">
Information on the Cessna 210 </a>
</p>
</body>
</html>


DEPT. OF CSE, GNDECPage 22
If the target is not at the beginning of the document, the target spot must be
marked
Target labels can be defined in many different tags with the id attribute, as in
<h1 id = "baskets"> Baskets </h1>
The link to an id must be preceded by a pound sign (#); If the id is in the
same document, this target could be
<a href = "#baskets">
What about baskets? </a>
If the target is in a different document, the document reference must be
included
<a href = "myAd.html#baskets”> Baskets </a>
Style note: a link should blend in with the surrounding text, so reading it
without taking the link should not be made less pleasant
Links can have images:
<a href = "c210data.html“>
<img src = "smallplane.jpg"
alt = "Small picture of an airplane " />
Info on C210 </a>

DEPT. OF CSE, GNDECPage 23
UNIT – 2: XHTML – 2: CSS: XHTML (continued..)
Lists; Tables;
Forms; Frames;
CSS: Introduction; Levels of style sheets; Property value forms;
Style specification formats; Selector forms;
Font properties; List properties;
Color; Alignment of text;
The Box model; Background images; The and tags; Conflict resolution.
2.1 Lists
Unordered lists
The list is the content of the <ul> tag
List elements are the content of the <li> tag
<h3> Some Common Single-Engine Aircraft </h3>
<ul>
<li> Cessna Skyhawk </li>
<li> Beechcraft Bonanza </li>
<li> Piper Cherokee </li>
</ul>
Ordered lists
The list is the content of the <ol> tag
Each item in the display is preceded by a sequence value
<h3> Cessna 210 Engine Starting Instructions
</h3>
<ol>
<li> Set mixture to rich </li>

DEPT. OF CSE, GNDECPage 24
<li> Set propeller to high RPM </li>
<li> Set ignition switch to "BOTH" </li>
<li> Set auxiliary fuel pump switch to
"LOW PRIME" </li>
<li> When fuel pressure reaches 2 to 2.5
PSI, push starter button </li>
</ol>
n Definition lists (for glossaries, etc.)
q List is the content of the <dl> tag
q Terms being defined are the content of the <dt> tag
q The definitions themselves are the content of the <dd> tag
<h3> Single-Engine Cessna Airplanes </h3>
<dl >
<dt> 152 </dt>
<dd> Two-place trainer </dd>
<dt> 172 </dt>
<dd> Smaller four-place airplane </dd>
<dt> 182 </dt>
<dd> Larger four-place airplane </dd>
<dt> 210 </dt>
<dd> Six-place airplane - high performance
</dd>
</dl>

DEPT. OF CSE, GNDECPage 25
2.2 Tables
A table is a matrix of cells, each possibly having content
The cells can include almost any element
Some cells have row or column labels and some have data
A table is specified as the content of a <table> tag
A border attribute in the <table> tag specifies a border between the cells
If border is set to "border", the browser’s default width border is used
The border attribute can be set to a number, which will be the border width
Without the border attribute, the table will have no lines!
Tables are given titles with the <caption> tag, which can immediately follow
<table>
Each row of a table is specified as the content of a <tr> tag
The row headings are specified as the content of a <th> tag
The contents of a data cell is specified as the content of a <td> tag
<table border = "border">
<caption> Fruit Juice Drinks </caption>
<tr>
<th> </th>
<th> Apple </th>
<th> Orange </th>
<th> Screwdriver </th>
</tr>
<tr>
<th> Breakfast </th>
<td> 0 </td>

DEPT. OF CSE, GNDECPage 26
<td> 1 </td>
<td> 0 </td>
</tr>
<tr>
<th> Lunch </th>
<td> 1 </td>
<td> 0 </td>
<td> 0 </td>
</tr>
</table>
n A table can have two levels of column labels
q If so, the colspan attribute must be set in the <th> tag to specify that the
label must span some number of columns
<tr>
<th colspan = "3"> Fruit Juice Drinks </th>
</tr>
<tr>
<th> Orange </th>
<th> Apple </th>
<th> Screwdriver </th>
</tr>
If the rows have labels and there is a spanning column label, the upper left corner
must be made larger, using rowspan
<table border = "border">
<tr>

DEPT. OF CSE, GNDECPage 27
<td rowspan = "2"> </td>
<th colspan = "3"> Fruit Juice Drinks
</th>
</tr>
<tr>
<th> Apple </th>
<th> Orange </th>
<th> Screwdriver </th>
</tr>
</table>
n The align attribute controls the horizontal placement of the contents in a table cell
q Values are left, right, and center (default)
q align is an attribute of <tr>, <th>, and <td> elements
n The valign attribute controls the vertical placement of the contents of a table cell
q Values are top, bottom, and center (default)
q valign is an attribute of <th> and <td> elements
à SHOW cell_align.html and display it
The cellspacing attribute of <table> is used to specify the distance between cells
in a table
n The cellpadding attribute of <table> is used to specify the spacing between the
content of a cell and the inner walls of the cell
<table cellspacing = "50">
<tr>
<td> Colorado is a state of …
</td>
<td> South Dakota is somewhat…
</td>
</tr>
</table>

DEPT. OF CSE, GNDECPage 28
- Table Sections
- Header, body, and footer, which are the elements: thead, tbody, and tfoot
- If a document has multiple tbody elements, they are separated by thicker
horizontal lines
2.3 Forms
n A form is the usual way information is gotten from a browser to a server
n HTML has tags to create a collection of objects that implement this information
gathering
q The objects are called widgets (e.g., radio buttons and checkboxes)
n When the Submit button of a form is clicked, the form’s values are sent to the
server
n All of the widgets, or components of a form are defined in the content of a
<form> tag
q The only required attribute of <form> is action, which specifies the URL
of the application that is to be called when the Submit button is clicked
action =
"http://www.cs.ucp.edu/cgi-bin/survey.pl"
n If the form has no action, the value of action is the empty string
n The method attribute of <form> specifies one of the two possible techniques of
transferring the form data to the server, get and post
n get and post are discussed in Chapter 10
n Widgets
n Many are created with the <input> tag
n The type attribute of <input> specifies the kind of widget being
created
n Text

DEPT. OF CSE, GNDECPage 29
n Creates a horizontal box for text input
n Default size is 20; it can be changed with the size attribute
n If more characters are entered than will fit, the box is
scrolled (shifted) left
q If you don’t want to allow the user to type more characters than will fit, set
maxlength, which causes excess input to be ignored
<input type = "text" name = "Phone"
size = "12" >
2. Checkboxes - to collect multiple choice input
q Every checkbox requires a value attribute, which is the widget’s value in
the form data when the checkbox is ‘checked’
n A checkbox that is not ‘checked’ contributes no value to the form
data
q By default, no checkbox is initially ‘checked’
q To initialize a checkbox to ‘checked’, the checked attribute must be set to
"checked"
q Widgets (continued)
Grocery Checklist
<form action = "">
<p>
<input type = "checkbox" name ="groceries"
value = "milk" checked = "checked">
Milk
<input type = "checkbox" name ="groceries"
value = "bread">
Bread
<input type = "checkbox" name = "groceries"
value= "eggs">
Eggs
</p>
</form>
3. Radio Buttons - collections of checkboxes in which only one button can be ‘checked’
at a time
n Every button in a radio button group MUST have the same name

DEPT. OF CSE, GNDECPage 30
n Widgets (continued)
3. Radio Buttons (continued)
q If no button in a radio button group is ‘pressed’, the browser often
‘presses’ the first one
Age Category
<form action = "">
<p>
<input type = "radio" name = "age"
value = "under20" checked = "checked"> 0-19
<input type = "radio" name = "age"
value = "20-35"> 20-35
<input type = "radio" name = "age"
value = "36-50"> 36-50
<input type = "radio" name = "age"
value = "over50"> Over 50
</p>
</form>
4. Menus - created with <select> tags
n There are two kinds of menus, those that behave like checkboxes and those that
behave like radio buttons (the default)
q Menus that behave like checkboxes are specified by including the multiple
attribute, which must be set to "multiple"
n The name attribute of <select> is required
n The size attribute of <select> can be included to specify the number of menu
items to be displayed (the default is 1)
q If size is set to > 1 or if multiple is specified, the menu is displayed as a
pop-up menu
Menus (continued)
q Each item of a menu is specified with an <option> tag, whose pure text
content (no tags) is the value of the item
q An <option> tag can include the selected attribute, which when assigned
"selected” specifies that the item is preselected
Grocery Menu - milk, bread, eggs, cheese
<form action = "">
<p>

DEPT. OF CSE, GNDECPage 31
With size = 1 (the default)
<select name = "groceries">
<option> milk </option>
<option> bread </option>
<option> eggs </option>
<option> cheese </option>
</select>
</p>
</form>
- Widgets (continued)
5. Text areas - created with <textarea>
q Usually include the rows and cols attributes to specify the size of the text
area
q Default text can be included as the content of <textarea>
q Scrolling is implicit if the area is overfilled
Please provide your employment aspirations
<form action = "">
- Widgets (continued)
n After clicking the menu:
n After changing size to 2:

DEPT. OF CSE, GNDECPage 32
<p>
<textarea name = "aspirations" rows = "3”
cols = "40">
(Be brief and concise)
</textarea>
</p>
</form>
n Widgets (continued)
6. Reset and Submit buttons
q Both are created with <input>
<input type = "reset" value = "Reset Form">
<input type = "submit” value = "Submit Form">
n Submit has two actions:
1. Encode the data of the form
2. Request that the server execute the server-resident program specified as
the value of the action attribute of <form>
3. A Submit button is required in every form
--> SHOW popcorn.html and display it
2.4 Frames
Frames are rectangular sections of the display window, each of which can display
a different document
Because frames are no longer part of XHTML, you cannot validate a document
that includes frames
The <frameset> tag specifies the number of frames and their layout in the window
<frameset> takes the place of <body>
Cannot have both!
<frameset> must have either a rows attribute or a cols attribute, or both
(usually the case)
Default is 1
The possible values for rows and cols are numbers, percentages, and
asterisks
A number value specifies the row height in pixels - Not terribly
useful!

DEPT. OF CSE, GNDECPage 33
A percentage specifies the percentage of total window height for
the row - Very useful!
q An asterisk after some other specification gives the remainder of the
height of the window
q Examples:
<frameset rows = "150, 200, 300">
<frameset rows = "25%, 50%, 25%">
<frameset rows = "50%, 20%, *" >
<frameset rows = "50%, 25%, 25%"
cols = "40%, *">
n The <frame> tag specifies the content of a frame
n The first <frame> tag in a <frameset> specifies the content of the first frame, etc.
q Row-major order is used
q Frame content is specified with the src attribute
q Without a src attribute, the frame will be empty (such a frame CANNOT
be filled later)
n If <frameset> has fewer <frame> tags than frames, the extra frames are empty
n Scrollbars are implicitly included if needed (they are needed if the specified
document will not fit)
n If a name attribute is included, the content of the frame can be changed later (by
selection of a link in some other frame)
àSHOW frames.html
n Note: the Frameset standard must be specified in the DOCTYPE declaration
Eg:
<!-- contents.html
The contents of the first frame of
frames.html, which is the table of
contents for the second frame
-->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Table of Contents Frame
</title>
</head>
<body>
<h4> Fruits </h4>
<ul>
<li> <a href = "apples.html"

DEPT. OF CSE, GNDECPage 34
target = "descriptions">
apples </a>
<li> <a href = "bananas.html"
target = "descriptions">
bananas </a>
<li> <a href = "oranges.html"
target = "descriptions">
oranges </a>
</ul>
</body>
</html>
n Nested frames - to divide the screen in more interesting ways
à SHOW nested_frames.html
2.5 Introduction
n The CSS1 specification was developed in 1996
n CSS2 was released in 1998
n CSS3 is on its way
n CSSs provide the means to control and change presentation of HTML documents
n CSS is not technically HTML, but can be embedded in HTML documents
n Style sheets allow you to impose a standard style on a whole document, or even a
whole collection of documents
n Style is specified for a tag by the values of its properties
2.6 Levels of Style Sheets
n There are three levels of style sheets
• Inline - specified for a specific occurrence of a tag and apply only to that
tag
– This is fine-grain style, which defeats the purpose of style sheets -
uniform style
• Document-level style sheets - apply to the whole document in which they
appear
• External style sheets - can be applied to any number of documents
n When more than one style sheet applies to a specific tag in a document, the lowest
level style sheet has precedence
• In a sense, the browser searches for a style property spec, starting with
inline, until it finds one (or there isn’t one)
n Inline style sheets appear in the tag itself

DEPT. OF CSE, GNDECPage 35
n Document-level style sheets appear in the head of the document
n External style sheets are in separate files, potentially on any server on the Internet
q Written as text files with the MIME type text/css
2.7 Linking an External Stylesheet
n A <link> tag is used to specify that the browser is to fetch and use an external
style sheet file
<link rel = "stylesheet" type = "text/css"
href = "http://www.wherever.org/termpaper.css">
</link>
- External style sheets can be validated
http://jigsaw.w3.org/css-validator/
validator-upload.html
2.8 Style Specification Formats
n Format depends on the level of the style sheet
n Inline:
q Style sheet appears as the value of the style attribute
q General form:
style = "property_1: value_1;
property_2: value_2;
property_n: value_n"
2.9 Format for Document-level
n Style sheet appears as a list of rules that are the content of a <style> tag
n The <style> tag must include the type attribute, set to "text/css"
n The list of rules must be placed in an HTML comment, because it is not HTML
n Comments in the rule list must have a different form - use C comments (/*…*/)
2.10 General Form, Document Level
n General form:
<style type = "text/css">
<!--
rule list
-->
</style>
n Form of the rules:
selector {list of property/values}
q Each property/value pair has the form:
property: value
q Pairs are separated by semicolons, just as in the value of a <style> tag
General Form, External style sheets

DEPT. OF CSE, GNDECPage 36
n Form is a list of style rules, as in the content of a <style> tag for document-level
style sheets
Selector Forms: Simple
The selector is a tag name or a list of tag names, separated by commas
h1, h3
p
Contextual selectors
ol ol li
Class Selectors
• Used to allow different occurrences of the same tag to use different style
specifications
• A style class has a name, which is attached to a tag name
q p.narrow {property/value list}
q p.wide {property/value list}
The class you want on a particular occurrence of a tag is specified with the class
attribute of the tag
• For example,
<p class = "narrow">
...
</p>
...
<p class = "wide">
...
</p>
Generic Selectors
A generic class can be defined if you want a style to apply to more than one kind
of tag
A generic class must be named, and the name must begin with a period
n Example,
.really-big { … }
n Use it as if it were a normal style class
<h1 class = "really-big"> … </h1>
...
<p class = "really-big"> … </p>
id Selectors
n An id selector allow the application of a style to one specific element
n General form:
#specific-id {property-value list}
n Example:
#section14 {font-size: 20}

DEPT. OF CSE, GNDECPage 37
Pseudo Classes
n Pseudo classes are styles that apply when something happens, rather than because
the target element simply exists
n Names begin with colons
n hover classes apply when the mouse cursor is over the element
n focus classes apply when an element has focus
Pseudo Class Example
<!-- pseudo.html -->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head> <title> Checkboxes </title>
<style type = "text/css">
input:hover {color: red;}
input:focus {color: green;}
</style>
</head>
<body>
<form action = "">
<p>
Your name:
<input type = "text" />
</p>
</form>
</body>
</html>
Properties
n There are 60 different properties in 7 categories:
q Fonts
q Lists
q Alignment of text
q Margins
q Colors
q Backgrounds
q Borders
Property Values
n Keywords - left, small, …
q Not case sensitive
n Length - numbers, maybe with decimal points

DEPT. OF CSE, GNDECPage 38
n Units:
q px - pixels
q in - inches
q cm - centimeters
q mm - millimeters
q pt - points
q pc - picas (12 points)
q em - height of the letter ‘m’
q ex-height - height of the letter ‘x’
q No space is allowed between the number and the unit specification e.g.,
1.5 in is illegal!
n Percentage - just a number followed immediately by a percent sign
n URL values
q url(protocol://server/pathname)
n Colors
q Color name
q rgb(n1, n2, n3)
n Numbers can be decimal or percentages
q Hex form: #XXXXXX
n Property values are inherited by all nested tags, unless overridden
Font Properties
n font-family
q Value is a list of font names - browser uses the first in the list it has
q font-family: Arial, Helvetica, Courier
q Generic fonts: serif, sans-serif, cursive, fantasy, and monospace (defined
in CSS)
n Browser has a specific font for each
q If a font name has more than one word, it should be single-quoted
n font-size
q Possible values: a length number or a name, such as smaller, xx-large, etc.
n font-style
q italic, oblique (useless), normal
n font-weight - degrees of boldness
q bolder, lighter, bold, normal
n Could specify as a multiple of 100 (100 – 900)
n font
q For specifying a list of font properties
font: bolder 14pt Arial Helvetica
q Order must be: style, weight, size, name(s)
n > SHOW fonts.html and display

DEPT. OF CSE, GNDECPage 39
n > SHOW fonts2.html and display
n The text-decoration property
q line-through, overline, underline, none
q letter-spacing – value is any length property value
List properties
n list-style-type
n Unordered lists
q Bullet can be a disc (default), a square, or a circle
q Set it on either the <ul> or <li> tag
n On <ul>, it applies to list items
<h3> Some Common Single-Engine Aircraft </h3>
<ul style = "list-style-type: square">
<li> Cessna Skyhawk </li>
<li> Beechcraft Bonanza </li>
<li> Piper Cherokee </li>
</ul>
n On <li>, list-style-type applies to just that item
<h3> Some Common Single-Engine Aircraft </h3>
<ul>
<li style = "list-style-type: disc">
Cessna Skyhawk </li>
<li style = "list-style-type: square">
Beechcraft Bonanza </li>
<li style = "list-style-type: circle">
Piper Cherokee </li>
</ul>
q Could use an image for the bullets in an unordered list

DEPT. OF CSE, GNDECPage 40
n Example:
<li style = "list-style-image:
url(bird.jpg)">
q On ordered lists - list-style-type can be used to change the sequence
values
Property valueSequence type First four
Decimal Arabic numerals 1, 2, 3, 4
upper-alpha Uc letters A, B, C, D
lower-alpha Lc letters a, b, c, d
upper-roman Uc Roman I, II, III, IV
lower-roman Lc Roman i, ii, iii, iv
à SHOW sequence_types.html and display
n CSS2 has more, like lower-greek and hebrew
Colors
n Color is a problem for the Web for two reasons:
1. Monitors vary widely
2. Browsers vary widely
- There are three color collections
1. There is a set of 16 colors that are guaranteed to be displayable by all
graphical browsers on all color monitors
black 000000 green 008000
silver C0C0C0 lime 00FF00
gray 808080 olive 808000
white FFFFFF yellow FFFF00
maroon 800000 navy 000080
red FF0000 blue 0000FF
purple 800080 teal 008080
fuchia FF00FF aqua 00FFFF
2. There is a much larger set, the Web Palette
q 216 colors
q Use hex color values of 00, 33, 66, 99, CC, and FF
q Inside back cover of this book has them!
3. Any one of 16 million different colors
___________________________________________
n The color property specifies the foreground color of elements
<style type = “text/css”>
th.red {color: red}
th.orange {color: orange}

DEPT. OF CSE, GNDECPage 41
</style>
<table border = "5">
<tr>
<th class = "red"> Apple </th>
<th class = "orange"> Orange </th>
<th class = "orange"> Screwdriver </th>
</tr>
</table>
n The background-color property specifies the background color of elements
à SHOW back_color.html and display
Alignment of Text
n The text-indent property allows indentation
q Takes either a length or a % value
n The text-align property has the possible values, left (the default), center, right, or
justify
n Sometimes we want text to flow around another element - the float property
q The float property has the possible values, left, right, and none (the
default)
q If we have an element we want on the right, with text flowing on its left,
we use the default text-align value (left) for the text and the right value for
float on the element we want on the right
<img src = "c210.jpg"
style = "float: right" />
q Some text with the default alignment - left

DEPT. OF CSE, GNDECPage 42
The Box Model
n Borders – every element has a border-style property
q Controls whether the element has a border and if so, the style of the border
q border-style values: none, dotted, dashed, and double
q border-width – thin, medium (default), thick, or a length value in pixels
q Border width can be specified for any of the four borders (e.g., border-topwidth)
q border-color – any color
q Border color can be specified for any of the four borders (e.g., border-topcolor)
à SHOW borders.html and display
n Margin – the space between the border of an element and its neighbor element
n The margins around an element can be set with margin-left, etc. - just assign them
a length value
<img src = "c210.jpg " style = "float: right;
margin-left: 0.35in;
margin-bottom: 0.35in" />

DEPT. OF CSE, GNDECPage 43
n Padding – the distance between the content of an element and its border
q Controlled by padding, padding-left, etc.
à SHOW marpads.html and display
Background Images
n The background-image property
à SHOW back_image.html and display
n Repetition can be controlled
q background-repeat property
q Possible values: repeat (default), no-repeat, repeat-x, or repeat-y
q background-position property
n Possible values: top, center, bottom, left, or right
The <span> and <div> tags
n One problem with the font properties is that they apply to whole elements, which
are often too large
q Solution: a new tag to define an element in the content of a larger element
- <span>
q The default meaning of <span> is to leave the content as it is
<p>
Now is the <span> best time </span> ever!
</p>
q Use <span> to apply a document style sheet to its content
<style type = "text/css">?
bigred {font-size: 24pt;
font-family: Ariel; color: red}
</style>
<p>
Now is the
<span class = "bigred">
best time </span> ever!
</p>

DEPT. OF CSE, GNDECPage 44
n The <span> tag is similar to other HTML tags, they can be nested and
n they have id and class attributes
n Another tag that is useful for style specifications: <div>
q Used to create document sections (or divisions) for which style can be
specified
n e.g., A section of five paragraphs for which you want some
particular style
Conflict Resolution
n When two or more rules apply to the same tag there are rules for deciding which
rule applies
n Document level
q In-line style sheets have precedence over document style sheets
q Document style sheets have precedence over external style sheets
n Within the same level there can be conflicts
q A tag may be used twice as a selector
q A tag may inherit a property and also be used as a selector
n Style sheets can have different sources
q The author of a document may specify styles
q The user, through browser settings, may specify styles
n Individual properties can be specified as important
Precedence Rules
n From highest to lowest
1. Important declarations with user origin
2. Important declarations with author origin
3. Normal declarations with author origin
4. Normal declarations with user origin
5. Any declarations with browser (or other user agent) origin
Tie-Breakers
n Specificity
1. id selectors
2. Class and pseudo-class selectors
3. Contextual selectors
4. General selectors
n Position

1. Essentially, later has precedence over earlier