Modern Web Programming Essentials
Modern Web Programming Essentials
S-Series
Covers
Complete HTML4.0,
HTML5, CSS3,
Guide of Java Script,
PHP, SQL,
Modern MySQL &
CMS System.
Author:
[Link]
2
C.S-Series Modern Web Programming
Web
Programming
Design Standards-Based Web Pages
Learn Modern Web Programming With Best
Practice
Deliver optimum client-side experience
My technical editor, James Pence, probably wondered when this project was
going to finish, and somehow he finished a nontechnical book of his own
during the project.
Finally, to my friends and family who tried to give me space to write this
thing, you deserve the biggest thanks. My Son Sadam Shahid and my wife
Ujala Shaheen, had to put up with a grouchy dad and far too many absent
weekends, so we now return you to our regularly scheduled weekends!
Cecilia, you provided a lot of help as well that made things a bit easier on all
of us, so thank you for that. I know you, more than anyone, appreciate the
importance of this project, considering the role HTML has played in our lives.
About the Technical Editor M. Kashif Lashari a full-time student.
As always, my greatest thanks go to Louise for knowing when to make me stop working. Our
daughter Holly was born during the writing of the first edition of this book, and our son Jake was
born this time round. The three of you make up my world.
Thanks to all at Sams who worked so hard to knock my code, prose, and time management into
shape. Particular thanks to Shelley Johnston, George Nedeff, and Steph Fox. Thanks and
apologies must also go to Megan Wade, who imposed order and coherence upon my writing. It
could not have been fun.
Writing often takes me away from other duties. I am fortunate in having such supportive friends
and colleagues at Corrosive. Max Guglielmino and Tolan Blundell weathered my prolonged
absence from the front line and filled the breach magnificently.
[Link]
4
C.S-Series Modern Web Programming
Shahid
Laashary
You can email or write me directly to let me know what you did or didn't like about this book—
as well as what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book, and
that due to the high volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to include this book's title and author as well as your name and
phone or fax number. I will carefully review your comments and share them with the author and
editors who worked on the book.
Email: webdev@[Link]
Mail: Mark Taber
Associate Publisher
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
[Link]
5
C.S-Series Modern Web Programming
books have been translating into Urdu language and are used around the
world both in industry and college settings. You can learn more about our
books and other creative projects at our Web site: [Link].
Copyright
Copyright © 2014 by C.S. Series. All rights reserved. Except as permitted
under the United States Copyright Act of 1976, no part of this publication
may be reproduced or distributed in any form or by any means, or stored in a
database or retrieval system, without the prior written permission of the
author or publisher. The material in this eBook also appears in the print
version of this title (Modern Web Programming)..
TERMS OF USE:
This is a copyrighted work and The C.S-Series and its licensors reserve all
rights in and to the work. Use of this work is subject to these terms. Except
as permitted under the Copyright Act of 1976 and the right to store and
retrieve one copy of the work, you may not decompile, disassemble, reverse
engineer, reproduce, modify, create derivative works based upon, transmit,
distribute, disseminate, sell, publish or sublicense the work or any part of it
without C.S-Series’s prior consent. You may use the work for your own
noncommercial and personal use; any other use of the work is strictly
prohibited. Your right to use the work may be terminated if you fail to comply
with these terms.
C.S-Series and its licensors do not warrant or guarantee that the functions
contained in the work will meet your requirements or that its operation will
[Link]
6
C.S-Series Modern Web Programming
be uninterrupted or error free. Neither C.S-Series nor its licensors shall be
liable to you or anyone else for any inaccuracy, error or omission, regardless
of cause, in the work or for any damages resulting there from. C.S-Series has
no responsibility for the content of any information accessed through the
work. Under no circumstances shall C.S-Series and/or its licensors be liable
for any indirect, incidental, special, punitive, consequential or similar
damages that result from the use of or inability to use the work, even if any
of them has been advised of the possibility of such damages. This limitation
of liability shall apply to any claim or cause whatsoever whether such claim
or cause arises in contract, tort or otherwise.
Part I contains Hours 1–3 and handles the information you will need to get your first script up
and running:
Hour 1, "PHP: From Home Page to Web Enterprise," describes the history and
capabilities of PHP and looks at some of the compelling reasons for deciding to learn this
scripting language.
Hour 2, "Installing PHP," explains how to install PHP on a Unix system and discusses
some of the configuration options you might want to choose when compiling PHP. In this
hour, we also examine ways of configuring PHP after it is installed.
Hour 3, "A First Script," covers the different ways in which you can embed a PHP script
in a document and create a script that writes text to the user's browser.
Part II comprises Hours 4–9. In this part, you will learn the basic components of the PHP
language:
[Link]
7
C.S-Series Modern Web Programming
Hour 4, "The Building Blocks," covers the basics of PHP. You will learn about variables,
data types, operators, and expressions.
Hour 5, "Going with the Flow," covers the syntax for controlling program flow in your
scripts. In addition to if and switch constructs, you will learn about loops using for and
while statements.
Hour 6, "Functions," explores the use of functions to organize your code.
Hour 7, "Arrays," discusses the array data type that can be used to hold list information.
We will also look at some of the functions PHP provides to manipulate arrays.
Hour 8, "Working with Strings," covers the functions you can use to manipulate strings.
Hour 9, "Objects," introduces PHP's support for classes and objects. Throughout the
course of the hour, we will develop a working example.
Part III consists of Hours 10–22. In this part, you will come to grips with the features and
techniques of the language:
Hour 10, "Working with Forms," introduces the dimension of user input through the
mechanism of the HTML form. You will learn how to gather data submitted via a form.
Hour 11, "Working with Files," shows you how to work with files and directories on the
local machine.
Hour 12, "Working with the DBA Functions," demonstrates PHP's support for DBM-
style database systems, versions of which are available on most systems.
Hour 13, "Database Integration—SQL," provides a brief introduction to SQL syntax and
introduces functions and classes for working with the MySQL database, the SQLite
library, and the PEAR::DB package.
Hour 14, "Beyond the Box," covers some of the details of HTTP requests and looks at
PHP network functions.
Hour 15, "Images On-the-Fly," explores PHP's image functions. With these, you can
create PNG files dynamically.
Hour 16, "Working with Dates and Times," covers the functions and techniques you can
use for date arithmetic. We create a calendar example.
Hour 17, "Advanced Objects," examines PHP's new extended support for objects and
object-oriented techniques.
Hour 18, "Working with Regular Expressions," introduces regular expression functions.
You can use these to find and replace complex patterns in strings.
Hour 19, "Saving State with Cookies and Query Strings," shows you some techniques for
passing information across scripts and requests.
Hour 20, "Saving State with Session Functions," extends the techniques explored in Hour
19, using PHP's built-in session functions.
Hour 21, "Working with the Server Environment," shows you how to call external
programs from your scripts and incorporate their output into your own.
Hour 22, "XML," looks at PHP's support for the Extensible Markup Language (XML).
We examine the XML Parser functions as well as more advanced topics such as DOM
and XSLT.
Part IV consists of Hours 23 and Hours 24. In these, we move beyond the core language to
examine the ways in which libraries can be used to extend PHP's functionality:
[Link]
8
C.S-Series Modern Web Programming
Hour 23, "PEAR: Reusable Components to Extend the Power of PHP," introduces the
PHP Extension and Application Repository. You learn how to install packages and work
with some examples.
Hour 24, "Towards a Framework for Larger Projects," builds up a code library of your
own. We explore some techniques that might be used in deploying a Front Controller
enterprise pattern. This example utilizes some of PHP's most advanced object-oriented
features.
Finally, we include a glossary that defines some of the more technical terms you might encounter
as you work through the book.
_________
Contents at a
Glance
Part 1: Introduction to Internet
1. Internet and World Wide Web -----------------------------------------
Part 4: JavaScript
[Link]
9
C.S-Series Modern Web Programming
1. Introduction to Java Script -----------------------------------------------
Part 5: PHP
1. Introduction to PHP --------------------------------------------------------
Part 6: SQL
1. Introduction to SQL -------------------------------------------------------
Part 7:MySQL
1. Introduction to My SQL -------------------------------------------------
[Link]
10
C.S-Series Modern Web Programming
Contents
Cover Page --------------------------------------------------------------------------------------------- 1
Acknowledgments ------------------------------------------------------------------------------------ 2
[Link]
11
C.S-Series Modern Web Programming
1.4.1 IP Addressing ---------------------------------------------------------------------------------
Email --------------------------------------------------------------------------------------- 25
VoIP ----------------------------------------------------------------------------------------
Commerce ---------------------------------------------------------------------------------
TELENET ----------------------------------------------------------------------------------
FTP ------------------------------------------------------------------------------------------
[Link]
12
C.S-Series Modern Web Programming
Microsoft Internet Explorer ------------------------------------------------------------------------
Web Directories---------------------------------------------------------------------------------------
Search Engines----------------------------------------------------------------------------------------
Types of Websites-----------------------------------------------------------------------------------
Multimedia on Web----------------------------------------------------------------------------------
Netiquette---------------------------------------------------------------------------------------------
Scripting Languages---------------------------------------------------------------------------------
Web Hosting------------------------------------------------------------------------------------------
Web Publishing
Cookies
Type of Cookies
Uses of Cookies
TCP/IP
Web 2.0
[Link]
13
C.S-Series Modern Web Programming
Web 3.0
HTML4.0
Benefits of HTML
Limitation of HTML
Headings
Paragraph
Line Breaks
Horizontal Line
Text Formatting
Fonts
Preformatted Text
Spaces
<DIV> Tag
<SPAN> Tag
<MARQUEE> Tag
HTML Comments
XML
XHTML
[Link]
14
C.S-Series Modern Web Programming
Flavors of XHTML 1.0
Lists
Ordered Lists
Unordered Lists
Definition Lists
Nested Lists
Images in HTML
Tables
Hyperlinks
Types of Hyperlinks
Email Hyperlinks
Images as Hyperlinks
Hyperlinks in Lists
Hyperlinks in Tables
Image Maps
[Link]
15
C.S-Series Modern Web Programming
Frames and Forms
Frames
Advantages of Frames
Disadvantages of Frames
Nested Frames
Forms
Uses of Forms
Form Elements
Text Field
Password Field
Radio Button
Checkbox Field
Selected Field
Button
Submit Button
Reset Button
Introduction to HTML5.0
HTML5
DHTML
Benefits of DHTML
Disadvantages of DHTML
[Link]
16
C.S-Series Modern Web Programming
Cascading Order
Special Effects
Text Effects
Text Layout
Lists
Background Colors
Background Images
Background Control
Parts of Border
CSS Class
Part 4: JavaScript
Introduction to Java Script
Scripts
[Link]
17
C.S-Series Modern Web Programming
Server Side Scripts
Client-Side Script
Java Script
Advantages of JavaScript
Uses of JavaScript
Running JavaScript
Data Types
Variables
Variable Declaration
Variable Initialization
Literals
Floating-Point Literals
Integer Literals
String Literals
Type Conversion
Expressions
Operators
Assignment Operators
Arithmetic Operator
Operator Precedence
Operator Associativity
Type Casting
Explicit Casting
Conditional Statements
[Link]
18
C.S-Series Modern Web Programming
Relational Operators
Relational Expression
If Statement
Logical Operators
Switch Statement
Conditional Operator
Loops
While loop
do-while loop
for loop
“continue” Statement
“break” Statement
Nested Loop
Functions
Function Declaration
Function Call
Returning Value
Local Variables
Global Variables
Built-in Functions
Dialog Boxes
Conversion Functions
[Link]
19
C.S-Series Modern Web Programming
Arrays
Array Declaration
Manipulating Arrays
Objects
Browser Objects
Arrays of Objects
Form Elements
Events
Event Handlers
Button Element
Text Element
Password Element
Checkbox Element
Form Validation
Advanced JavaScript
Date Object
Image Object
[Link]
20
C.S-Series Modern Web Programming
Window Object
History Object
String Object
Part 5: PHP
Part 6: SQL
Part 7: MySQL
Part 8: CMS System
1. Introduction to CMS System…………………………………
Part – 1
Introduction to Internet
[Link]
21
C.S-Series Modern Web Programming
Includes:
____________________________________________________
Chapter 1 Internet & World Wide Web
Internet:
Internet is a huge collection of computers all over the world that are
connected to one another. It is a global network of computers. These
computer are connected through different telecommunication lines like
Phone Line
Fiber optic lines
Satellites and wireless Connections
[Link]
22
C.S-Series Modern Web Programming
Uses of Internet:
Some uses of internet are as follows.
Working of Internet:
The internet is a collection of millions of computers. These computers are
linked together on a computer network. The network is used by the
computers to communicate with one another. A personal computer can be
connected to Internet by using phone lines, DSL, Fiber optic lines, Cell phone,
Satellite or Wireless connection and cable modem. These devices
communicate with the server of Internet service provider.
A user computer is usually connected with ISP using different resources. ISPs
are connected to larger ISPs. Several main transmission media carry the
heaviest amount of traffic on internet. These carriers of network traffic are
collectively called Internet backbone. Backbones are connected through fiber
optic lines, submarine cables or satellite links. In this way, every computer
on the Internet is connected to every other computer.
[Link]
23
C.S-Series Modern Web Programming
Flow of Information: Internet contains information on all types of
topics. People search information on any topic. Search engines are
used to search information on Internet. Easy access to information has
enabled people to be informed.
Better Understanding: Internet is an easy way of communication
among people. They can exchange their views. It has created better
understanding. People can understand the views and thinking of one
another. It helps in creating harmony and peace in the world.
Comfort in Life: The use of internet has provided many comforts for
society. People can perform their duties easily. They can sell and buy
goods online. They can run their business using Internet.
Knowledge: Internet is a source of huge information. People can get
information from websites. They can interact with different people,
scholars and learned persons to get knowledge.
History of Internet:
The work Internet was started in 1960s during Cold War of Russia and
America. America wanted to communicate with Armed Forces. A network of
four computers was developed in the beginning for this purpose.
ARPANET:
During Cold War, Russia launched Sputnik satellite and America developed a
network known as ARPANET. It was developed for Advanced Research Project
Agency (ARPA). ARPA worked on a project to send information to armed
forces at long distances. Different organizations and universities also
involved in this research.
Paul Baran:
In 1964, Paul Baran published a paper on Distributed Communication
Networks. It was a theoretical idea for data transfer. It included:
NCP Protocol:
Protocol is a collection of rules. In 1970s, NCP (Network Control Protocol)
was developed. It was the first standard protocol for data transfer.
[Link]
24
C.S-Series Modern Web Programming
DARPA:
DARPA stands for Defense Advanced Research Projects Agency. It was a new
name of ARPA. Now 37 computers were connected together. DARPA started
work to share data not only on single network but also among different
networks. Stanford Research Institute took part in this research.
TCP/IP:
A team of Stanford Research Institute developed a protocol called TCP/IP. It
stands for Transmission Control Protocol/ Internet Protocol. It was designed
to share and transfer data among different networks.
Internet:
Internet is now the largest network in the world. Millions of computers are
connected together through different medium. People can share information,
data. Any computer with a modem and telephone line can become a part of
the internet.
[Link]
25
C.S-Series Modern Web Programming
Modem: modem is an electronic device that is used to transfer data
over internet. It links the computer with the internet using telephone
line.
Dialup Software: dialup software is used to establish a connection
between personal computer and a server of an ISP.
ISP Connection: ISP stands for internet service provider. It provides
the link between the computer and the internet. A person has to get an
account of an ISP for establishing a connection to internet.
Web Browser: internet browser is software that is used to view web
page. Microsoft internet explorer, Google chrome, Mozilla Firefox and
Netscape Communicator are popular web browsers.
Addressing Scheme:
Internet addresses are used to access different computers on the internet.
Each computer on the internet has become a unique address. This address is
used to establish a connection with that computer. There are two types of
addressing schemes on the Internet.
IP Addressing:
IP addressing is a unique number that refers to a computer connected to the
Internet. IP stands for Internet Protocol. This address is a 32-bit number. It
consists of four numbers separated by period. Each number is between 0 and
255. These numbers are known as octets. An example of IP address is
[Link]. Normally, first number indicates a network and the last
number indicates a specific computer.
A server on the Internet has a static IP address. It does not change very
often. When a computer connects to the internet, it also gets an IP address
by the ISP. This IP address is used only during session and is not static.
[Link]
26
C.S-Series Modern Web Programming
DNS Addressing:
IP address is difficult to remember for the users. All servers on the internet
also have human-readable names. It is known as domain names. A domain
name consists of text instead of number. It is easier to remember a domain
name than IP address.
Host name
Domain
The domain represents the institution that uses the address. The domain
names are called top-level domains. Each domain name has a top-level
domain that indicates the type of organization associated with domain
name. The domain name outside United States also includes the country
code. The country code of Pakistan is pk e.g. [Link]
Domain (TLDs)
amazon aol
co ac
yaho
[Link]
27
C.S-Series Modern Web Programming
Domain Type
com Commercial organizations
edu Educational institutions
gov Government departments
mil Military organizations
net Network providers
org Non-profit organizations
museum Accredited museum
biz Business organizations
info Organizations or individuals providing general
information
name Individuals of families
pro Professional like doctors, engineers
aero Aviation community members
coop Cooperative societies and unions
A web page is a document that may include text, graphics, audio, video and software etc. these
web pages are connected to one another using hyperlinks. Web pages are also known as
hypertext documents. Anyone can view web pages through a web browser. A collection of
related web page is called web site. Each web site has a unique address. Web sites are stored on a
host computer on the internet. These computers are known as web server. The process of
launching a web page is called publishing the page.
[Link]
28
C.S-Series Modern Web Programming
Shopping: It is possible for user to buy an item using www. You can see products and prices,
and even order them by using your credit card etc.
Flight information: it is used to provide the latest information on flights arrivals and departures.
Television Station: www provides information about programs, the latest news and special
events. Some television show different event live on their websites.
Celebrities Sportsman and Film Actors: important celebrities can contact their fans, provide
information about them and send their pictures.
Government Authorities: government authorities can provide information about services and
facilities for the people.
News: most newspaper have their website. Latest news and interviews are provided on these
websites.
Encyclopedia Publisher: Online encyclopedias are available. You can find detailed information
on any topic in the world.
Search Engines: Search engine is a website that provides the facility to find required websites
on a particular topic. You can find thousands of websites about any topic.
Medical: many sites in the world provide detailed information on diseases. You can also consult
a panel of on-line doctors to get the advise about any medical problem.
Email:
Email stands for Electronic Mail. It is the exchange of messages and files through internet.
Message can be in the form of graphics, sounds, video clips or simple text. It is a fast way of
sending message anywhere in the world. The sender and receiver may be setting in the same
building or anywhere in the world. One email message can be send to multiple recipients. Email
facility is provided by many internet service provider or specialized websites. Yahoo, Hotmail
and Gmail are examples of popular email providing websites.
Working of Email:
An email program is used to create, send and receive emails. It is also known as email client.
When the user sends an email message, the computer connects to an email server and transmits a
copy of the message to that server.
Email server is host computer on the internet that is used to send and receive emails. The email
server receives the message and finds out the email server where that email is to be sent. It
connects to that server and transmits another copy of the message.
[Link]
29
C.S-Series Modern Web Programming
Email Attachment:
An email message can also contain attachment. Attachment is process of sending connecting
files with email message. Any type of file can be attached to email such as documents,
spreadsheets, audio and video etc.
MIME stands for Multipurpose Internet Mail Extension. It is an internet protocol that supports
email attachments. Different websites provide different file size that can be attached with an
email message.
Disadvantages of Email:
Some limitations of email are as follows:
Email does not provide high privacy. An email passes from one computer system to
another through different networks. The system administrator of a network or a hacker
can read the contents of emails.
Junk email is an unwanted email. It is also known as spam. A person may send such
email that the receiver does not want to read. A large number of junk emails may fill the
space of email account.
An email message cannot express emotions properly. The receiver cannot view the facial
expression or voice of the sender.
Email is read when the user connects to the internet and check email account. An urgent
message may be ignored or delayed.
Email may not be delivered successfully due to communication error.
Most of the viruses are spread through email messages. Virus can spread if the user opens
an email containing a virus.
Email Address:
Every email account has a unique address. An email address usually has two parts which are
separated by the symbol @. These parts are as follows:
[Link]
30
C.S-Series Modern Web Programming
User ID
Identity of email service
Example:
shahidlashari@[Link]
In this example shahidlashari is called user ID. It is used to sign into email service.
Social Networking:
Social networking is a way of publishing online communities. The people use social networking
websites to interact with one another. Myspace is an example of social networking sites.
Professionals also use social networking site such as Linkedln,
VoIP:
VoIP stands for voice over Internet Protocol. It is also called Internet telephony. It is used to
speak to other users over the internet. VoIP uses the internet instead of telephone network to
connect a user to other user. It requires high-speed internet connection like DSL.
Mailing List:
A mailing list is a collection of email names and addresses given a single name. an email
message sent to a mailing list is received by every person on the list. Different people discuss
different topic and distribute their ideas to other people by email. Softwares are available to
administrate mailing lists. The most common program is listserv.
News Groups:
A news group is a discussion group on the internet. People exchange information on a vast range
of topics such as news, business, science and computer. A user sends message to the news group
to participate in discussion. Other users in the news group read and reply to the message. A
software is required to obtain articles from news server. A news server is a host computer that
exchanges articles with other servers on the internet. These servers use Network News Transfer
Protocol (NNTP) to communicate. The users have to subscribe on a news group to view articles
on a specific topic.
E-Commerce:
[Link]
31
C.S-Series Modern Web Programming
E-Commerce stands for electronic commerce. E-Commerce means to carry
out financial and business dealings using internet. A person can deal with his
customers throughout the world. People can buy and sell goods on internet.
Even payments can be made using Credit Card numbers etc. The trend of E-
Commerce is rapidly becoming popular.
Role of e-commerce:
1. Online education:
Online education is becoming very popular. Different types of
interactive tutorials are available on the internet. The students can
browse these online books and tutorials or can download them after
purchasing. Some websites provide online lectures for the students.
2. Electronic banking:
Many banks are now introducing electronic banking. Using your
computer you connect to the bank’s computer system via the internet
and control your daily financial dealing from home. It reduces the staff
and building of banks. Many customers pay their bills from their bank
accounts using this facility.
3. Electronic Shopping:
It has become very easy for the people to shop from home using
internet. Different manufacturers present their products on the
internet. People can browse the website, place an order and even
make a payment using credit card. It has made shopping very easy.
4. Job Search:
Internet is used to search different types of jobs all over the world.
Many websites are the developed that provide information to the
people about job vacancies. Job seekers can also apply for the job
using internet.
5. Conducting Auction:
Many websites provide the facility of auction. People participate in the
auction to purchase a product. The can also pay the price using their
credit cards etc. a popular website that provides this facility is eBay.
6. Collaboration with Partners:
Businessmen can collaborate with their partners using internet. They
can discuss ideas, exchange views and make strategies in
collaboration with business partners in the world.
7. Marketing and Advertising:
[Link]
32
C.S-Series Modern Web Programming
E-Commerce is playing an important part to make and advertise
products all over the world. The use of popular websites can be
effective way of introducing a product to the customers.
8. Providing Customer Services:
Businessmen can interact with their customers using the internet. They
can discuss different issues about their products. The can also deal
with their complaints and provide different services to them.
9. Online Travel Reservation:
Online travel reservation is a popular use of e-commerce. People can
reserve seats in airline flights, hotels or car using the internet.
10. Online trading:
Online trading is a process of conducting business using the internet.
The stockbrokers can do all trading activities electronically. The can
submit and receive bids using computers. The can also interconnected
with computer display screens where brokers match the buyers with
sellers. It reduces the cost as no paper or special building is required to
conduct these activities.
Types of e-commerce:
1. Business-to-consumer:
2. Consumer to consumer
3. Business to business
[Link]
33
C.S-Series Modern Web Programming
advertisement, recruiting, sales, marketing, technical support and training
are some examples of B2B e-commerce. For example, some companies
provide online purchasing, tracking and transaction facilities to other
companies.
Advantages of e-commerce:
TELENET:
FTP:
Website
Home page
Hyper link
Image map
Frame
Table
HTTP
HTML
Webmaster
Domain name
URL
ISP
SMTP
[Link]
34
C.S-Series Modern Web Programming
DNS
Advantages of Internet
Information search
E-commerce
Online results
Online shopping
Fast communication
Discussion groups
Job search
Entertainment
Online education
Research
Advertisement
Video conferencing
Government authorities
News
Encyclopedia publisher
Search Engines
Medical
Disadvantages of Internet
Hacking
Immorality
Security problems
[Link]
35
C.S-Series Modern Web Programming
Viruses
Wastage of time
Cyber crime
Online education
Downloading software
Online results
Research
Online encyclopedia
Discussion groups
Information search
Online trading
Competitive advantage
Web Browser
Types of Browsers
Text-based Browsers
Graphical Browsers
Web Server
Web directories
[Link]
36
C.S-Series Modern Web Programming
Search Engines
AND
OR
NOT
Search by phrase
Types og websites
Portal
News
Information
Business/Marketing
Educational
Entertainment
Advocacy
Personal
Multimedia on web
Graphics
Animation
Audio
Video
Virtual reality
[Link]
37
C.S-Series Modern Web Programming
Plug-ins
Netiquette
HTML
Scripts
Applet
Servlet
ActivX Controls
Server Administrators:
HTML Coders:
Designers:
Software Programmers:
Database Administrator:
Marketers:
Scripting Languages:
Java
javaScripts
VB Scripts
PERL
DHTML
XML
[Link]
38
C.S-Series Modern Web Programming
XHTML
WML
Web Hosting
Shared Hosting
Dedicated Servers
Managed Hosting
Web publishing
Cookie
Example
Types of cookies
Uses of cookies
TCP/IP
Internet
Extranet
[Link]
39
C.S-Series Modern Web Programming
Web 2.0
Wiki
Social networking
Tagging
Collaboration tools
Web 3.0
Ampersand Sign or
& * Asterisk
Concatenation Sign
[Link]
40
C.S-Series Modern Web Programming
Introduction to HTML
HTML stands for Hyper Text Markup Language. It was developed in
early 1990s. it is a formatting language used to develop web pages.
Hypertext means that the HTML marks certain words in the document as
links to other parts of the same document or other document. When the user
clicks on a link, browser starts displaying the document attached to that link.
[Link]
41
C.S-Series Modern Web Programming
HTML is simpler than SGML. It was designed for use over the internet in
the form of web pages. HTML is more suited for this purpose. It is used to
design and create pages for different types of users for the web.
Benefits of HTML:
Some advantages of HTML are as follows:
Limitations of HTML:
Some limitations of HTML are as follows:
[Link]
42
C.S-Series Modern Web Programming
Static: HTML can only be used to create static web pages.
Fixed Tag Set: HTML does not provide the facility to create
customixed tags. It only provides a predefined set of tags. It is not
possible to extend HTML.
Not Reusable: HTML code is used for specific pages and cannot be
reused. The user cannot display the same HTML document in a
different manner without creating different documents each time.
<HTML>
<BODY>
</HTML>
In every HTML document, <HTML> and </HTML> tags indicate the beginning
and end of the document. These tags inform the browser that the document
is an HTML file. All other HTML tags must be written within these tags.
Head Section
Body Section
1. Head Section:
<HEAD> and </HEAD> tags identify the heading or title of document.
The tags <TITLE> and </TITLE> can appears only in this section. The
text between the title tags appears as title in the browser’s window. Its
length should not more than 60 characters.
[Link]
43
C.S-Series Modern Web Programming
2. Body Section:
Practical No. 01
Write HTML code that displays a simple message on the web page.
<HTML>
<HEAD>
</HRAD>
<BODY>
</BODY>
</HTML>
Double click the file. The web page will appear in browser as follows:
Attributes:
Some important attributes of <BODY> tags are as follows:
Attribute Description
BGCOLOR It specifies the background color of the web
page.
BACKGROUND It specifies the background picture of the web
page.
TEXT It specifies the color of the text displayed on
the web page.
Example:
[Link]
44
C.S-Series Modern Web Programming
<BODY BGCOLOR= “red” TEXT=”yellow”>
In the above example, the background color of the web page is red and text
color is yellow. The color name or its hexadecimal code can be given as the
value of the attribute.
In the above example, “[Link]” will appear in the background of the web
page. It should be stored in the some directory in which the web page is
stored. If the picture is stored in some other directory, the complete path of
the picture should be given in the attribute.
Headings
Headings are very important tags in the BODY of HTML document. It is
used to display different types of headings. The opening tag for a heading is
<Hn> and the closing tag is </Hn> where n is the size of heading. Its value
is from 1 to 6. The value 1 represents the largest and the value 6 represents
the smallest heading size.
Attributes:
Attribute Description
ALIGN It specifies the alignment of heading. The
possible values are center, left and right.
The default value is left.
Example:
The above line will display the heading in the center of the page.
Practical No. 02
Write HTML code that displays six types of heading in a web page.
<HTML>
<BODY>
[Link]
45
C.S-Series Modern Web Programming
<H3 My 3rd Heading. <.H3>
</BODY>
</HTML>
Double click the file. The web page will appear in the browser as follows:
Paragraphs:
Paragraphs are used to add text to a document in such a way that it will
automatically adjust the end of line to suit the window. Paragraphs are
defined with the <P> tag. The use of ending tag </P> is optional.
HTML automatically adds an extra blank line before and after a paragraph.
Attributes:
Some important attributes of paragraph tag are as follows:
Attribut Description
e
ALIGN It specifies the alignment of paragraph. The
possible values are center, left and right the
default value is left.
Example:
Practical No. 03
Write HTML code displays three paragraphs with different paragraph
alignments.
[Link]
46
C.S-Series Modern Web Programming
<HTML>
<BODY>
</BODY>
</HTML>
Double click the file. The web page will appear in the browser as follows:
Example:
The following text will be displayed in single line.
Sentence One.
Sentence Two.
[Link]
47
C.S-Series Modern Web Programming
Practical No. 04
Write HTML code that displays text in four lines using <BR> tag.
<HTML>
<BODY>
</BODY>
<HTML>
Double click the file. The web page will appear in the browser as follows:
Attributes:
Some important attributes of HR tag are as follows:
Attribute Description
ALGIN It specifies the alignment of the line. Possible values
are left, right and center. Line appears in center by
default
SIZE It specifies the size of the line. The default size is 2
pixels.
WIDTH It specifies the width of line. Size can be given in
pixels or percentage. The width of line is according
to the width of webpage by default.
NOSHADE It turns off the shading of the line.
COLOR It specifies the color of the line.
[Link]
48
C.S-Series Modern Web Programming
Example:
<HR WIDTH=50 ALIGN= “center” SIZE=4>
Practical No. 05
Write HTML code that displays three horizontal lines with different attributes.
<HTML>
<BODY>
</BODY>
</HTML>
Double click the file. The web page will appear in the browser as follows:
Bold
<B> tag is used to display text in bold face style. It is closed by <B>tag.
Example
Italic
[Link]
49
C.S-Series Modern Web Programming
Example
Underline
Example
Superscript
Example
N<SUP>2</SUP>
Superscript
Example
N<SUB>2</SUB>
Practical No. 06
Write HTML code that displays text in different formatting.
<HTML>
<B> Bold</B><BR>
<Italics</1><BR>
<U>Underline</U><BR>
X<SUP>3</SUP><BR>
[Link]
50
C.S-Series Modern Web Programming
H<SUB>2</SUB>O<BR>
</HTML>
Double click the file. The web page will appear in the browser as follows:
2.7.1 Fonts
<FONT> tag is used to specify the characteristics of font. Different
characteristics include the typeface,saze and color. It is closed with </FONT>
tage.
Attributes:
Some important attributes of FONT tag are as follows:
Attribu Description
te
FACE It specifies the font of the text. The possible values
are “Arial” “Arial
Black” “Courier”and “MS sans Serif” etc.
SIZE It specifies the font of the [Link] can be from 1 to 7.
The default size is 3. The sixe can also be given as
relative to the default size. The size 1 displays 8pt
size, size 2 displays 10 pt and so on.
COLOR It specifies the font of the text. It can be given as
color name of hexadecimal value of the color.
The following tables shows the color name and its hexadecimal value:
[Link]
51
C.S-Series Modern Web Programming
<FONT SIZE=+2 FACE=“Helvetica”>Helvetica</FONT><BR>
Practical No. 07
Write HTML code that displays text of different sizes and colors.
<HTML>
<BODY>
<BODY>
</HTML>
Double click the file. The web page will appear in the browser as follows:
text.<BIG> tag makes the text a little bigger and <SMALL> tag makes the
text a little smaller. However, different browsers display the effect of these
tags differently. In Internet Explorer, text formatted with <BIG> tag is always
one size larger than the surrounding text. The tag has no effect if the size of
surrounding text is 7. The text formatted with <SMALL> is one size smaller
than surrounding text. The tag has no effect if size of surrounding text is1.
Example
The following line will display the text one size larger than normal size:
[Link]
52
C.S-Series Modern Web Programming
The following line will display the text one size smaller than normal size:
Example:
The following text will appear in single line. HTML ignores extra line breaks
so the text appears in single line.
<PRE>
</PRE>
2.8 Spaces
If an HTML document has many space, additional spaces are removed
automatically. If the user inserted in the text by using character entity  
that stands for non breaking space
Example
[Link]
53
C.S-Series Modern Web Programming
2.9 <DIV>Tag
<DIV> tag is used to define a section in an HTML document. It can be used
to group large section of HTML elements together and format them with
cascading style sheet. The closing tag </DIV> is used to indicate the end of
section
Attributes
Some important attributes of <DIV> tag are as follows:
Attribute Description
ALIGN It specifies the alignment of the DIV. The possible values are
center,left and right. The default value is left.
STYLE It is used to incluede inline cascading style sheet
Example
<DIV STYLE=”background-color:biue;text-align:right”>
</DIV>
Practical No. 08
[Link]
54
C.S-Series Modern Web Programming
Write HTML code that displays two sections of text with different formatting
with inline CSS using <DIV>tag.
<HTML>
<BODY>
<DIV STYLE=”=”background-color:orange;text-align:center”>
<P>Its my style!</p>
</DIV>
</DIV>
</BODY>
</HTML>
Double click the file. The web page will appear in the browser as follows:
Example
<p> This is paragraph
This is paragraph</P>
Practical No. 09
[Link]
55
C.S-Series Modern Web Programming
Write HTML code that displays a paragraph using<SPAN> tag. It uses style
attribute to chang the characteristics of part a paragraph element.
<HTML>
<BODY>
The color of the sky is blue,but if you look at the <SPAN STYLE=”color:
‘green”’>trees, they are green</SPAN/></P>
</BODY>
Double click the file. The web page will appear in your browser.
Attributes:
Attribute Description
BEHAVIOR It indicates how the contents will scroll. The possible
values are scroll, slide, alternate. The scroll value is the
default value. It indicates that the content scrolls off the
edge of marquee area and then reappears on the other
side. The slide valu is almost the same. It also indicates
that when the content reaches the left edge, it stops
without scrolling off. The alternate value makes the
contents bounce back and forth. All contents remain visible
all the time.
BGCOLOR It is used to set the background color of the marquee. Its
value can be given as a combination of red, green and
blue or name of the color. The hexadecimal value of the
color can also be used.
DIRECTION It indicates the direction to which the marquee will scroll.
[Link]
56
C.S-Series Modern Web Programming
The possible values are up, down, left and right. The
default value is left. The left value indicates that the
marquee starts at the right and moves to left across the
page. The right value indicates that the marquee starts at
the left and moves to right across the page.
HEIGHT It defines the height of marquee. It is given in pixels or
percentage.
HSPACE It is used to set the horizontal space to the left and right of
the marquee. Its value is given in pixels.
LOOP It specifies the number of times the marquee will scroll.
The default value is INFINITE.
SCROLLDELAY It is used togrher with SCROLLAMOUNT to set the speed of
the scrolling. Marquee moves the content by displaying the
content and then delays for some period of time specified
in SCROLLDELAY. Its value is given in milliseconds. The
default delay is 85
SCROLLAMOUN It is used together with SCROLLDELAY to set the speed of
T the scrolling. Marquee moves the content by displaying the
content and delay for some period of time. It then displays
the content in a new position specified in
SCROLLAMOUNTthat sets the size in pixels of each jump.
Ahigher value for SCROLLAMOUNT makes the marquee
scroll faster. The default value is 6.
WIDTH It defines the width of marquee. It is given in pixels.
VSPACE It is used to set the vertical space at the top and bottom of
the marquee. It is given in pixels
Example:
<MARQUEE> Marquee</MARQUEE>
<MARQUEELOOP=2>Hello</MARQUEE>
Practical No: 10
Write HTML code that displays three marquee with different attributes.
<HTML>
<BODY>
</marquee></font>
[Link]
57
C.S-Series Modern Web Programming
<font size=”4” face=”courier” color=”green”>
</body>
</html>
Double click on the file. The web page will appear in your browser.
HTML Comments:
Example:
[Link]
58
C.S-Series Modern Web Programming
Lists:
HTML can display different items in the form of lists. Lists are used to present
text in more readable form. Different types of lists are as follows:
1. Ordered Lists
2. Unordered Lists
3. Definition Lists
Ordered Lists:
An ordered list is a list of items in which each item is marked with a number
or letter. Ordered list is also known as numbered list. <ol> tag is used to
[Link]
59
C.S-Series Modern Web Programming
create an ordered list. It stands for ordered list. <li> tag is used with each
item in the list. It stand for list item. It has no closing tag. </ol> tag is used
to close an ordered list.
Attributes:
Type: It specific the number scheme for list. The default number scheme is
1, 2, 3…… Possible schemes are:
1 for 1, 2, 3…
A for A, B, C…
a for a, b, c…..
Example:
<ol type=”A”>
<li>Red
<li>Green
<li>Blue
</ol>
Practical No: 11
[Link]
60
C.S-Series Modern Web Programming
Write HTML code that display the following output:
<html>
<head>
<title></title>
</head>
<body>
<;l>
[Link]
61
C.S-Series Modern Web Programming
<li>Mango
<li>Apple
<li>Banana
</ol>
<ol type=”A”>
<li>Lahore
<li>Karachi
<li>Peshawar
</ol>
<ol type=”i”>
<li>Orange
<li>Red
<li>Green
</ol>
</body>
</html>
Double click on the file. The web page will appear in the brpwser.
Unordered List:
[Link]
62
C.S-Series Modern Web Programming
An unordered list is a list of item in which each item is marked with a symbol.
Unordered list is also known as unnumbered list. <ul> tag is used to create
an unordered list. It stands for unordered list. <li> tag is used with each item
in the list. </ul> tag is used to close an unordered list.
Double click on the file. The web page will appear in the browser.
<tr>
<ol type="1">
<ol type="1">
</ol>
</tr>
[Link]
63
C.S-Series Modern Web Programming
<tr>
<td>
<ol type="1">
<li>In the old password text box, type your current password
<li>In the new password text box, type your desired new password
<li>In the confirm password text box, retype your new password
<li>Click OK
</ol>
Recommendations
[Link]