Unit 1 - Fundamentals of Web, XHTML A Brief Introduction About The Internet 1) Origins
Unit 1 - Fundamentals of Web, XHTML A Brief Introduction About The Internet 1) Origins
Unit 1 - Fundamentals of Web, XHTML A Brief Introduction About The Internet 1) Origins
1
So, the Internet is actually a network of networks, rather than a network
of computers.
Obviously, all devices connected to the Internet must be uniquely
identifiable.
4) Domain Names
The IP addresses are numbers. Hence, it would be difficult for the users to
remember IP address.
To solve this problem, text based names were introduced. These are
technically known as domain name system (DNS).
These names begin with the names of the host machine, followed by
progressively larger enclosing collection of machines, called domains.
A DNS server is a server software program that performs Domain Name
Services (DNS).
This involves taking a full host name such as 'www.vicomsoft.com' or a
domain name such as 'vicomsoft.com' and returning the corresponding
Internet Protocol (IP) address such as 195.224.81.4.
There may be two, three or more domain names. DNS is of the form
hostname.domainName.domainName.
Example: aiet.ac.in The steps for conversion from DNS to IP:
The DNS has to be converted to IP address before destination is reached.
This conversion is needed because computer understands only numbers.
The conversion is done with the help of name server.
As soon as domain name is provided, it will be sent across the internet to
contact name servers.
This name server is responsible for converting domain name to IP
If one of the name servers is not able to convert DNS to IP, it contacts
other name server.
2
This process continues until IP address is generated.
Once the IP address is generated, the host can be accessed.
The hostname and all domain names form what is known as FULLY
QUALIFIED DOMAIN NAME.
3
The Web is a collection of software and protocols that has been installed
on most, if not all, of the computers on the Internet (web bunches of
pages).
6) WEB BROWSERS
Client initiates the communication which requests for information stored
on server which sends back the information back to client from server.
Documents provided by servers on the Web are requested by browsers,
which are programs running on client machines.
They are called browsers because they allow the user to browse the
resources available on servers.
Mosaic was the first browser with a graphical user interface which was
text-based.
A browser is a client on the Web because it initiates the communication
with a server, which waits for a request from the client before doing
anything.
In the simplest case, a browser requests a static document from a server.
The server locates the document among its servable documents and sends
it to the browser, which displays it for the user.
Sometimes a browser directly requests the execution of a program stored
on the server. The output of the program is then returned to the browser.
Web supports variety of protocols .the most common one is HTTP
(hypertext transfer protocol). HTTP provides a standard form of
communications between browsers and web servers.
Examples: Internet Explorer, Mozilla Firefox, Netscape Navigator,
Google Chrome, Opera etc.,
7) WEB SERVERS
Web servers are programs that provide documents to requesting browsers.
Example: Apache, IIS (internet information server).
Web server operations:
Web browsers initiate network communications with servers by sending
them URL’s.
A URL can specify one of the two different things:
Address of data file stored on the server that is to be sent to client.
Program stored on server that the client wants executed, with o/p of
program returned to the client.
4
All the communications between a web client and a web server use the
HTTP.
When a web server begins execution, it informs the OS under which it is
running & it runs as a background process.
A web client or browser, opens a network connection to a web server,
sends information requests and possibly data to the server, receives
information from the server and closes the connection.
The primary task of web server is to monitor a communication port on
host machine, accept HTTP commands through that port and perform the
operations specified by the commands.
When the URL is received, it is translated into either a filename or a
program name.
General characteristics of web server:
The file structure of a web server has two separate directories.
The root of one of these is called document root which stores web
documents.
Ex:Your host may even have several folders nested inside each other,
one of which is the document root. In the example above the document
root was:
/www/
The root of the other directory is called the server root which stores
server and its support software’s. (give example)
The files stored directly in the document root are those available to clients
through top level URLs.
The secondary areas from which documents can be served are called
virtual document trees.
5
Many servers can support more than one site on a computer, potentially
reducing the cost of each site and making their maintenance more
convenient. Such secondary hosts are called virtual hosts.
Some servers can serve documents that are in the document root of other
machines on the web; in this case they are called as proxy servers.
Proxy server is a server (a computer system or an application) that acts
as an intermediary for requests from clients seeking resources from other
servers. A client connects to the proxy server, requesting some service,
such as a file, connection, web page available from a different server and
the proxy server gives the request.
8) Apache
6
Uniform Resource Locators (URLs) are used to identify different kinds of
resources on Internet.
If the web browser wants some document from web server, just giving
domain name is not sufficient because domain name can only be used for
locating the server.
It does not have information about which document client needs.
Therefore, URL should be provided.
The general format of URL is: scheme: object-address
Example: http: www.vtu.ac.in/results.php
The scheme indicates protocols being used. (http, ftp, telnet...)
In case of http, the full form of the object address of a URL is as follows:
//fully-qualified-domain-name/path-to-document
Another format is: file://path-to-document. Which focus on xhtml
documents. Hostname is the name of server computer that stores the
document. Message to host machine must be directed to appropriate
process running on host for handling.
Default port number of web server is 80. if the server has been configured
to use some other port number , its necessary to attach that port number to
he host name in the URL.
URLs can never have embedded spaces.
It cannot use special characters like semicolons, hash, ampersands
andcolons.(ex: https://www.google.co.in/?
gws_rd=ssl#q=web+hosting+services).
The path to the document for http protocol is a sequence of directory
names and a filename, all separated by whatever special character the OS
uses. (forward or backward slashes).
The path in a URL can differ from a path to a file because a URL need
not include all directories on the path.
A path that includes all directories along the way is called a complete
path.
7
Example: http://www.vtu.ac.in/index.html
In most cases, the path to the document is relative to some base path that
is specified in the configuration files of the server. Such paths are called
partial paths.
Example: http://www.jgi.ac.in/.
If the directory doesn’t have file that the server recognises home page, a
directory listing is constructed and returned to browser.
8
The header contains information about communication and body contains
data of communication.
Request Phase:
The general form of an HTTP request is as follows:
1. HTTP method Domain part of URL HTTP version
2. Header fields
3. Blank line
4. Message body
The following is an example of the first line of an HTTP request: GET
/storefront.html HTTP/1.1
The Host: host name request field gives the name of the host. The Host
field is required for HTTP 1.1.
9
The If-Modified-Since: date request field specifies that the requested file
should be sent only if it has been modified since the given date.
If the request has a body, the length of that body must be given with a
Content-length field. The header of a request must be followed by a blank
line, which is used to separate the header from the body of the request.
The Response Phase:
The general form of an HTTP response is as follows:
1. Status line
2. Response header fields
3. Blank line
4. Response body.
The status line includes the HTTP version used, a three-digit status code
for the response, and a short textual explanation of the status code. For
example, most responses begin with the following: HTTP/1.1 200 OK .
The status codes begin with 1, 2, 3, 4, or 5. The general meanings of the
five categories specified by these first digits are shown in Table 1.2. Table
1.2 First digits of HTTP status codes
One of the more common status codes is one user never want to see: 404
Not Found, which means the requested file could not be found.(example
refer notes).
HTTP Request Example:-
Common response fields: Content-length: 488, Content-type: text/html
- Can communicate with HTTP without a browser
- > telnet blanca.uccs.edu http
GET /respond.html HTTP/1.1
Host: blanca.uccs.edu
10
Note: Both request headers and response headers must be followed by a
blank line.
In http response version used is 1.1 and client requests to server and server
receives the request hence status is 200 ie, success. Last modified field informs
the client, the modified date and time of the data requested. Server used is
apache and message or document sent is of type text hence character encoding
is done. At the end when server receives page and sends back to client
connection closes.
13) SECURITY
Security is one of the major concerns in the Internet. The server system
can be accessed easily with basic hardware support, internet connection
& web browser.
The client can retrieve very important information from the server.
Similarly, the server system can introduce virus on the client system.
These viruses can destroy the hardware and software in client. While
programming the web, following requirements should be considered:
Privacy: it means message should be readable only to communicating
parties and not to intruder.
Integrity: it means message should not be modified during transmission.
Authentication: it means communicating parties must be able to know
each other’s identity
Non-repudiation: it means that it should be possible to prove that
message was sent and received properly. (give examples for all four).
The basic tool to support privacy and integrity is encryption. Data to be
transmitted is converted or encrypted into different form, which is
impossible to decrypt for someone who cannot access data.
In public key encryption, a public key and private key are used, the public
key to encrypt messages and private key to decrypt. Example Alice and
bob want to share their communication.
Firstly, Alice sends the message which will be encrypted using public key
and sent to Bob. Bob on receiving end will decrypt the message using
private key to get the original message.
Widely used public key algo is RSA.
Another security problem for web is deliberate destruction of information
on computers attached to internet. It can be due to when a document is
downloaded from internet.
Common virus is codeRed virus.
Security can be provided using cryptographic algorithm. Ex: private key,
public key Protection against viruses and worms is provided by antivirus
11
software, which must be updated frequently so that it can detect and
protect against the continuous stream of new viruses and worms.
12
Ruby is a relatively recent object-oriented scripting language that is
introduced here primarily because of its use in Rails, a Web applications
framework.
Rails provides a significant part of the code required to build Web
applications that access databases, allowing the developer to spend his or
her time on the specifics of the application without the drudgery of
dealing with all of the housekeeping details.
XHTML
• To describe the general form and layout of documents.
• XHTML document is a mix of content and controls.
• Controls are tags and their attributes.
• Tags often delimit content and specify something about how the content
should be arranged in the document.
• Attributes provide additional information about the content of a tag.
Creating XHTML Documents
• XHTML editors - make document creation easier.
• Shortcuts to typing tag names, spell-checker.
• WYSIWYG (what you see is what you get) XHTML editors.
• Need not know XHTML to create XHTML documents.
Plugins and Filters
• Plug ins Integrated into tools like word processors, effectively converting them
to WYSIWYG XHTML editors.
• Filters Convert documents in other formats to XHTML.
• Advantages of both filters and plug-ins:
• Existing documents produced with other tools can be converted to XHTML
documents.
• Use a tool you already know to produce XHTML.
• Disadvantages of both filters and plug-ins:
• XHTML output of both is not perfect - must be fine tuned.
• XHTML may be non-standard.
• You have 2 versions of the doc: difficult to synchronize.
XML
• A meta-markup language.
• Used to create a new markup language for a particular purpose or area.
• Because the tags are designed for a specific area, they can be meaningful.
• No presentation details.
• A simple and universal way of representing data of any textual kind
JavaScript
• A client-side HTML-embedded scripting language.
• Only related to Java through syntax.
• Dynamically typed and not object-oriented.
13
• Provides a way to access elements of HTML documents and dynamically
change them.
Java
• General purpose object-oriented programming language.
• Based on C++, but simpler and safer.
Running a server programs on web server to provide computational
capability, special kind of programApplet, it resides on server but
compiled and downloaded to browser when requested by Xhtml
document being displayed by browser.
Server side scripting language can make use of.
Web interaction that occurs on server and accessing server resident
databases are called Servlets.
• Our focus is on applets, servlets, and JSP.
Perl
• Provides server-side computation for HTML documents, through CGI
• Perl is good for CGI programming because:
• Direct access to operating systems functions
• Powerful character string pattern-matching operations
• Access to database systems
• Perl is highly platform independent.
PHP
• A server-side scripting language
• An alternative to CGI
• Similar to JavaScript
• Great for form processing and database access through the Web.
Rails
Framework for web based applications that access databases.
ASP.net is also development framework for web based applications.
Makes use of Model-view-controller.
A controller can send commands to the model to update the model's state
(e.g., editing a document). It can also send commands to its associated
view to change the view's presentation of the model (e.g., by scrolling
through a document).(program logic).
A model stores data that is retrieved to the controller and displayed in the
view. Whenever there is a change to the data it is updated by the
controller.(databases)
A view requests information from the controller. The controller fetches it
from the model and passes it to the view that the view uses to generate an
output representation to the user.(presentation)
Tightly bound with relational databases.
Ajax
14
Asynchronous javascript+xml.
Traditional web interaction, client sends message to server. When the
server receives document or message from client, client waits until
server responds back the client. Client has to wait until he/she receives
the document from server and then if needed can process with next
document.
In AJAX web application, firstly, communication from browser to
server is asynchronous. Ie, browser need not wait for the server to
respond, browser can continue whatever he/she was doing while server
finds and transmits the requested document. Also, document provided
by server is a small part of display document and hence takes less time
to transmit and render.
The x in AJAX is XML as data supplied by server will be in form of
xml document that provides new data to be placed in displayed
document.
Aim of AJAX is to have web-based application in terms of speed
interaction as well as user experience.
Chapter 2 XHTML
1) BASIC SYNTAX
The fundamental syntactic units of HTML are called tags.
15
In general, tags are used to specify categories of content.
The syntax of a tag is the tag’s name surrounded by angle brackets (< and
>).
Tag names must be written in all lowercase letters.
Most tags appear in pairs: an opening tag and a closing tag.
The name of a closing tag is the name of its corresponding opening tag
with a slash attached to the beginning. For example, if the tag’s name is p,
the corresponding closing tag is named /p.
Whatever appears between a tag and its closing tag is the content of the
tag. Not all tags can have content.
The opening tag and its closing tag together specify a container for the
content they enclose.
The container and its content together are called an element.
Example: <p> This is Web Programming Notes. </p>
The paragraph tag, <p>, marks the beginning of the content; the </p> tag
marks the end of the content of the paragraph element.
Attributes, which are used to specify alternative meanings of a tag, can
appear between an opening tag’s name and its right angle bracket.
They are specified in keyword form, which means that the attribute’s
name is followed by an equal’s sign and the attribute’s value.
Attribute names, like tag names, are written in lowercase letters.
Attribute values must be delimited by double quotes.
Comments in programs increase the readability of those programs.
Comments in XHTML have the same purpose. They can appear in
XHTML in the following form:
<!-- anything except two adjacent dashes -->
Browsers ignore XHTML comments—they are for people only.
Comments can be spread over as many lines as are needed. For example,
you could have the following comment:
<!-- CopyRights.html This notes is prepared by Sahana Shetty of
ISE-->
16
replace the existing character sets with its standard Unicode
Transformation Format (UTF).
The Unicode Standard has become a success and is implemented in
HTML, XML, Java, JavaScript, E-mail, ASP, PHP, etc. The Unicode
standard is also supported in many operating systems and all modern
browsers.
Xml version 1.0 because its simple to understand.
The xml declaration usually includes a second attribute, encoding, which
specifies the encoding used for the document [utf-8].
Following is the xml declaration element, which should be the first line of
every XHTML document:
<?xml version = "1.0" encoding = "utf-8"?>
Note that this declaration must begin in the first character position of the
document file.
The xml declaration element is followed immediately by an SGML
DOCTYPE command, which specifies the particular SGML document-
type definition (DTD) with which the document complies, among other
things.
The !DOCTYPE declaration must be the very first thing in your HTML
document, before the <html> tag.
The !DOCTYPE declaration is not an HTML tag; it is an instruction to
the web browser about what version of HTML the page is written in.
XHTML DOCTYPE is mandatory
The xmlns attribute in <html> is mandatory
<html>, <head>, <title>, and <body> are mandatory.
Public because any one can use such kind of document.(for public use).
ENenglish language; W3c The World Wide Web Consortium (W3C)
is the main international standards organization for the World Wide Web
to provide some goal. DTDA Document Type Definition (DTD)
defines the structure or rules and the legal elements and attributes of an
XML document.
A DTD can be declared inside an XML document or in an external file.
DTD contains some standards for defining an document(tags and
attributes).
The following command states that the document in which it is included
complies with the XHTML 1.0 Strict standard:
17
An XHTML document must include the four tags <html>, <head>, <title>, and
<body>.
The <html> tag identifies the root element of the document. So, XHTML
documents always have an <html> tag immediately following the
DOCTYPE command, and they always end with the closing html tag,
</html>.
The html element includes an attribute, xmlns, that specifies the XHTML
namespace, as shown in the following element:
18
Note: it’s mandatory to use first three lines of code. And explain the tag
examples.
4) Paragraphs:
It begins with <p> and ends with </p>. Multiple paragraphs may appear in a
single document.
<html>
<head>
<title> Paragraph </title>
</head>
<body>
<p> Paragraph 1 </p>
<p> Paragraph 2 </p>
<p> Paragraph 3 </p>
</body>
</html>
5) Line Breaks:
When the content of paragraph element displayed other than at beginning
of line, browser breaks the current line and inserts blank line.
The break tag is specified as <br />.
The slash indicates that the tag is both an opening and closing tag.
19
6) Preserving White Space
Sometimes it is desirable to preserve the white space in text—that is, to
prevent the browser from eliminating multiple spaces and ignoring
embedded line breaks. This can be specified with the <pre> tag.
7) Headings
There are 6 levels of headings specified by tags:<h1>-<h6>
<h1> highest leve; heading.
Headings are displayed in bold face font
Some browsers <h1>, <h2>, and <h3> use font sizes that are larger than
that of the default size of text,
<h4> uses the default size, and <h5> and <h6> use smaller sizes. The
heading tags always break the current line, so their content always
appears on a new line. Browsers usually insert some vertical space before
and after all headings.
8) Block Quotations
If we want block of text to be set off from normal flow of text in
document we use block quotation.
The <blockquote> tag is used to make the contents look different from
the surrounding text.
Block quotation of text is indented either on left or right side or both.
Another possibility is block can be set to italics.
20
9) Font Styles and Sizes:
<b>, <i> and <u> specifies bold, italics and underline respectively.
The emphasis tag, <em>, specifies that its textual content is special and
should be displayed in some way that indicates this distinctiveness. Most
browsers use italics for such content.
The strong tag, <strong> is like the emphasis tag, but more so. Browsers
often set the content of strong elements in bold.
The code tag, <code>, is used to specify a monospace font, usually for
program code.
Ex: cost = Quantity*price.
Subscript and superscript characters can be specified using <sub> &
<sup> tags.
21
Xhtml tags are categorized as block or inline. The content of inline tag
appears on current line.
So inline tag doesnot implicitly include line break.
Block tags are heading and blockquote whereas <em> and <strong> are
inlin tags.
Block tags in xhtml cannot appear in content of inline tags. Similarly,
inline tags and text cannot be directly nested in body or form elements.
22
11) Horizontal Rules:
The parts of a document can be separated from each other, making the
document easier to read, by placing horizontal lines between them.
Such lines are called horizontal rules. The block tag that creates them is
<hr />.
The <hr /> tag causes a line break (ending the current line) and places a
line across the screen.
Note again the slash in the <hr /> tag, indicating that this tag has no
content and no closing tag.
23
The meta element is used to provide additional information about a
document.
The meta tag has no content; rather, all of the information provided is
specified with attributes.
The two attributes that are used to provide information are name and
content.
The user makes up a name as the value of the name attribute and specifies
information through the content attribute. One commonly chosen name is
keywords; the value of the content attribute associated with the keywords
are those which the author of a document believes characterizes his or her
document.
An example is <meta name = "Title" content = "Programming the
Web" /> <meta name = "Author" content = "Sahana" />
Web search engines use the information provided with the meta element
to categorize Web documents in their indices.
Metadata will not be displayed on the page, but will be machine parsable.
Meta elements are typically used to specify page description, keywords,
author of the document, last modified, and other metadata.
The metadata can be used by browsers (how to display content or reload
page), search engines (keywords), or other web services.
13) Images
Image can be displayed on the web page using <img> tag.
The most common methods of representing images are graphical
interchange format and Jpeg format.
Files in both of these formats are compressed to reduce storage needs and
provide quicker transfer over internet.
24
The GIF format s specific purpose is in moving of images.
It uses 8 bit color representation for pixels allowing pixel to have 256
different colors.
Files containing GIF images use .gif extension on their names. It can be
made to appear transparent.
The JPEG format uses 24 bit color representation for pixels which allows
JPEG images to include more than 16 million different colors.
Files stored in .jpeg extension format.
This compression process loses some of the color accuracy of the image.
Disadvantages of JPEG is that it doesn’t support transparency.
Next is portable network graphics(PNG).
Provides good replacement for JPEG and GIF because it has best
chacteristics of both.
One disadvantage is that compression algorithm doesnot sacrifice picture
clarity, ie, its image requires more space than comparable JPEG images.
When the <img> tag is used, it should also be mentioned which
image needs to be displayed. This is done using src attribute.
Attribute means extra information given to the browser
Whenever <img> tag is used, alt attribute is also used.
Alt stands for alert.
Some very old browsers would not be having the capacity to
display the images.
In this case, whatever is the message given to alt attribute, that
would be displayed.
Another use of alt is :
when image display option has been disabled by user. The option is
normally disabled when the size of the image is huge and takes
time for downloading.
The src attribute specifies the URL (web address) of the image:
<img src="url" alt="some_text">
The alt attribute specifies an alternate text for an image, if the image
cannot be displayed.
The alt attribute provides alternative information for an image if a user
for some reason cannot view it (because of slow connection, an error in
the src attribute, or if the user uses a screen reader).
<html>
<head>
<title>display image</title>
</head> <body>
<img src="java.png" alt="cannot display"/>
25
</body>
</html>
Example:
<img src=”abc.jpg” alt= “” height=”120” width=”180” align= left
border=”2” hspace=”10” vspace=”10”/>
26
Output:
Links:
27
Hyperlinks are the mechanism which allows the navigation from one page to
another.
The href attribute specifies the destination address
(http://www.w3schools.com/html/).The link text is the visible part.
The term “hyper” means beyond and “link” means connection. Whichever text
helps in navigation is called hypertext.
Hyperlinks cam be created using <a> (anchor tag)
The attribute that should be used for <a> is href .
Note: explaination refer textbook
Link.html
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml1-strict.dtd"> <!-- complete.html A
document which must be followed throughout the notes -->
<html xmlns = "http://www.w3.org/1999/xhtml"> <head>
<title> My first program </title>
</head>
<body>
<a href = "linnk.html"> CLICK HERE </a>
</body>
</html>
Program: link.html Now, execute “linnk.html” file, you will get aftr we click on
CLICK HERE link we will be navigating to link.html.
linnk.html
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml1-strict.dtd">
<!-- complete.html A document which must be followed throughout the notes
-->
<html xmlns = "http://www.w3.org/1999/xhtml"> <head>
<title> My first program </title>
</head>
<body>
hello world...
</body>
</html>
After clicking on the above text, we can navigate to another page “link.html” as
shown below
28
If the target of a link is not at the beginning of a document, it must be
some element within the document, in which case there must be some
means of specifying it.
The target element can include an id attribute, which can then be
used to identify it in an href attribute. (observe the scroll bar in the
outputs given).
Target Value Description
_self Opens the linked document in the same frame as it was clicked (this is
_top Opens the linked document in the full body of the window
<html>
<head>
<title> target link</title>
</head>
<body>
<h1> Puneeth Rajkumar </h1>
<a href = "#bottom"> Click Here For His Autobiography </a> <p><pre>
Appu Abhi Veera Kannadiga Maurya Akaash Namma Basava Ajay Arasu
Milana Bindaas Vamshi Raaj Raam Prithvi Jackie Hudugaru Paramathma
Anna Bond
</pre></p>
<h2> AutoBiography </h2>
<p id = "bottom"> <pre> Puneeth Rajkumar was born on 17th of March,
1975. His father Dr. Rajkumar is the Legend of Kannada Film Industry. His
mother is Smt. Parvathamma Rajkumar who is a renowned producer in the
industry. His brothers ShivaRajkumar and RaghavendraRajkumar are very
popular heroes. He is married to Smt. Ashwini Revnath He has two
daughters namely Dhrithi and Vanditha.. At present, Puneeth is the greatest
star of Kannada Film Industry. </pre>
</p>
</body>
29
</html>
here we are not creating two separate files, but we are specifying a target
within the same document itself. If you click on the above link, you will
be redirected to the bottom of the page which contains Autobiography of
Puneeth Rajkumar. This is useful for lengthy documents like e-
newspaper, e-magazine etc.,
16) LISTS
Ordered unordered and definition lists
Unordered Lists:
The <ul> tag, which is a block tag, creates an unordered list. Each
item in a list is specified with an <li> tag (li is an acronym for list
item).
Any tags can appear in a list item, including nested lists. When
displayed, each list item is implicitly preceded by a bullet.
30
<!DOCTYPE html>
<html>
<body>
<h2>Unordered List with Default Bullets</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
Output:
Ordered Lists:
31
of bullets.
Nested Lists:
<html>
<head>
<title> nested lists </title>
</head>
<ol>
<li> Information Science
</li>
<ol>
<li>OOMD</li>
<li>Java & J2ee</li>
<ul>
<li>classes and methods</li>
<li>exceptions</li>
<li>applets</li>
<li>servelets</li>
</ul>
<li>Computer Networks</li>
<ul> <li>Part 1</li>
<li>Part 2</li>
</ul>
<li>DBMS</li>
<li>Operations Research</li>
</ol>
<li> Computer Science</li>
32
<ol>
<li>Compiler Design</li>
<li>FLAT</li>
<ul>
<li>NFA</li>
<li>DFA</li>
<li>CFG</li>
</ul>
<li>Computer Graphics</li>
<li>Artificial Intelligence</li>
</ol>
</ol>
</html>
O/p:
Nested Lists:
1. Information Science
1. OOMD
2. Java & J2ee
classes and methods
exceptions
applets
servelets
3. Computer Networks
Part 1
Part 2
4. DBMS
5. Operations Research
2. Computer Science
1. Compiler Design
2. FLAT
NFA
DFA
CFG
3. Computer Graphics
4. Artificial Intelligence
--Definition Lists:
As the name implies, definition lists are used to specify lists of terms and
their definitions, as in glossaries.
A definition list is given as the content of a <dl> tag, which is a block tag.
Each term to be defined in the definition list is given as the content of a
<dt> tag.
The definitions themselves are specified as the content of <dd> tags.
33
The defined terms of a definition list are usually displayed in the left
margin; the definitions are usually shown indented on the line or lines
following the term.
<!DOCTYPE html>
<html>
<body>
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
</body>
</html>
Output:
Coffee
Black hot drink
Milk
White cold drink
17) TABLES
A table is a matrix of cells.
The cells in the top row often contain column labels, those in the
leftmost column often contain row labels, and most of the rest of the
cells contain the data of the table. The content of a cell can be almost any
document element, including text, a heading, a horizontal rule, an image,
and a nested table.
Basic Table Tags:
A table is specified as the content of the block tag <table>.
There are two kinds of lines in tables: the line around the outside of the
whole table is called the border; the lines that separate the cells from each
other are called rules.
It can be obtained using border attribute. The possible values are
“border” or any number. <table border=”3”>
The table heading can be created using <caption> tag.
The table row can be created using <tr> tag.
The column can be created either by using <th> tag (stands for table
header which is suitable for headings) or <td> tag (stands for table data
which is suitable for other data).
34
<caption> element to define a table caption.
35
Table with heading
<!-- e2_10.html
A solution to Exercise 2.10 - a simple table
-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> A simple table </title>
</head>
<body>
<table border = "border">
<caption> Tree Characteristics </caption>
36
<tr>
<td rowspan = "2" colspan = "2"> </td>
<th colspan = "4"> Tree </th>
</tr>
<tr>
<th> Pine </th>
<th> Maple </th>
<th> Oak </th>
<th> Fir </th>
</tr>
<tr>
<th rowspan = "4"> Characteristic </th>
<th> Average Height (feet) </th>
<td> 55 </td>
<td> 50 </td>
<td> 50 </td>
<td> 65 </td>
</tr>
<tr>
<th> Average Width (inches) </th>
<td> 18 </td>
<td> 26 </td>
<td> 24 </td>
<td> 28 </td>
</tr>
<tr>
<th> Typical Lifespan (years) </th>
<td> 150 </td>
<td> 230 </td>
<td> 310 </td>
<td> 135 </td>
</tr>
<tr>
<th> Leaf Type </th>
<td> Long needles </td>
<td> Broadleaf </td>
<td> Split leaf </td>
<td> Short needles </td>
</tr>
</table>
</body>
</html>
37
Output:
Tree Characteristics
Tree
Pine Maple Oak Fir
Average Height
55 50 50 65
(feet)
Average Width
18 26 24 28
(inches)
Characteristic
Typical Lifespan
150 230 310 135
(years)
Long Split Short
Leaf Type Broadleaf
needles leaf needles
<html> <head> <title> Align and valign </title> </head> <body> <p>Table
having entries with different alignments</p>
<table border="border">
<tr align = "center">
<th> </th>
<th> aa </th>
<th> sneha</th>
<th> K </th>
</tr>
<tr>
<th> Ramya </th>
<td align = "left"> Akaash </td>
<td align = "center"> Datta </td>
<td align = "right"> Ra </td>
</tr>
<tr>
<th> <br/>Rakshitha <br/><br/><br/>
</th>
38
<td> sahana </td>
<td valign = "top">athiya </td> <td valign = "bottom"> arnav </td>
</tr>
</table>
</body>
</html>
o/p:
aa sneha K
Ramya Akaash Datta Ra
athiya
Rakshitha sahana
arnav
-- The cellpadding and cellspacing Attribute:
Output:-
39
Table with space = 10, pad = 50
sneha sahana
sneha sahana
Table Sections:
Tables naturally occur in two and sometimes three parts: header, body, and
footer. (Not all tables have a natural footer.) These three parts can be
respectively denoted in XHTML with the thead, tbody, and tfoot elements.
The header includes the column labels, regardless of the number of levels in
those labels. The body includes the data of the table, including the row
labels. The footer, when it appears, sometimes has the column labels
repeated after the body. In some tables, the footer contains totals for the
columns of data above. A table can have multiple body sections, in which
case the browser may delimit them with horizontal lines that are thicker than
the rule lines within a body section.
18) Forms:
The most common way for a user to communicate information from a
Web browser to the server is through a form.
XHTML provides tags to generate the commonly used objects on a screen
form. These objects are called controls or widgets.
There are controls for single-line and multiple-line text collection,
checkboxes, radio buttons, and menus, among others.
All control tags are inline tags.
40
The <input> Tag:
Many of the commonly used controls are specified with the inline
tag <input>, including those for text, passwords, checkboxes, radio
buttons, and the action buttons Reset, Submit, and plain.
Text Box
It is a type of input which takes the text.
Any type of input can be created using <input>
The type attribute indicates what type of input is needed for the text
box, the value should be given as text.
For any type of input, a name has to be provided which is done
using name attribute.
The size of the text can be controlled using size attribute.
Every browser has a limit on the number of characters it can
collect. If this limit is exceeded, the extra characters are chopped
off. To prevent this chopping, maxlength attribute can be used.
When maxlength is used, users can enter only those many
characters that is given as a value to the attribute.
Single-line text input controls
Password-input controls
Multi-line text input controls.
41
<p> <label>Enter the email id: <input type = "text" name = "myname" size =
"24" maxlength = "25" />
</label> </p>
<p>
<label>Enter the password: <input type = "password" name = "mypass" size
= "20" maxlength = "20" /> </label>
</p>
</form>
Radio Button
o Radio buttons are special type of buttons which allows the
user to select only individual option
o Radio buttons are created using the input tag with the type
attribute having the value radio.
o When radio buttons are created, values must be provided
with the help of value attribute.
o All the radio buttons which are created would have same
name. This is because the radio buttons are group elements.
o If one of the radio buttons has to be selected as soon as the
web page is loaded, checked attribute should be used. The
value also would be checked.
Check Box
Check box is a type of input using which multiple options can be
selected.
Check box can also be created using the <input> tag with the type having
the value “checkbox”.
During the creation of check box, the value should be provided using the
value attribute.
All the checkbox which are created would have the same name because
they are group elements.
If one of the check box have to be selected as soon as the page is loaded,
checked attribute should be used with the value checked.
42
<form action = " ">
<p> <label><input type="checkbox" name="act"
value="one"/>parneetha</label>
<label><input type="checkbox" name="act" value="two"/>shraddha</label>
43
<option value=”desktop”>desktop computer</option>
<option value=”laptop”>laptop computer</option>
<optgroup disabled=”disabled” value=””>--software--</option>
<option value=”officesoftware”> officesoftware </option>
<option value=”GAMES”> GAMES </option>
</select>
44
The purpose of such a server-resident program is to process the form data
and return some response to the user. Every form requires a Submit
button.
The Submit and Reset buttons are created with the <input> tag.
Image button:
<input type=”image” src=”ab.jpg” alt=”submit” name=”btnimg” />
<form action=" ">
<p>
<input type="SUBMIT" value="SUBMIT"/>
<input type="RESET" value="RESET"/>
</p>
</form>
Output:
45
<head>
<title> CompleteForm</title>
</head>
<body>
<h1>Registration Form</h1>
<form action=" ">
<p>
<label>Enter your email id: <input type = "text" name = "myname" size = "24"
maxlength = "25" /> </label>
</p>
<p>
<label>Enter the password: <input type = "password" name = "mypass" size =
"20" maxlength = "20" />
</label>
</p>
<p>Gender</p>
<p> <label><input type="radio" name="act" value="one"/>Male</label>
<label><input type="radio" name="act" value="two"/>Female</label> </p>
<p>Which of the following Accounts do you have?</p>
<p> <label><input type="checkbox" name="act" value="one"/>Gmail</label>
46
19) FRAMES
The browser window can be used to display more than one document at a
time. The window can be divided into rectangular areas, each of which is
a frame. Each frame is capable of displaying its own document.
Framesets:
The number of frames and their layout in the browser window are
specified with the <frameset> tag.
A frameset element takes the place of the body element in a
document. A document has either a body or a frameset but cannot
have both.
The <frameset> tag must have either a rows or a cols attribute. (or
both)
To create horizontal frames, rows attribute is used.
To create vertical frames, cols attribute is used.
The values for these attributes can be numbers, percentages and
asterisks.
<frameset row= “200,300,400”> or
<frameset row= “22%,33%,45%”>or can be written as
<frameset row= “200,300,*”>
Two or more values are separated by commas & given in quoted
string. (refer text)
To Demonstrate using rows Attribute and col attribute <html> <?xml
version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
47
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- frames.html
An example to illustrate frames
-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head> <title> Frames </title>
</head>
<frameset rows = "20%,20%,20%" cols = "25%,*">
<frame src = "Ex13.html" />
<frame src = "Ex2.html" name = "Links" />
</frameset>
</html>
Ex13.html
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- checkbox.html
An example to illustrate a checkbox
-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head> <title> Select </title>
</head>
<body>
<p>
Grocery menu-milk,bread,eggs,cheese
</p>
<form action = "">
<p>
with size = 1 (the default)
<select name="groceries">
<option> milk </option>
<option> bread </option>
<option> eggs </option>
<option> cheese </option>
</p>
</form>
</body>
</html>
Ex2.html
<?xml version = "1.0" encoding = "utf-8"?>
48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- e2_3.html
This is a solution to Exercise 2.3
-->
o/p:
49
20) SYNTACTIC DIFFERENCES BETWEEN HTML AND XHTML
PARAMETERS HTML XHTML
Case Sensitivity Tags and attributes names Tags and attributes names
are case insensitive. must be in lowercase
Closing tags Closing tags may be omitted. All elements must have
<p>aaaaa closing tag
<p>hhhhh <input type=”text”
name=”add”></input>
Quoted attribute values Special characters are All attribute values must be
quoted. Numeric values are quoted including numbers
rarely quoted. <table border=”border”>
Border should be
compulsorly quoted
Explicit attribute values Some attribute values are All attribute values must be
implicit. For example: <table explicitly stated
border>. A default value for <table border=”border”>
border is assumed It is compulsory to give
value for attribute explicitly.
id and name attributes Both id and name attributes Use of id is encouraged and
are encouraged use of name is discouraged
Element nesting Rules against improper All nesting rules are strictly
nesting of elements (for enforced
example: a form element
cannot contain another form
element) are not enforced.
Character entities:
" ”
& &
< <
> >
50
Linking to E-mail address:
When you click on link that shows an email address, which is ready to send an
mail to that address.
<a href =mailto:[email protected]>[email protected] </a>
HTML HTML5
Doctype declaration in Html is too longer
DOCTYPE declaration in Html5
<!DOCTYPE HTML PUBLIC
is very simple "<!DOCTYPE
"-//W3C//DTD HTML 4.01//EN"
html>
"http://www.w3.org/TR/html4/strict.dtd">
character encoding in Html is also longer
character encoding (charset)
<!DOCTYPE HTML PUBLIC
declaration is also very simple
"-//W3C//DTD HTML 4.0
<meta charset="UTF-8">
Transitional//EN">
Audio and Videos are integral
Audio and Video are not part of HTML4 part of HTML5 e.g. <audio> and
<video> tags.
Vector Graphics is possible with the help
Vector graphics is integral part of
of technologies such as VML, Silverlight,
HTML5 e.g. SVG and canvas
Flash etc
It is almost impossible to get true JS GeoLocation API in HTML5
GeoLocation of user browsing any helps identify location of user
website especially if it comes to mobile browsing any website (provided
devices. user allows it)
It provides local storage in place
Html5 use cookies.
of cookies.
Not possible to draw shapes like circle, Using Html5 you can draw
51
shapes like circle, rectangle,
rectangle, triangle.
triangle.
Does not allow JavaScript to run in Allows JavaScript to run in
browser. JS runs in same thread as background. This is possible due
browser interface. to JS Web worker API in HTML5
<article>
The HTML <article> element represents a self-contained composition in a
document, page, application, or site, which is intended to be independently
distributable or reusable (e.g., in syndication). Examples include: a forum post,
a magazine or newspaper article, or a blog entry.
<article class="film_review">
<header>
<h2>Jurassic Park</h2>
</header>
<section class="main_review">
<p>Dinos were great!</p>
</section>
<section class="user_reviews">
<article class="user_review">
<p>Way too scary for me.</p>
<footer>
<p>
Posted on
<time datetime="2015-05-16 19:00">May 16</time>
by Lisa.
</p>
</footer>
</article>
<article class="user_review">
<p>I agree, dinos are my favorite.</p>
<footer>
<p>
Posted on
<time datetime="2015-05-17 19:00">May 17</time>
by Tom.
</p>
</footer>
</article>
</section>
<footer>
52
<p>
Posted on
<time datetime="2015-05-15 19:00">May 15</time>
by Staff.
</p>
</footer>
</article>
<section>
<aside>
The HTML <aside> element represents a section of a document with content
connected tangentially to the main content of the document (often presented as a
sidebar).
<article>
<p>
The Disney movie <em>The Little Mermaid</em> was
first released to theatres in 1989.
</p>
<aside>
<p>
The movie earned $87 million during its initial release.
</p>
</aside>
<p>
More info about the movie...
</p>
</article>
<header>
The HTML <header> element represents a group of introductory or
navigational aids. It may contain some heading elements but also other elements
like a logo, a search form, and so on.
<header>
<h1>Main Page Title</h1>
<img src="mdn-logo-sm.png" alt="MDN logo">
53
</header>
<footer>
The HTML <footer> element represents a footer for its nearest sectioning
content or sectioning root element. A footer typically contains information about
the author of the section, copyright data or links to related documents.
<footer>
Some copyright info or perhaps some author
info for an <article>?
</footer>
<datalist>
<datalist> tag specifies set of options for <input> element.
<!DOCTYPE html>
<html>
<head>
<title>HTML Datalist Tag</title>
</head>
<body>
<input list = "tutorials" />
<datalist id = "tutorials">
<option value = "Java">
<option value = "ASP">
<option value = "PHP">
<option value = "Ruby">
<option value = "jQuery">
</datalist>
</body>
</html>
<audio>,<video>
HTML5 features, include native audio and video support without the need for
Flash.
The HTML5 <audio> and <video> tags make it simple to add media to a
website. You need to set
src
attribute to identify the media source and include a controls attribute so the user
can play and
pause the media.
Embedding Video
54
Here is the simplest form of embedding a video file in your webpage −
<video
src
=
"foo.mp4"
width
=
"300"
height
=
"200"
controls
>
Your browser does not support the
<video>
element.
</video>
The current HTML5 draft specification does not specify which video formats
browsers should
support in the video tag. But most commonly used video formats are −
Ogg
− Ogg files with Thedora video codec and Vorbis audio codec.
mpeg4
− MPEG4 files with H.264 video codec and AAC audio codec.
You can use <source> tag to specify media along with media type and many
other attributes. A
video element allows multiple source elements and browser will use the first
recognized format −
<!DOCTYPE HTML>
<html>
<body>
<video
width
=
"300"
height
=
"200"
controls
autoplay
>
<source
src
55
=
"/html5/foo.ogg"
type
=
"video/ogg"
/>
<source
src
=
"/html5/foo.mp4"
type
=
"video/mp4"
/>
Your browser does not support the video element.
</video>
</body>
</html>
This will produce following result −
Video Attribute Specification
autoplay This boolean attribute if specified,
the video will automatically begin
to play back as soon as it can do so
without stopping to finish loading
the data.
autobuffer This boolean attribute if specified,
the video will automatically begin
buffering even if it's not set to
automatically play.
controls If this attribute is present, it will
allow the user to control video
playback, including volume,
seeking, and pause/resume
playback.
height This attribute specifies the height of
the video's display area, in CSS
pixels.
loop This boolean attribute if specified,
will allow video automatically seek
back to the start after reaching at
the end.
poster This is a URL of an image to show
until the user plays or seeks.
56
src The URL of the video to embed.
This is optional; you may instead
use the <source>
preload This attribute specifies that the
video will be loaded at page load,
and ready to run.
Embedding Audio
HTML5 supports
<audio> tag which is used to embed sound content in an HTML or XHTML
document as follows.
<audio
src
=
"foo.wav"
controls
autoplay
>
Your browser does not support the
<audio>
element.
</audio>
The current HTML5 draft specification does not specify which audio formats
browsers should
support in the audio tag. But most commonly used audio formats are
ogg, mp3
and
wav
.
You can use <source> tag to specify media along with media type and many
other attributes. An
audio element allows multiple source elements and browser will use the first
recognized format −
<!DOCTYPE HTML>
<html>
<body>
<audio
controls
autoplay
>
<source
src
=
57
"/html5/audio.ogg"
type
=
"audio/ogg"
/>
<source
src
=
"/html5/audio.wav"
type
=
"audio/wav"
/>
Your browser does not support the audio element.
</audio>
</body>
</html>
autoplay This boolean attribute if specified,
the audio will automatically begin
to play back as soon as it can do so
without stopping to finish loading
the data.
autobuffer This boolean attribute if specified,
the audio will automatically begin
buffering even if it's not set to
automatically play.
controls If this attribute is present, it will
allow the user to control audio
playback, including volume,
seeking, and pause/resume
playback.
loop This boolean attribute if specified,
will allow audio automatically seek
back to the start after reaching at
the end.
preload This attribute specifies that the
audio will be loaded at page load,
and ready to run.
58