Web Programming Fundamentals Overview
Web Programming Fundamentals Overview
Chapter-1
Fundamentals of web
Internet, Intranet, WWW, Web browsers, Web servers, Search Engines, DNS, URLs, MIME,
HTTP, CGI, Internet Security.
1. LAN
LAN is a group of computers connected to each other in a small area such as
building, office.
It is less costly and provides higher security.
2. MAN
MAN is a network that covers a large geographic area by interconnecting a
different LAN to form a large network.
It has a higher range than LAN.
3. WAN
A WAN is a network that extends over a large geographical areas such as states or
countries.
A WAN is widely used in the field of business, government and education.
Internet (1 Mark)
The internet is the Large network that connects computers all over the world.
Through the internet, people can share information and communicate from anywhere
with an internet connection.
The internet carries large range of information, resources and services.
The internet consists of millions of private, public, business and government networks.
Uses of Internet
Electronic Mail
At least 85% of the inhabitants of cyber space send and receive e-mail. Some 20 million
e-mail messages cross the internet every week.
Research
It include personal research on a particular subject, students doing research for academic
projects and papers, and journalists and other writers researching stories.
Downloading files
Downloading file is accessing information from a web browser, e-mail browser or other
similar systems and saving it to a computer.
Group Discussions
These include public, and the private mailing lists.
Interactive Games
Online video games can be a way to help supplement child’s learning and teach them key
life skills.
Shopping
Online stores usually enable shoppers to use search features to find specific models,
brands or items.
History of Internet
Year Description
1958 Under president Eisenhower, the US formed an Advanced Research Projects
Agency(ARPA) to facilitate more research in science, which could meet
military requirements.
1969 Introduced with ARPANET to implement packet switching
1974 Vint cerf and Robert E Kahn introduced the Transmission Control Protocol
and Internet Protocol(TCP/IP suite)
1991 Tim Berners Lee invented the World Wide Web(WWW) which runs on HTTP.
1995 Internet Service Providers(ISP) allowed the public to subscribe to the
Internet.
2000-2020 Rise of social networking(Facebook, twitter), Blogging sites(Blogspot,
wordpress)
Intranet (1 Mark)
Intranets are private networks used by organizations to distribute communications exclusively
to their workforce and they have been used for decades by enterprises for internal
communications.
The internet is the Large network that Intranets are private networks used by
connects computers all over the world organizations to distribute communications
exclusively to their workforce and they have
been used for decades by enterprises for
internal communications.
In internet, there are multiple users. In intranet, there are limited users.
Internet is unsafe Intranet is safe.
In Internet, there are more number of visitors. In Intranet, there are less number of visitors.
Internet is a public network. Intranet is a private network
Anyone can access internet In this, anyone cant access the intranet
Internet provides unlimited information Intranet provides limited information
WWW (1 Mark)
WWW is abbreviated as World Wide Web
WWW is a collection of webpages found on the network access via internet.
Tim Berners Lee, a British Scientist, invented the World Wide Web (WWW) in 1989,
while working at CERN.
With a web browser, a user views webpages that may contain text, images and other
multimedia and navigates between them using hyperlinks.
WWW is the information sharing model that is built on top of the internet.
Domain Names
A domain name is the textual address where internet users can access website.
The most people type the domain name in the browser than IP address as it is easy to remember
name than numbers.
Example: IP address of [Link] is [Link]
Top level Domains
.com Commercial business
.org Organizations(typically, non profit)
.gov Government agencies
.edu Educational institutions
.net Network organizations
.mil Military organizations
.int International organizations
Sub domains are the third level domains that are used to organize the website containing in a
systematic manner.
They are just like folders under root directory.
Ex: [Link]
Nginx
Nginx is a popular open source web server for administrators because of its light resource
utilization and scalability.
Lighttpd
A free webserver that comes with FreeBSD operating system. It is fast and secure, while
consuming less CPU power.
URL (1 mark)
URL is abbreviated as Uniform Resource Locator
URL is used to specify addresses on the world wide web.
URL include the protocol(Ex: HTTP, FTP), the domain name (or IP address) and additional path
information(folder/file).
Syntax: scheme://location:port/[Link]?querystring=1
Scheme: it is the communication protocol . The most commonly used scheme for web
communication is http or https
Location: it is the DNS or IP address
Port: The TCP port number that the server is listening for incoming request from the clients. It is
a 16 bit binary number by default port is 80.
[Link]: the name and location of the requested resource under the server document
base directory.
Ex: [Link] program/[Link]
MIME (1 mark)
MIME stands for “Multipurpose Internet Mail Extensions”
MIME is a way of identifying files on the internet according to their nature and format.
MIME is an internet standard that extends the format of email messages to support text in
character sets other than ASCII, as well as attachments of audio, video, images and application
programs.
MIME enables to send and receive graphics audio and video files via the internet mail system.
Syntax: type/ subtype
Type Subtype Example
Text Plain or html Text/plain or text/html
Image Gif or jpeg Image/gif or image/jpeg
Video Mpeg Video/mpeg
Application Pdf Application/pdf
application doc Application/doc
SMTP
SMTP stands for “Simple Mail Transfer Protocol”
It is a standard protocol on a TCP/IP network for sending emails through servers from one
computer to another computer.
HTTP (1 Mark)
HTTP stands for “ HyperText Transfer Protocol”
HTTP is an application protocol which allows the fetching of resources such as HTML
documents.
Communication between client computers and web servers is done by sending HTTP request and
receiving HTTP Responses.
The communication using HTTP involve two phases.
1. HTTP Request Phase
2. HTTP Response phase
HTTP Message: It consists of three parts message head, blank line, message body.
Request Line
Request heads
Blank Line
Request Message
Message body(optional)
1) HTTP 1.0
2) HTTP 1.1
Syntax of request header:
Request header name: request header value 1, request header 2,…
Example: host: [Link]
Accept: image/gif
Accept language: us .en
Status line
Response head
Blank Line
Response message
Status line:
Syntax:
http version status code reason phrase
HTTP version: it is used in this session either http/1.0 or http/1.1
Status code: A three digit number generated by the server to reflect the outcome of the request.
Reason phrase: it gives the short explanation to the status code
Example:
http/1.1 200 ok
http/1.0 404 not found
http/1.1 500 internal server error
Response header:
Syntax:
Response header name: response header value
Example:
Content type: text/html
Content length:80
Connection keep aline
Communication between clients and servers is done by requests and responses:
1) A client(a browser) sends an HTTP request to the web
2) An web server receives the request
3) The server runs an application to process the request
4) The server returns an HTTP response (output) to the browser
5) The client (the browser) receives the response
Stateless Protocol
Stateless protocols are the type of network protocols in which client send request to the server
and server response back according to the current state.
It does not require the server to retain session information or a status about each communicating
partner for multiple request.
Examples: HTTP and IP
CGI [ 1 Mark]
CGI stands for Common Gateway Interface
CGI is a server extension that extends the capability of web server
It is the technology allows the web browsers to submit forms and connect to programs over a
web server.
Example: when we fill up the form and submit the form applying click the submit button and it
goes , what are the results from this level is CGI
In the first step the web client connect to the web server and sends the program to the webserver.
The web server runs a CGI program in the server side.
The webserver sends that particular dynamic web document is as a response to the web client.
As a fresh document is created for each request the contest of the dynamic document can vary
from one request to another.
Example: getting the date and time from the webserver.
Advantages of CGI
1) CGI is used for simple interactive applications
2) CGI programs are server side programs.
3) CGI programs can be written in any programming languages like Perl, PHP, python, Java,
C++
4) It is simple
5) it is light weight and speedy because it does not required any particular library to make a CGI
program
Environment variables
A CGI program uses of list of environment variables to response to the request from the browser.
Environment Variable Meaning
CONTENT_LENGTH The length of the data passed to CGI root
directory of web documents
DOCUMENT_ROOT Root directory of web documents
HTTP_USER_AGENT Type of the client programmer(browser)
SERVER_NAME It specifies the server name and IP address
SERVER_ROOT Port number of the server
A search engine is a software system that is designed to search for information on the world
wide web.
Search engine searches the world wide web in a systematic way for particular information
specified in a textual web search query.
Youtube
Youtube was founded in 2005 by veterans of PayPal and was purchased by Google. It receives
more than 1.5 billion logged in users per month and feeds over 1 billion hours of video each day
to users.
Amazon
Amazon was launched in 1995. it is one of the first large companies to sell goods online.
Facebook
In 2006, facebook was developed by Mark Zuckerberg. It crosses 2 billion searches/ day. It also
gives businesses and advertisers a market access.
Bing
Bing replaced MSN search as Microsoft’s answer to Google in 2009. it provides of various
search services, including web, video, image and map search products.
Internet Security
Internet security is a standard for protecting data that gets sent through the internet.
The most common security issues are
1. Privacy
2. Authentication
3. Integrity
4. Non repudiation
5. Encryption and Decryption
Question Bank
1 Mark Questions:
1) Define Internet.
3 Marks Questions:
1) What is DNS? Explain its task.
2) Explain MIME.
3) Explain Web browser.
4) Explain in brief origin of internet.
5) Write the differences between Internet and Intranet.
6) How the dynamic document is created and processes?
5 Marks Questions:
1) What is webserver? Explain the types of webserver.
2) What is Internet? Explain the merits of internet.
3) Discuss Internet Protocol Address.
4) Discuss URL Paths.
5) Explain Uniform Resource Locators.
6) Write a note on Multi Purpose Internet Mail Extensions.
7 Marks Questions:
1) Explain a) MIME b) WWW c) DNS with suitable examples.
2) Explain the phases of HTTP.
3) Discuss the general forms of HTTP request.
*****
Year Version
1989 Tim Berners Lee invented WWW
1991 Tim Berners Lee invented HTML
1993 HTML 1.0 is released. It is released for sharing information that can be readable and
accessible via web browsers. It didn’t support the background color or background
image of the page.
1995 HTML 2.0 is released. It contains all the features of HTML [Link] color
and images could be set. Forms became available with a limited set of fields. First
time visitors to a web page could submit information. Tables also came in picture.
1997 HTML 3.2 is released by Dave Raggett, who introduced a fresh paper on draft on
HTML. HTML 3.2 support CSS level 1. HTML 3.2 didn’t included support for the
frame but browsers makers implemented them anyway.
1999 W3C Recommendation: HTML 4.01. HTML 4.01 also provides the basis for
meaning of XHTML elements and attributes, reducing the size of XHTML 1.0
specification.
2008 WHATWG HTML 5 First public Draft. HTML 5 improves interoperability and
reduce the development costs by making precise rules on how to handle all HTML
elements and how to recover from errors. HTML 5 included functions for
embedding audio, video, graphics, client-side data storage and interactive
documents.
2015 XHTML 1.0
XHTML is the first specification for the HTML and XML cross-breed.
XHTML document can be manipulated by any program that understands XML.
2018 XHTML 1.1
XHTML 1.1 breaks features of XHTML 1.0 down into separate modules which
browsers may or may not choose to implement depending on their appropriates for
the web browser devices.
Web Standards is defined as a formal set of standards and technical specifications used
to define aspects of the World Wide Web.
These are best practice standards used by organizations to build web sites and web
applications.
The commonly referenced Web Standards are HTML, XML 1.0, XHTML, CSS.
Advantage:
1. HTML can create only static and plain pages so if we need dynamic pages then
HTML is not useful.
2. Need to write lot of codes for making simple web pages..
HTML XHTML
1. The tag names and attribute names are 1. The tag names and attribute name are case
case insensitive. sensitive.
2. In HTML, we can use capital letters for [Link], XHTML, all tags must be written in
element, lowercase for attributes. lowercase.
3. Not required in HTML. 3. Every element we use in XHTML must
have both an opening and closing tag.
4. It is optional. 4. In XHTML, empty element may use either
the empty element syntax (br />) or have an end
tag immediately follow the start tag (<br>
</br>).
[Link] required. 5. All attributes in XHTML must be contained in
quotes.<input type=”submit” name=”submit
button”/>
6. Some elements have attributes that do 6. In XHTML , all attribute must be expressed in
not appear to require a value-for attribute-name and attribute-value pairing with
example. quote marks surroundings the attribute value –
part.
<input type=”checkbox” name=”chkNewsletter”
checked=”checked”.>
[Link] allows Minimization. 7. It doesn’t allow attribute minimization
[Link] is not required in HTML. 8. In XHTML, the opening <html>tag
requires an xmlns attribute(XML NameSpace).
[Link] is optinal. 9. XHTML requires certain characters to appear
as named entities.
Ex: We can’t use the character, it must be
expressed using an HTML entity.
[Link] HTML, languages in the document 10. In XHTML, languages in the document
must be expressed using the lang attribute. must be expressed using the xml:lang attribute.
[Link] must be served as text/html. 11. XHTML must be served with an XML
MIME type, such as application/xml or
application/xhtml+xml.
1) Sustainability
2) Wide Range of applications
3) Compatibility
4) Closing tags
5) XHTML is easier to teach and to learn
6) XHTML is ready for the future
7) Extensibility
Sustainability:
XHTML will sustain more long time till web application use XML for their
development.
Compatibility:
The XHTML documents are written in compliance with the rule of XML, and XML
processing programs can covert an XHTML document into PDF, RFT . Because of this
it supports wide range of file format.
Closing tags:
XHTML supports closing tags. It makes our source code clean and readable.
Extensibility:
XML documents are required to well-formed. In the XML-based DTD, a new set of
elements simply needs to be internally consistent and well-formed to be added to an
existing DTD.
HTML Comments:
There will be nothing change in terms of the visibility. It is just simple notice to
anyone looking at code of the web page.
1) DOCTYPE
2) Head
3) Body
The <head> area contains information about the document, such as ownership , copyright,
and keywords; and the <body> area contains the content of the document to be displayed.
Example:
<? xml version=”1.0” ?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0
Strict//EN” [Link]
[Link] >
<html xmlns=[Link] xml:lang=”en” lang=”en”>
<head>
<title>My XHTML Sample page</title>
</head>
<body>
<h1>Welcome to XHTML</h1>
</body>
</html>
Explanation:
Line 1:
Since XHTML is, when HTML expressed with XML document. So it must include
the initial XML declaration <?xml version=”1.0” ?> at the top of the document.
Line 4:
The second tag in an XHTML document must include the opening <html> tag with the
XML namespace identified by the xmlns=[Link] attribute.
The XML namespace identifies the range of tags used by one DTD which doesn’t
conflict with user-defined tags or tags defined in other DTDs.
Line 5-7:
XHTML document must include a full header area. This area contains the opening
<head> tag and the title tags(<title></title>), and is then completed with the closing
</head> tag.
Line 8-10:
XHTML document must include opening and closing <body> </body> tags. Within
these tags we can place traditional HTML coding tags.
Line 11:
Finally, the XHTML document is completed with the closing </html> tag.
DOCTYPE definition line in an XHTML document specifies the document type. The
syntax and legal elements of an XHTML documents are specified by DTD
The purpose of a DTD (Document Type Definition) is to define the legal building
blocks of an XML document. A DTD defines the document structure with the list of
legal elements and attributes.
If we are planning to use strictly CSS and avoiding to write most of the XHTML
attributes, then it is recommended to use this DTD. If we want to use XHTML 1.0
Strict DTD then we need to put following line at the top of the XHTML
document.
If we are planning to use many XHTML attribute as well as few CSS properties,
then we should use this DTD and we should write XHTML document according
to the DTD.
If we want to use this then we need to put following line at the top of the
XHTML document.
<! DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional //EN”
[Link]
We can use this DTD when we want to use HTML Frames to partition the
browser window into two or more frames.
If we want to use this DTD then we need to put following line at the top of
XHTML document.
<! DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Frameset //EN”
[Link]
Rule 3: All attributes that are use in XHTML, must be in lower case.
Wrong: <a HREF=”[Link]
Right : <a href=[Link] </a>
Question Bank
1 Mark Questions
1) What is XHTML?
2) What is HTML?
3) Why XHTML is required?
3 Marks Questions
1) What are the advantages of XHTML over HTML?
2) Explain XHTML doctypes?
3) Explain Structure of HTML program.
4) What is the differences between HTML and XHTML.
5) Write the primary function of W3C?
6) What do you mean by Web Standards?
5 Marks Questions
1) Explain XHTML document structure.
2) Write the advantages and disadvantages of HTML.
3) How HTML works.
7 Marks Questions
1) Explain the general structure of an HTML program with an example.
2) What is XHTML? Write the syntax rule to create XHTML and what are the advantages
of XHTML over HTML.
*****
Chapter 3
Syntax:
<p align=”value”> paragraph body </p>
Output:
--------------------------------------------------------- --------------------------
Headings H1 to H6
HTML defines six levels of headings.
The heading elements are H1, H2, H3, H4, H5, and H6.
h1 is the largest heading tag and h6 is the smallest one.
When you place the text within the heading tags <h1>.........</h1>, it is
displayed on the browser in the bold format and size of the text depends on the
number of heading.
Syntax:
<h1> headings </h1>
Output:
---------------------------------------------------------------------------------
Syntax:
<pre> preformatted text </pre>
Output:
------------------------------------------------------------------------------------
Line Break:
HTML tag <br> element defines a line break.
The <br> tag is an empty tag which means that it has no end tag.
Line breaks ends the live we are currently on and resume on the next line.
Syntax:
<br>
Output:
------------------------------------------------------------------------------------
Horizontal Rule:
The <hr> tag in HTML stands for horizontal rules across the page.
This is used to insert a horizontal rule in an HTML page to divide or separate
document sections.
The <hr> tag is an empty tag and it does not require an end tag.
The table given below describe the <hr> tag attributes:
Attribute Value Description
left
Used to specify the alignment of the
Align center
horizontal rule.
right
Used to specify the bar without
noshade noshade
shading effect.
Used to specify the height of the
size pixels
horizontal rule.
Used to specify the width of the
Width pixels
horizontal rule.
Output:
------------------------------------------------------------------------------------
Presentation elements
HTML contains several elements for defining text with a special meaning, and
whenever user wants to format text element the presentation elements are used.
Tag Description
<b> .... </b> Defines italic text
<i> .... </i> Defines bold text
<u> ......... </u> Defines underlined with a simple line.
<ins> .... </ins>
<sub> ..... </sub> Defines subscripted text. Subscripted text appears half
a character below the normal line and is sometimes
rendered in a smaller fonts.
<sup> ...... </sup> Defines superscripted text. Superscripted text appears
half a character above the normal line and is
sometimes rendered in a smaller fonts.
<s> ..... </s> Displayed with a strikethrough, which is a thin line
<strike> .... </strike> through the text or text has been deleted from a
<del> ... </del> document.
<big> .... </big> It is used to make the contents of the element one font
size larger than the rest of the text surrounding it.
<small> .... </small> It is used to make the contents of the element one font
size smaller than the rest of the text surrounding it.
<mark> ..... </mark> Defines marked text.
Output:
----------------------------------------------------------------------------------
Output:
-------------------------------------------------------------------------
<i> - Italic text:
Italic tag is used to write the content in italic format.
Output:
------------------------------------------------------------------------------------
Output:
---------------------------------------------------------------------------
<u> - underline:
The <u> tag in HTML stands for underline and it’s used to underline the text
enclosed within the <u> tag.
Output:
------------------------------------------------------------------------------------
Output:
Output:
-----------------------------------------------------------------------------------
<sup> - Superscript text
The HTML <sup> element defines superscript text. Superscript text appears
half a character above the normal line, and is sometimes rendered in a smaller
font. Superscript text can be used for footnotes, like WWW [1].
Output:
---------------------------------------------------------------------------------
Phrase Elements
Phrase elements are used to indicate that a block of text has structural meaning.
Tag Description
<code> ....... </code> Defines the computer code
<kbd> ...... </kbd> Defines the keyboard input
<var> ....... </var> Defines a variable
<em> ....... </em> Defines emphasized text
<strong> ....... </strong> Defines important text.
<address> ..... </address> Used to contain addresses
--------------------------------------------------------------------------------------
<meta> Tag
The metadata means information about data.
The <meta> tag in HTML provides information about HTML Document.
<meta> tags always go inside the <head> tag.
It used to specify character set, page description, keywords, author of the
document, and viewport settings.
Metadata will not be displayed on the page but will be machine parsable.
CHARACTER ENTITIES
Character entities are used to display the special characters in HTML.
Syntax: &entity_name;
Or
&entity_code;
β β β
® ® ®
© © ©
∆ Δ δ
∏ π ϖ
------------------------------------------------------------------------------------
<marquee> tag:
Marquee tag supports scrollable texts and images within webpage. Scrolling either
from left to right or vice versa, or top to bottom or vice versa.
Syntax:
<marquee> scrollable texts/images </marquee>
Attributes:
Attribute Description
width Provide width or breadth of a marquee.
height Provides the height or length of a
marquee.
direction Provides the direction or way in which
your marquee will allow you to scroll.
The value of this attribute can be: left,
right, up or down.
Example:
<html>
<body>
<marquee>scrolling text</marquee>
<h4> scrolling image</h4>
<marquee>
<img src = "C:\Users\VVFGC\Downloads\[Link]">
</marquee>
</body>
</html>
Chapter 4
LISTS
HTML Lists are used to specify lists of information.
All lists may contain one or more list elements.
There are three different types of HTML lists:
Ordered List or Numbered List (ol)
Unordered List or Bulleted List (ul)
Description List or Definition List (dl)
Attributes
Type Description
type="1" The list items will be numbered with numbers (default)
type="A" The list items will be numbered with uppercase letters
type="a" The list items will be numbered with lowercase letters
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
</body>
</html>
OUTPUT:
-----------------------------------------------------------------------------
The Unordered HTML List
Unordered lists provides a sequence of unordered steps for an activity.
An unordered list starts with the <ul> tag and ends with the </ul> tag.
Each list item starts with the “li” tag.
The list items are marked with bullets i.e small black circles by default.
The type attribute of the <ul> tag, defines the type of the list item marker
Attributes
Type Description
disc Sets the list item marker to a bullet (default
circle Sets the list item marker to a circle
square Sets the list item marker to a square
none List items will not be marked
OUTPUT:
----------------------------------------------------------------------------------
Syntax:
<dl>
<dt>term name</dt>
<dd> definition of term </dd>
</dl>
OUTPUT:
--------------------------------------------------------------------------------
Images
Images can improve the design and the appearance of a web page.
Attributes:
Attribute Value Description
src url/pathname Specifies the URL of an image
alt text Specifies an alternate text for an image
top
bottom
Specifies the alignment of an image according
align middle
to surrounding elements.
left
right
Specifies the width of the border around an
border pixels
image
height pixels Specifies the height of an image
width pixels Specifies the width of an image
OUTPUT:
Example:
<html>
<head>
<title>bgsound tag </title>
</head>
<body>
<bgsound src=”C:\folder\sleep.mp3” loop=”5”>
<p> the audio is playing background </p>
</body>
</html>
----------------------------------------------------------------------------------------
<marquee> behaviour:
An HTML <marquee> tag is a scrolling piece of text or image displayed either
horizontally across or vertically down the web page.
Attributes:
Attribute Value Description
width pixels Specifies the width of the marquee
height pixels Specifies the height of the marquee
up
down Specifies the direction in which marquee should
direction
left scroll
right
scrolldelay pixels Specifies how long to delay between each jump
---------------------------------------------------------------------------------------
syntax:
<a href="url">link text</a>
Output:
-------------------------------------------------------------------------------------
Internal Link
HTML internal link is linked within the same web page.
An internal link takes you to another page in your website.
HTML internal link name is followed by head sign(#). HTML <a> tag is use for
anchor point name, which is referred to a internal link into a same page.
These links are usually relative and are in the form of:
<a href="/web/[Link]">
<b>Web Design Resources</b>
</a>
External Links
External HTML Links is linked to external web page.
<a href="[Link]
--------------------------------------------------------------------------------------
Types of Hyperlinks
Links can point to other web pages, web sites, graphics, files, sounds, e-mail
addresses, and other locations on the same web page.
Image hyperlink – Uses an image to take visitors to another page, file or document.
<a href="/web/[Link]">
<img src=”/web/[Link]”>
</a>
E-mail hyperlink – Allows visitors to send an e-mail message to the displayed e-mail
address.
<a href=”vvfgcbca@[Link]”>
Send E-mail
</a>
------------------------------------------------------------------------------------------------------------------------------------------
anchor <a> tag :
a link is specified using HTML tag <a>. This tag is called anchor tag.
Anything between the opening <a> tag and the closing </a> tag becomes part of
the link and a user can click that part to reach to the linked document.
Syntax:
<a href=”url”>link text </a>
Attributes:
Attribute Value Description
href url Specifies the url of the page the link goes to
Chapter 5
Tables and Forms in HTML
Tables
A table is a collection of information or data arranged into columns and rows.
Content of a cell can be any elements including text, an image, list and a
nested table etc..
Tables are defined with the <table> tag.
Attributes :
Attribute Values Description
align left Specifies the alignment of a table according
center to the surrounding text.
right
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
<tr >
<td valign="top">Balu</td>
<td valign="center">22</td>
<td valign="bottom">CSE</td>
</tr>
<tr >
<td valign="bottom">RAKESH</td>
<td valign="center">25</td>
<td valign="top">EC</td>
</tr>
</table>
</body>
</html>
Output:
---------------------------------------------------------------------------------------------------------------
The rowspan and colspan attributes
rowspan used to specify the number of rows a cell should merge. rowspan
attribute have numeric value. <th> and <td> tags can use this attribute.
for example,
<td rowspan= 2>
Above example says two rows of data is going to merge.
colspan used to specify the number of columns a cell should merge. colspan
attribute have numeric value. <th> and <td> tags can use this attribute.
for example,
<td colspan= 2>
Above example says two cols of data is going to merge.
<td>1 Sem</td>
<td>2 Sem</td>
<td rowspan="2">10</td>
</tr>
<tr>
<td>C</td>
<td>C++</td>
</tr>
</table>
</body>
</html>
Output:-
---------------------------------------------------------------------------------
The cellpadding and cellspacing attributes
Cellpadding is the distance between the edges of the cell to its content. which
you will use to adjust the white space in your table cells. Numerical value must
be given for cellpadding.
Cellspacing is the distance between cells. which you will use to adjust the
white space in your table cells. Numerical value must be given for cellspacing.
Example:
<table cellspacing="5" cellpadding="10">
<html>
<body>
<table border="3" cellspacing="10" cellpadding="5">
<tr>
<td>WEB</td>
<td>PROGRAMMING</td>
</tr>
</table>
<hr>
<br>
<table border="3" cellspacing="5" cellpadding="10">
<tr>
<td>WEB</td>
<td>PROGRAMMING</td>
</tr>
</table>
</body>
</html>
Output:
------------------------------------------------------------------------------
MANAGING FORMS
A form is the usual way of information, it contains different kind of information
such as username, password, contact number, email id etc.
HTML provides various tags like check box, text, radio buttons, submit buttons
etc., these elements are used to submit the information from web browser to
web server.
----------------------------------------------------------------------------------
<Form> Tag:
The form tag is used to create an HTML form. This tag has many attributes.
The most required attributes is the action and method attribute.
action attribute:
Action attribute is required to provides the path to the database or server
or script or program that will process the form data when the user submits
the form.
Example: <form action=”/bu-bin/[Link]”>
method attribute:
This attribute tells the web server how to process the data values.
This specifies two techniques: get and post
get method:- which is used to request data from a specified
resource/server.
POST method:- which is used to send data to a server to create/update a
resource.
Example: <form action=”/bu-bin/[Link]” method="GET">
<form action=”/bu-bin/[Link]” method=”post”>
-----------------------------------------------------------------------------------
FORM CONTROLS
The different types of form controls are:
Text box
Text area
Password input controls
Buttons
Checkboxes and radio buttons
Select boxes(sometimes referred to as drop down menus and list boxes)
File select boxes
Hidden controls
Image buttons
----------------------------------------------------------------------------------------
input Element (or <input> tag) in HTML :
Input Elements are the most common elements which are used in HTML Forms.
Various user input fields can be created such as text, check box, password field,
radio button, submit button etc.
The <input> element can be displayed in several ways, depending on the type
attribute
<input> elements
<input> element can be displayed in several ways, depending on the type
attribute are listed below:
Text: Creates horizontal box for text input. Default size is which can be changed
with size or maxlenght attribute.
Example:
<form>
First Name: <input type="text" /> <br>
Last Name: <input type="text"/> <br>
</form>
OUTPUT:
Password: If the contents of the textbox should not be displayed when user
types it then password control should used. It cannot be read, usually by replacing
each character with a symbol such as the asterisk ("*") or a dot ("•").
Example:
<form>
<input type="text"><br>
<input type="password">
</form>
OUTPUT:
Radio button: Radio buttons are typically visible as small circles, which are filled
or highlighted when selected. Only one button can be checked at a time.
Example:
<form>
<input type="radio" >
<label>Male</label><br>
<input type="radio" >
<label>Female</label><br>
<input type="radio" >
<label>Other</label>
</form>
OUTPUT:
Checkbox : Checkboxes are used for lists, where the user can choose one or
more selections from a list of options.
Example:
<form>
<input type="checkbox" ">
<label > I have a bike</label><br>
<input type="checkbox" >
<label >I have a car</label><br>
<input type="checkbox" >
<label > I have a boat</label>
</form>
OUTPUT:
Date: Date element is used for entering a date. Once you run your html code date
picker will available like calendar.
Example:
<form>
<input type="date">
</form>
OUTPUT:
Submit: Submit element used for submit the form, its look like button on
webpage if you click on that, form inform is submitted.
Example:
<form>
First name:<br>
<input type="text"><br>
Last name:<br>
<input type="text"><br><br>
<input type="submit" value="Submit">
</form>
Output:
Reset: reset button that will reset all form values to their default values or clear
all the fields of form.
Example:
<form>
Name:<br>
<input type="text"><br><br>
<input type="submit"> <input type="reset">
</form>
Output:
----------------------------------------------------------------------------
<Select> Tag:
The <select> defines a drop-down list or provides a menu of options
Example:
<from>
Select your fav. car:
<select>
<option>Volvo</option>
<option>Saab</option>
<option>Fiat</option>
<option>Audi</option>
</select>
</from>
OUTPUT:
---------------------------------------------------------------------------------
FRAMES
HTML frames are used to divide your browser window(or webpage) into
multiple sections, where each section can load a separate HTML document.
To use frames on a page we use <frameset> tag instead of <body> tag.
The <frameset> tag defines how to divide the window into frames.
The rows attribute of <frameset> tag defines horizontal frames
and cols attribute defines vertical frames.
Each frame is indicated by <frame> tag and it defines which HTML document
shall open into the frame.
Attribute:
Attribute Description
cols Specifies how many frames the window will be split into vertically and
specifies the width of each frame.
The default width is 100% = one column taking up the whole width.
rows Specifies how many frames the windows will be split into horizontally
and specifies the height of the frame.
The default is 100% = one row taking up the whole height.
Example:
<html>
<frameset rows = "20%,80%">
<frame src = “[Link]" />
<frame src = "[Link]" />
</frameset>
</html>
Attributes Description
Specifies whether a three dimensional border should be
frameborder
displayed between frames.
marginheight Determines the amount of space above and below the frame.
Examples:
[Link]
<html>
<frameset rows = "30%,80%">
<frame src="C:\Users\Dell\Desktop\[Link]" />
<frameset cols = "20%,*">
<frame src = "C:\Users\Dell\Desktop\[Link]" />
<frame src = "[Link]" />
</frameset>
</frameset>
</html>
[Link]
<html>
<body bgcolor="pink">
<center>
<h1>Advaith Hyundai</h1>
Caring for you always
</center>
</body>
</html>
[Link]
<html>
<body>
<ul>
<b><l>
<li>Hyundai Santro
<li>Hyundai Grand I10
<li>Hyundai Elite I20
<li>Hyundai Aura
<li>Hyundai All New Verna
</l></b>
</ul>
</body> </html>
[Link]
<html>
<body>
<p align="center">
<b>Welcome To Advaith Hyundai
Buy Choose , Service , Your Dream Hyundai Cars</b>
</p><hr>
<p align="center">
Advaith Hyundai has a rich legacy and it is World’s largest
Prof. JANHAVI N L, VVFGC, Tumkur Page 13
INTERNET PROGRAMMING TABLES AND FORMS IN HTML
Output:
Question Bank:
1 marks:
1. What is table?
2. Define <td>,<tr>,<th>?
3. Define rowspan ?
4. Define colspan?
5. Write the purpose of using <caption> tag.
6. What is the use of valign attribute.
7. Define cellspacing.
8. Define cellpadding
9. What is form.
[Link] is the use of <input> tag.
[Link] are attributes of <frameset> tags.
[Link] do you mean by frames.
3 marks:
1. What is the use of “submit” and “reset” button?
2. Explain get and post.
3. Explain <select> tag.
5 marks:
1. Explain different types of INPUT elements present in HTML.
2. Explain basic HTML table tag.
3. Write an HTML code to design application form, includes student details
Chapter 6
XML- EXTENSIBLE MARKUP LANGUAGE
CSS
CSS is a language that applies styles to a HTML document and its elements to
change the look and feel.
It is usually stored in [Link] style which can be re-used for all the web
pages.
A website is made up of HTML for content plus CSS for appearance.
HTML + CSS = WEB PAGE
(Content) (Presentation)
---------------------------------------------------------------------------------------
ADVANTAGES
1. CSS saves time-
You can write CSS once and then reuse same sheet in multiple HTML pages.
You can define a style for each HTML element and apply it to as many Web
pages as you want.
3) Easy maintenance-
To make a global change, simply change the style, and all elements in all the
web pages will be updated automatically.
DISADVANTAGE
Browser Compatibility
Some style sheet features are supported and some are not supported by the
browsers.
--------------------------------------------------------------------------------------
Example:
You can define a table border as follows:
table{border :1px;}
---------------------------------------------------------------------------------------
LEVELS OF STYLE SHEET (CSS Inclusion)
There are 3 levels of style sheet used associate css styles witlh your HTML
document.
1) Inline
2) Document or internal
3) External
The internal style is defined inside the <style> element, inside the head
section.
Example:
<html>
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
3) External CSS-
With an external style sheet, you can change the look of an entire website by
changing just one file!
Each HTML page must include a reference to the external style sheet file inside
the <link> element, inside the head section.
External styles are defined within the <link> element, inside the <head>
section of an HTML page:
An external style sheet can be written in any text editor, and must be saved
with a .css extension.
The external .css file should not contain any HTML tags.
Example:
[Link]
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
[Link]
<html>
<head>
<link rel="stylesheet" href="[Link]">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
---------------------------------------------------------------------------------------
TYPES OF SELECTORS
CSS selectors are used to select the content you want to style. Selectors are the
part of CSS rule set. CSS selectors select HTML elements according to its id, class,
type, attribute etc.
There are several different types of selectors in CSS.
CSS Element Selector
CSS Id Selector
CSS Class Selector
CSS Universal Selector
CSS Group Selector
2) CSS Id Selector
The id selector selects the id attribute of an HTML element to select a specific
element.
An id is always unique within the page so it is chosen to select a single, unique
element.
It is written with the hash character (#), followed by the id of the element.
Example:
<html>
<head>
<style>
#para1 {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<p id="para1">Hello [Link]</p>
<p>This paragraph will not be affected.</p>
</body>
</html>
3) Class selectors
The class selector selects HTML elements with a specific class attribute.
It is used with a period character . (full stop symbol) followed by the class name.
Example:
<html>
<head>
<style>
.center {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1 class="center">This heading is blue and center-aligned.</h1>
<p class="center">This paragraph is blue and center-aligned.</p>
</body>
</html>
Example:
<xml version"1.0" encoding="UTF-8'?>
<books>
<book>
<title Internet Programming</title>
<author>Kumar</author>
</book>
</books>
1. XML Declaration:
The XML declaration indicates that the document written XML and specifies
which version of XML.
The XML declaration must be on the first line of document.
The XML declaration can also specify language encoding for document.
Ex: <?xml version="1.0" encoding=TF-8>
2. Root element:
All XML document must one (and only one) root element. All other elements
must be nested inside this root element.
The first tag in the document will always be the opening tag of the root
element and the closing tag will always be at the bottom of the element.
XML document contains an element which is the parent of all other child
elements.
The first element of the document is called the root element.
Ex: <books> ………. </books>
3. Child element:
These are elements that are contained within the root element. Elements are
usually represented
by an opening and closing tag
Tags have attributes to provide information about tag, <books> ---</books>
These are three types:
o Start tag.(Ex: <book>)
o End tag.(Ex:</book>)
o Empty-element tag: This is also known as body less tag. It has start tag
but doesn't have a matching end tag. Ex: <book/>
4. Element:
The content between start tag and end tag including tag is called element. An
element can contain other child elements.
Example:
<book>
<title>Internet Programming</title>
<author> abc </author>
<book>
5. Attributes:
Elements can also contain one or more attributes.
An attributes is a name/value pair that we place within an opening tag, which
allows us to provide extra information about an element.
Attribute often provide information that is not part of the data Attribute values
must always be enclosed in either single or double quotes.
Example:
<book type-"technical">
</book>
6. Comments:
XML comments begin with <!-- and end with -- >,
An XML comment allows us to write comments within the document and
comments are ignored by XML parsers.
We write comment as an note to ourselves or another programmer. It can
appear anywhere in within the document.
Example:-
<!--This file is related to books information ->
Example:
<book> This is incorrect
<book> This is correct</book>
[Link]
<?xml version=”1.0” encoding=”UTF-8”?>
<?xm-stylesheet type=”text/css” href=”[Link]”?>
<books>
<book>
<title>web</title>
[Link]
books
{
margin:10px;font-family:verdana;
}
title
{
font-weight:bold;
font-size:large;
color:red;
}
author
{
font-weight:italic;
font-size:large;
color:blue;
}
------------------------------------------------------------------------------------------
XML CDATA
CDATA is used about text data should not be parsed by the XML parser.
Characters like "<” and "&" are illegal in XML elements.
Java script contains a lot "<” or "&".
To avoid the errors seript code can be defined as CDATA.
Everything inside a CDATA section is ignored by the parser.
A CDATA section starts with <![CDATA[ and ends with ]]>
Example:
<html>
<head><title>CDTA Demos/title>
<script type="text/javascript”>
<[CDATA[
function greatest(a,b)
if(a>b) then
return b;
else
return a;
}]]>
</script>
</head>
<body>
<h1>Greatest of two number</h1>
</body>
</html>
-----------------------------------------------------------------------------------------
Types of XML Document and Validation
There are two types of XML document and validation.
o Well Formed.
o Valid Document
a) Well Formed:
"Well Formed" XML document is a document that conforms to the XML syntax
rules.
b) Valid document:
Valid" XML document is "Well Formed" XML document which conforms to the
rule of a DTD.
DTD of [Link]
<!ELEMENT books (book)+>
<IELEMENT book(title , author)>
<IELEMENT title(#PCDATA)>
<!ELEMENT author(#PCDATA)
– books can have one or more book elements
– Each book element have title and author
– The title and author contains PCDATA and which means, element data is
going to parser.
-------------------------------------------------------------------------------------
DOCTYPE Syntax:
We can declare a DTD at the top of the XML document using the <!DOCTYPE
declaration.
The Basic syntax is:
<!DOCTYPE rootname [DTDJ>
Where,
rootname is the root element.
[DTD] is the actual definition
Rules:
1. The document type declaration must be written in between the XML declaration
and the root element.
2. Keyword DOCTYPE must be followed by the root element.
3. Keyword DOCTYPE must be in upper case.
--------------------------------------------------------------------------------------
Prof. JANHAVI N L, VVFGC, Tumkur Page 13
INTERNET PROGRAMMING XML- eXtensible Markup Language
EXTERNAL DTD:
External DTD is same as internal DTD except that it defines in the external
file.
We create DTD in notepad and save this file with dtd and it can use with
more than one XML document.
[Link]
<?xml version = "1.0" encoding = "UTF-8" standalone="no" ?-
<?xml-stylesheet type="lext/css" href="[Link]"?>
<!DOCTYPE address SYSTEM "[Link]">
<address>
<name> neethu joy</name>
<company>wipro</company>
<phone> (011) 123-4567</phone>
<email>&email123;</email>
</address>
--------------------------------------------------------------------------------------
XML NAMESPACES
In XML, A namespace is used to prevent any conflicts with element names.
In other words, Namespace means by which we can differentiate elements and
attributes of different XML document types from each other when combining
them together into other document, or even processing multiple documents
simultaneously.
Example:
<?xml version="1.0" encoding="UTF-8"2>
books
<book>
<title>Intemet Programming</title
author kumar</author>
</book>
</books>
5. Usually the element for which a namespace is declared is usually the root of a
document.
<html xmlns=[Link]
This declares the default namespace, from which names appear without prefix.
-----------------------------------------------------------------------------------
XML Schemas
An XML Schema defines how to structure an xml document and it can be used
in the place of DTD.
XML Schema is based on the XML.
XML Schema language is known as XML Schema Definition(xSD).
XML Schemas are used to overcome the disadvantage of DTDs.
--------------------------------------------------------------------------------------