Notes Web Technologies
Notes Web Technologies
1
INTERNET AND WORLD WIDE WEB
Unit Structure :
1.0 Objective
1.1 Introduction to internet and its applications.
1.1.1 Email
1.1.2 Telnet
1.1.3 FTP
1.1.4 E–commerce
1.1.5 Video conferencing
1.1.6 E business.
1.2 Internet service providers
1.3 Domain name servers
1.4 Internet address
1.5 World wide web and its evolution
1.6 URL
1.7 Browsers
1.7.1 Internet explorer,
1.7.2 Netscape navigator,
1.7.3 opera,
1.7.4 fire fox,
1.7.5 chrome,
1.7.6 Mozilla,
1.8 Search Engine
1.9 Web server
1.9.1 Apache
1.9.2 IIS
1.9.3 Proxy Server
1.10 HTTP protocol.
1.11 Summery
1.12 Unit End exercise
1.0 OBJECTIVE:
Internet is ---
A computer network consisting of a worldwide network of computers
that use the TCP/IP network protocols to facilitate data transmission
and exchange.
The Internet is a global system of interconnected computer networks
that use the standard Internet Protocol Suite (TCP/IP) to serve billions
of users worldwide.
The term Internet actually refers to the combined collection of
academic, commercial, and government networks connected over
international telecommunication backbones and routed using IP
addressing.
2
Email message body contains text (7bit ASCII) as well as multimedia
messages. These processes are declared in Multipurpose Internet Mail
Extensions (MIME). MIME is set of RFCs (Request for Comment)
Network based emails are exchanged over the internet using the SMTP
(Simple Mail Transfer protocol).
In the process of transporting email messages between systems, SMTP
communicates delivery parameters using a message envelope separate
from the message (header and body)itself.
Email addresses (both for senders and recipients) are two strings
separated by the character "@" (the "at sign"): such as user@domain
The right-hand part describes the domain name involved, and the left-
hand part refers to the user who belongs to that domain.
An email address can be up to 255 characters long and can include the
following characters:
Lowercase letters from a toz;
Digits
The characters ".","_" and "-" (full stop, underscore, and hyphen)
1.1.2 Telnet
3
Data transferred over telnet is vulnerable as telnet does not use any
encryption technique to mask or protect the data.
Most implementations of Telnet have no authentication that would
ensure communication is carried out between the two desired hosts and
not intercepted in the middle.
Commonly used Telnet daemons have several vulnerabilities
discovered over the years.
Extensions to the Telnet protocol provide Transport Layer Security
(TLS) security and Simple Authentication and Security Layer (SASL)
authentication that address the above issues.
Few applications of telnet include the ‘putty’ TCP client which can
access a linux server using windows operating system, Absolute telnet
(windows client) and RUMBA (terminal emulator).
1.1.3 FTP
File transfer protocol is a simple and standard network protocols that
transfers a file from one host to the other over a TCP network.
Based on client server architecture.
Utilizes separate control and data connection for client and server to
transmit and receive file(s) over the network.
It is an application protocol that uses the internet’s TCP/IP suite.
Mainly used to transfer the web pages or related data from the source
or creator to a host that acts as a server to make the page or file
available to other hosts (uploading) or downloading programs and
other files from server to a host.
FTP protocol can perform over a active or passive connection.
When a connection is made from the client to server, it is called as
control connection and it remains open for duration of session. This
connection is responsible for establishing connectivity between client
and server.
Other connection opened by client (passive) or server (active) is called
data connection and is used to transfer the data.
As separate ports are used by client and server for these connections,
FTP becomes an put of band protocol.
Data transfer can take place in following three modes
o Stream mode : data is sent in a continuous stream where FTP does
not do any formatting.
o Block mode: FTP breaks the data into several blocks (block
header, byte count, and data field) and then passes it on to TCP.
o Compressed mode: Data is compressed using a single algorithm.
FTP is a old protocol and is basically low in security aspect. Data
transferred over FTP is not encrypted and is in clear text format.
4
Hence the data like usernames, passwords can be read by anyone who
can capture the FTPed package. Newer versions of the protocol,
however, apply secure shell protocol (SSH) and avoid all the problems
faced by FTP.
Following are few types of FTP protocol with additional features
Anonymous FTP : Users login using an ‘anonymous’ account to
protect their confidential data.
Remote FTP: FTP commands executed on a remote FTP server
FTP with web browser and firewall support.
Secure FTP (SFTP,FTPS)
1.1.4 ECommerce
1.1.6 E business
E business is conduct of business over the internet, which includes
buying and selling of goods and even services.
In other words it is application of information and communication
technologies in support of all activities in business.
Applications of E business are divided into following categories–
7
o Internal business systems--
o Customer Relationship Management(CRM)
o Enterprise Resource Planning(ERP)
o Human resource management system(HRMS)
o Enterprise Communication and collaboration
o Content management
o E- mails
o Voicemails
o Web conferencing
o Electronic commerce
o B2B (business to business)
o B2C (business to customer)
o B2E business-to-employee
o B2Gbusiness-to-government
o G2Bgovernment-to-business
o G2G (government-to-government)
o G2C (government-to-citizen)
o C2C (consumer-to-consumer)
o C2B(consumer-to-business)
A business model is defined as the organization of product, service and
information flows, and the source of revenues and benefits for
suppliers and customers. The concept of e-business model is the same
but used in the online presence.
Few e business models are–
o E-shops
o E-commerce
o E-procurement
o E-malls
o E-auctions
o Virtual Communities
E business has more security risks as compared to a regular business,
as E business has many more users at a time. Keeping the large
information confidential is a difficult task. Also, data integrity,
authenticity and storage of data are some challenges faced by
Ebusiness.
Some methods to provide security are physical security as well as
encryption in data storage, transmission, antivirus software and
firewalls. Digital signature is another way to confirm the ownership
of a document.
8
1.2 INTERNET SERVICE PROVIDER
ISP connections–
ISPs which provide connections through phone lines like dial ups,
do not seek any information about the caller’s (user of the internet)
physical location or address. So, caller from any location which is in reach
of the ISP, can use the services provided.
Services provided –
ISP host usually provide e mail, FTP and web hosting services.
Other services can be like virtual machines, clouds or entire physical
servers where clients can run their own softwares.
ISPs often take services from their upstream ISPs. i.e. they work in
hierarchy. The ISPs are divided into three categories –
Free ISP: these are ISPs which provide services free of cost to the users
and display advertisements till the users are connected. These are called as
freenets. These are normally run on no profit basis.
10
The resolver, or another DNS server acting recursively on behalf of the
resolver, egotiates use of recursive service using bits in the query
headers.
Resolving usually entails iterating through several name servers to find
the needed information. However, some resolvers function
simplistically and can communicate only with a single name server.
These simple resolvers (called "stub resolvers") rely on a recursive
name server to perform the work of finding information for them.
Operation of DNS–
Domain name resolvers determine the appropriate domain name
servers responsible for the domain name in question by a sequence of
queries starting with the right-most (top-level) domain label.
DNS recorsor consults three name servers to resolve one address. The
process is as follows–
o A network host is configured with an initial cache (so called hints) of
the known addresses of the root name servers. Such a hint file is
updated periodically by an administrator from a reliable source.
o A query to one of the root servers to find the server authoritative for
the top-level domain.
o A query to the obtained TLD server for the address of a DNS server
authoritative for the second-level domain.
o Repetition of the previous step to process each domain name label in
sequence, until the final step which returns the IP address of the host
sought.
Internet address follows the TCP/IP suite hence, it is also known as the
IP address.
Internet address has a job of identifying a node on the network. In
other words, it is a numeric lable attached to every system (computer
or any other device). The basic function of IP address are two–
Identification of computer or node or device and location addressing.
The designers of the Internet Protocol defined an IP address as a 32-bit
number[1] and this system, known as Internet Protocol Version 4
(IPv4), is still in use today. However, due to the enormous growth of
the Internet and the predicted depletion of available addresses, a new
addressing system (IPv6), using 128 bits for the address, was
developed in 1995,[3] standardized as RFC 2460 in 1998,[4] and is
being deployed worldwide since themid-2000s.
IP addresses are binary numbers, but they are usually stored in text
files and displayed in human-readable notations, such as 172.16.254.1
(forIPv4)
11
IPV4 address is a 32 bit number, which uses the decimal doted
notation consisting of 4 decimal numbers each ranging from 0 to 255
separated by dots. Network administration divides the IP address into
two parts. – the most significant 8 bits are called network address
portion the remaining bits are known as rest bits or host bits or
identifiers and they are used for host numbering in anetwork.
Although IPV4 provides 4.3 billion addresses, they are exhausted due
to high demand and as a result, insufficient addresses available with
IANA (Internet assigned numbers authority). The primary address
pool of IANA is expected to get exhausted by mid 2011. To
permanently address the problem, new version of IP i.e. IPV6 was
brought forward, this version moved the size of IP address from 32 bit
to 128 bits.
Both IPV4 as well as IPV6 have reserved addresses for private or
internal networks. This is termed as private addressing.
Both IPV4 and IPV6 have sub netting effect. That mean, IP networks
can be divided into smaller groups or subnets. IP addresses two
constituents that is network address and host identifier or interface
identifier are used for this purpose.
Internet Protocol addresses are assigned to a host either anew at the
time of booting, or permanently by fixed configuration of its hardware
or software. Persistent configuration is also known as using a static IP
address. In contrast, in situations when the computer's IP address is
assigned newly each time, this is known as using adynamic IP address
Evolution of WWW
In March 1989, Tim Berners-Lee wrote a proposal that referenced
ENQUIRE, a database and software project he had built in 1980, and
described a more elaborate information management system.
on November 12, 1990, with help from Robert Cailliau, Tim
Berners- Lee published a more formal proposal to build a "Hypertext
project" called "World Wide Web" (one word, also "W3") as a
"web" of "hypertext documents" to be viewed by "browsers" using a
client– server architecture.
12
This proposal estimated that a read-only web would be developed
within three months and that it would take six months to achieve
"the creation of new links and new material by readers, to achieve
universal authorshipl" as well as "the automatic notification of a
reader when new material of interest to him/her has become
available."
A NeXT Computer was used by Berners-Lee as the world's first web
server and also to write the first web browser, World Wide Web, in
1990.
Tools needed were a working Web the first web browser (which was
a web editor as well); the first web server; and the first web pages,
which described the project itself.
On August 6, 1991, Tim Berners-Lee posted a short summary of the
World Wide Web project on the alt. hypertext newsgroup.
This date also marked the debut of the Web as a publicly available
service on the Internet. The first photo on the web was uploaded by
Berners-Lee in 1992, an image of the CERN house band Les
Horribles Cernettes.
The first server outside Europe was set up at SLAC to host the
SPIRES-HEP database in 91 –92.
The concept of hypertext originated with older projects from the
1960s, such as the Hypertext Editing System (HES) at Brown
University by Ted Nelson and Douglas Engelbart.
Tim Berners Lee introduced the concept of the Universal Document
Identifier (UDI), later known as Uniform Resource Locator (URL)
and Uniform Resource Identifier (URI); the publishing language
Hyper Text Markup Language (HTML); and the Hypertext Transfer
Protocol(HTTP).
In 1993, a graphical browser was developed by a team at the
National Center for Supercomputing Applications at the University
of Illinois at Urbana-Champaign (NCSA-UIUC), led by Marc
Andreessen. This was the first web browserever.
1.6 URL
13
Every URL consists of some of the following:
o The scheme name (commonly called protocol), followed by a
colon. The scheme name defines the namespace, purpose, and the
syntax of the remaining part of the URL.
o Domain Name depending upon scheme(alternatively, IP address).
The domain name or IP address gives the destination location for
the URL.
o An optional port number; if omitted, the default for the scheme is
used
o Path of the resource to be fetched or the program to be run. The
path is used to specify and perhaps find the resource requested. It
may be case-sensitive for non window based servers. Eg:
http://www.mudlle.ac.in/news.html
o A query string for scripts The query string contains data to be
passed to software running on the server. It may contain
name/value pairs separated by ampersands, for example ? first_
name= John & last_name=Doe.
o Optional fragment identifier that specifies a part or a position
within the overall resource or document. When used with HTTP, it
usually specifies a section or location within the page, and the
browser may scroll to display that part of the page.
When resources contain references to other resources, they can use
relative links to define the location of the second resource.
relative URLs are dependent on the original URL containing a
hierarchical structure against which the relative link is based.
the ftp, http, and file URL schemes are examples of some that can be
considered hierarchical, with the components of the hierarchy being
separated by"/"
A URL is a URI that, "in addition to identifying a resource, provides a
means of locating the resource by describing its primary access
mechanism.
1.7 BROWSERS
14
This process begins when user inputs the URI in the browser. Prefix of
the URI describes how to interpret the URI. Most URIs have resource
retrieved over Hyper text Transfer Protocol. Some web browsers also
support prefixes like FTP.
Once this is done, the HTML script is passed to the browser’s layout
engine. To make the script interactive java script support is needed.
With this, browser can interpret text, images, video and interactive
scripts.
All major browsers allow users to access multiple information
resources at the same time in different windows or in tabs. Major
browsers include pop up blockers to prevent windows to open without
users consent.
Most major web browsers have these user interface elements in common:
Back and forward buttons to go back to the previous resource and forward
again.
o A history list, showing resources previously visited in a list
(typically, the list is not visible all the time and has to be
summoned)
o A refresh or reload button to reload the current resource.
o A stop button to cancel loading the resource. In some browsers, the
stop button is merged with the reload button.
o A home button to return to the user's homepage
o An address bar to input the Uniform Resource Identifier (URI) of
the desired resource and display it.
o A search bar to input terms into a search engine
o A status bar to display progress in loading the resource and also the
URI of links when the cursor hovers over them, and page zooming
capability.
The usage share of web browsers is as shown below. (Source: Median
values)
Internet Explorer(43.55%)
Mozilla Firefox (29.0%; Usage by version number)
Google Chrome (13.89%)
Safari(6.18%)
Opera(2.74%)
Mobile browsers (4.45%)
Some special web browsers are listed below–
1.7.3 OPERA
Opera is a web browser and Internet suite developed by Opera
Software. The browser handles common Internet-related tasks such as
displaying web sites, sending and receiving e-mail messages,
managing contacts, chatting on IRC, downloading files via Bit Torrent,
and reading webfeeds.
Opera is offered free of charge for personal computers and mobile
phones. This is the most popular mobile phone browser and is not
packages in desktop operating system.
Features include tabbed browsing, page zooming, mouse gestures, and
an integrated download manager. Its security features include built-in
16
phishing and malware protection, strong encryption when browsing
secure websites, and the ability to easily delete private data such as
HTTP cookies.
Opera runs on a variety of personal computer operating systems,
including Microsoft Windows, Mac OS X, Linux, and FreeBSD
Opera includes built-in tabbed browsing, ad blocking, fraud protection,
a download manager and Bit Torrent client, a search bar, and a web
feed aggregator. Opera also comes with an e-mail client called Opera
Mail and an IRC chat client builtin.
Opera has several security features visible to the end user. One is the
option to delete private data, such as HTTP cookies, the browsing
history, and the cache, with the click of a button. This lets users erase
personal data after browsing from a shared computer.
Opera Mobile is an edition of Opera designed for smart phones and
personal digital assistants(PDAs)
Mozilla Firefox is a free and open source web browser descended from
the Mozilla Application Suite and managed by Mozilla Corporation.
As of February 2011[update], Firefox is the second most widely used
browser with approximately 30% of worldwide usage share of web
browsers.
To display web pages, Firefox uses the Gecko layout engine, which
implements most current web standards.
The latest Firefox features[15] include tabbed browsing, spell
checking, incremental find, live book marking, a download manager,
private browsing, location-aware browsing (also known as
"geolocation") based exclusively on a Google service.
Firefox runs on various operating systems including Microsoft
Windows, Linux, Mac OS X, FreeBSD, and many other platforms.
1.7.5 CHROME
Chrome, the web browser by Google, is rapidly becoming popular due
to following features-
o SPEED: Chrome is designed to be fast in every possible way: It's
quick in staring up from the desktop, loading web pages and
running complex web applications.
o SIMPLICITY: Chrome's browser window is streamlined, clean
and simple. Chrome also includes features that are designed for
efficiency and ease of use. For example, you can search and
navigate from the same box, and arrange tabs however you wish.
o SECURITY: Chrome is designed to keep you safer and more
secure on the web with built-in malware and phishing protection,
auto updates to make sure the browser is up-to-date with the latest
17
security updates, and more. Learn more about Chrome's security
features.
Chrome is the first browser to incorporate machine translation in the
browser itself, without requiring additional plugins orextensions.
1.9.1 APACHE
Apache HTTP Server is a free and open-source web server that
delivers web content through the internet. It is commonly referred to as
Apache and after development; it quickly became the most popular
HTTP client on the web.
The word, Apache, has been taken from the name of the Native
American tribe ‘Apache’, famous for its skills in warfare and strategy
making.
Apache is the most widely used Web Server application in Unix-like
operating systems but can be used on almost all platforms such as
Windows, OS X, OS/2, etc
18
It is a modular, process-based web server application that creates a
new thread with each simultaneous connection. It supports a number
of features; many of them are compiled as separate modules and
extend its core functionality, and can provide everything from server
side programming language support to authentication mechanism.
Features of Apache:
Handling of static files
Loadable dynamic modules
Auto-indexing
Compatible with IPv6
Supports HTTP/2
FTP connections
Bandwidth throttling
Load balancing
Session tracking
URL rewriting
Geolocation based on IP address and many more
1.9.2 IIS
19
1.9.3 PROXY SERVER
A proxy server provides a gateway between users and the internet. It is
a server, referred to as an “intermediary” because it goes between end-
users and the web pages they visit online.
Proxies provide a valuable layer of security for your computer. They
can be set up as web filters or firewalls, protecting your computer from
internet threats like malware.
Benefits of proxy server:
Enhanced security
Private browsing, watching, listening and shopping
Access to location– specific content
Prevent employees from browsing inappropriate or distracting sites
20
The HTTP protocol is a request/response protocol based on the
client/server based architecture where web browsers, robots and search
engines, etc. act like HTTP clients, and the Web server acts as a server.
Basic Features:
HTTP is connectionless protocol
HTTP is media independent
HTTP is stateless
1.11 EXERCISE
22
2
HTML5
Unit Structure :
2.0 Objectives
2.1 Introduction
2.2 Why HTML5?
2.3 Formatting text by using tags
2.4 Formatting text by lists
2.5 Formatting of backgrounds
2.6 Creating hyperlinks and anchors
2.7 Style sheets
2.8 CSS formatting text using style sheets
2.9 Formatting paragraphs using style sheets.
2.10 Summary
2.11 References
2.12 Exercise
2.0 OBJECTIVES:
2.1 INTRODUCTION
23
HTML5 is a standard for structuring and presenting content on the
World Wide Web.
Features of HTML5
It allows you to play a video and audio file. You can embed audio or video
on your web pages without resorting to third-party plugins.
It facilitates you to design better forms and build web applications that
work offline.
It provides you advance features for that you would normally have to write
JavaScript to do.
Cross-Browser Compatibility
HTML5 is easy to implement and it works with CSS3. Today all
browsers support HTML5 tags and even IE6 understands the markup
<!doctype html> and will render the pages correctly.
Offline Browsing
HTML5 also offers offline browsing, which means that visitors can
load certain elements on a web page without an active internet connection.
With HTML5 offline caching we can still load core elements of the
websites and you can view them offline.
24
Video and Audio Support
With HTML5 technology, we no longer need to rely upon third-
party plugins in order to render audio and videos. You can forget about
Flash Player and other third-party media players and plugins. You can
make your videos and audio easily accessible with the new HTML5
<video> and <audio> tags.
<!DOCTYPE> tag:
HTML <!DOCTYPE> tag is used to inform the browser about the
version of HTML used in the document. It is called as the document type
declaration (DTD).
<article> tag :
The HTML <article> tag defines an independent self-contained
content in a document, page, application or a site.
Syntax
<article> ... </article>
The example below shows the <article>tag .
<article>
<h1>Introduction to HTML5</h1>
<p>. HTML5 is enriched with advance features which make it easy and
interactive for developer and users..</p>
</article>
Syntax
<header> ... </header>
The example below shows the <header>tag .
<header>
<h2>Sports</h2>
<p>Cricket sport is World's no.1 sport all over the world</p>
</header>
Syntax
<section> ... </section>
The example below shows the <section>tag .
<section>
<h1>Introduction to HTML5</h1>
<p>. HTML5 is enriched with advance features which make it easy and
interactive for developer and users..</p>
</section>
Syntax
<figcaption> ... </figcaption>
The example below shows the <section>tag .
<figure>
<imgsrc="discovery.jpg" alt="Space Shuttle">
<figcaption>NASA - Space Shuttle Discovery</figcaption>
</figure>
27
Ordered List or Numbered List:
In the ordered HTML lists, all the list items are marked with
numbers by default. It is known as numbered list also. The ordered list
starts with <ol> tag and the list items start with <li> tag.
<ol>
<li>Sachin</li>
<li>Kapil</li>
<li>Rahul</li>
<li>Rohit</li>
</ol>
28
HTML provides you following two good ways to decorate your
webpage background.
HTML Background with Colors
HTML Background with Images
Syntax
<tagnamebgcolor = "color_value"...>
The example below shows the <bgcolor>attribute.
<table bgcolor = "yellow" width = "100%">
<tr>
<td>
Syntax
<tagname background = "Image_url"...>
The example below shows the < background > attribute.
<table background = "/images/html.gif" width = "100%" height = "100">
<tr><td>
HTML links are hyperlinks. You can click on a link and jump to
another document. The HTML <a> tag defines a hyperlink. To make a
hyperlink in an HTML page, use the <a> and </a> tags, which are the tags
used to define the links.
Syntax
<a href = "...........">Hyperlink Text </a>
The example below shows the < a > tag.
<a href="Next.html">Next Page</a>
The HTML anchor tag defines a hyperlink that links one page to
another page. It can create hyperlink to other web page as well as files,
29
location, or any URL. The href attribute is used to define the address of
the file to be linked.
If we want to open that link to another page then we can use target
attribute of <a> tag. With the help of this link will be open in next page.
Syntax
<a href = "...........">Hyperlink Text </a>
The example below shows the < a > tag.
<a href="First.html">Home Page</a>
Text Color
The color of the text is defined by the CSS color property.
body {
color: #434343;
}
Text Alignment:
The text-align property is used to set the horizontal alignment of
the text.Text can be aligned in four ways: to the left, right, centre or
justified.
h1 {
text-align: center;
}
p{
31
text-align: justify;
}
Text Decoration:
The text-decoration property is used to set or remove decorations
from text. This property accepts one of the following values: underline,
overline, line-through, and none.
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
Text Transformation:
The text-transform property is used to set the cases for a text.Using
this property you can change an element's text content into uppercase or
lowercase letters.
h1 {
text-transform: uppercase;
}
h2 {
text-transform: capitalize;
}
h3 {
text-transform: lowercase;
}
Text Indentation:
The text-indent property is used to set the indentation of the first
line of text within a block of text. The size of the indentation can be
specified using percentage (%), length values in pixels, ems.
p{
text-indent: 100px;
}
indent: It can be set left and right only. Creates space that represents the
distance between the edge of the frame and content.
32
margin: It can be set top, bottom, left and right. Creates space that
represents the distance between the indent and the border.
border: It can be set top, bottom, left and right. A visual effect that
represents the distance between the margin and padding.
padding: It can be set top, bottom, left and right. Represents the distance
between the border and content.
Single line css using style attribute:
<p style="text-align:right">This is some text in a paragraph.</p>
Style paragraphs with CSS:
<style>
p{
color: navy;
text-indent: 30px;
text-transform: uppercase;
}
</style>
2.10 SUMMARY
HTML5 chapter covers the key web components driving the future of
the Web. Harness the power of HTML5 to create web apps and
solutions that deliver state-of-the-art media content and interactivity
with new Audio, Video, and Canvas elements.
HTML5 technologies are essential knowledge for today's web
developers and designers. New APIs such as Local Storage,
Geolocation, Web Workers, and more expand the Web as a platform,
allowing for desktop-like applications that work uniformly across
platforms
2.11 REFERENCES
2.11 EXERCISE
1) What do you understand by HTML tags? How many tags are required
to create a web page in HTML5?
2) Explain the various formatting tags in HTML5.
3) Explain the various new tags introduced by HTML5 in Media
Elements.
33
4) What is the correct usage of the following HTML5 semantic elements?
5) How many ways can a CSS be integrated as a web page?
6) What benefits and demerits do External Style Sheets have?
7) What are the limitations of CSS?
8) Explain what are the components of a CSS Style?
9) What do you mean by CSS selector?
10) Which property is used for controlling the image position in the
background?
11) What is the main difference between class selectors and id selectors?
12) Which property of a table is used to the appearance of the adjacent
borders?
13) How many formats you can display a CSS colour?
14) What do you mean by animation in CSS?
15) What are pseudo elements?
34
UNIT - 2
3
NAVIGATION
Unit Structure
3.0 Objectives
3.1 Introduction
3.2 Planning site organization
3.3 Creating text based navigation bar
3.4 Creating graphics based navigation bar
3.5 Creating image map
3.6 Redirecting to another URL
3.7 Summary
3.8 Bibliography
3.9 Unit End Exercise
3.0 OBJECTIVES
3.1 INTRODUCTION
35
Types of web navigation
The use of website navigation tools allow for a website's visitors to
experience the site with the most efficiency and the least
incompetence.
A website navigation system is analogous to a road map which enables
webpage visitors to explore and discover different areas and
information contained within the website.
There are many different types of website navigation: Hierarchical
website navigation the structure of the website navigation is built from
general to specific.
This provides a clear, simple path to all the web pages from anywhere
on the website.
Global website navigation Global website navigation shows the top
level sections/pages of the website.
It is available on each page and lists the main content sections/pages of
the website.
Site map:
A site map (or sitemap) is a list of pages of a web site accessible to
crawlers or users.
It can be either a document in any form used as a planning tool for
Web design, or a Web page that lists the pages on a website, typically
organized in hierarchical fashion.
Sitemaps make relationships between pages and other content
components. It shows shape of information space in overview.
Sitemaps can demonstrate organization, navigation, and labeling
system.
36
A navigation bar is a user interface element within a webpage that
contains links to other sections of the website.
We can use the navigation bar to visit other sections of the website.
Example:
<html>
<head>
<title> Navigation Bar </title>
</head>
<body>
<hr />
<a href="index.htm">Home</a>
<a href="tips.htm">Tips and Tricks</a>
<a href="problems.htm">Problem-Solving</a>
<a href="products.htm">Products</a>
<a href="about.htm">About Our Store</a>
<a href="contact.htm">Contact Us</a></p>
<hr />
</body>
</html>
Output:
Output:
Text hyperlinks are clear and unambiguous, but not all that attractive.
We might prefer to create a navigation bar that uses buttons or other
graphics instead of text links.
We can create the graphics yourself in a graphics-editing program.
Follow these guidelines:
38
Keep the size of each button small (150 pixels wide at the most).
Make each button the same size and shape. They should vary only
in the text on them.
Save each button as a separate file in GIF or JPG format.
There are thousands of sites with free graphical buttons you can
download.
Make several copies of a button you like, and then use a text tool in a
graphics-editing program to place different text on each copy.
Example:
<html>
<head>
<title> Navigation Bar </title>
</head>
<body>
<nav>
<hr>
<p style="margin:0px">
<a href="index.htm"><imgsrc="images/btn_home.gif"
style="border: none"></a>
<a href="tips.htm"><imgsrc="images/btn_store.gif"
style="border:none"></a>
<a href="problems.htm"><imgsrc="images/btn_contactus.gif"
style="border: none"></a>
<a href="products.htm"><imgsrc="images/btn_support.gif" style=
"border: none"></a>
<hr>
</nav>
</body>
</html>
Output:
Example:
<! DOCTYPE html>
<html>
<h3>Mapping an Image
<body>
<p>Click on the different continents of the map to know about
them.</p>
<imgsrc="world-map-151576_960_720.png" width="960"
height="492" alt="World Map" usemap="#worldmap">
<map name="worldmap">
<area shape="rect" coords="184, 36, 272, 158" alt="north america"
href="https://en.wikipedia.org/wiki/North_America">
<area shape="rect" coords="282, 215, 354, 367" alt="south america"
href="https://en.wikipedia.org/wiki/South_America">
<area shape="rect" coords="506, 151, 570, 333" alt="africa"
href="https://en.wikipedia.org/wiki/Africa">
<area shape="rect" coords="618, 42, 791, 162" alt="asia"
href="https://en.wikipedia.org/wiki/Asia">
40
<area shape="rect" coords="509, 44, 593, 110" alt="europe"
href="https://en.wikipedia.org/wiki/Europe">
<area shape="rect" coords="786, 288, 862, 341" alt="australia"
href="https://en.wikipedia.org/wiki/Australia_(continent)">
<area shape="rect" coords="249, 463, 760, 488" alt="antartica"
href="https://en.wikipedia.org/wiki/Antarctica">
</map>
</body>
</html>
Output:
41
Syntax:
<meta http-equiv = "refresh" content = " time ;url = l
Example:
<! DOCTYPE html>
<html>
<head>
<title>HTML Redirect</title>
<meta http-equiv="refresh"
content="5; url = https://old.mu.ac.in/distance-open-learning/" />
</head>
<body>
<h1 style="text-align: center; color: green ;">
IDOL Mumbai University
</h1>
Output:
3.7 SUMMARY
42
3.8 BIBLIOGRAPHY
1.https://learning.oreilly.com/library/view/microsoft-html5-
step/9780735656543/ch10s03.html
2.https://www.geeksforgeeks.org/html-mapping-image/
3.https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav
43
4
LAYOUTS
Unit Structure :
4.0 Objectives
4.1 Introduction
4.2 HTML5 Semantic Tags
4.3 Creating Divisions
4.4 Creating HTML5 Semantic Layout
4.5 Positioning and Formatting Divisions
4.6 Summary
4.7 Bibliography
4.8 Unit End Exercise
4.0 OBJECTIVES
Understand tags and the new HTML semantic tags in breaking a page
into sections.
Learn to place the division in a specified location within your page.
Create a division-based layout to your web page
Create a HTML5 Semantic layout to your web page
4.1 INTRODUCTION
Semantic HTML tags are those that clearly describe their meaning
in a human- and machine-readable way.
44
List of new semantic tags:
The semantic tags added in HTML5 are:
<article>
<aside>
<details>
<figcaption>
<figure>
<footer>
<header>
<main>
<mark>
<nav>
<section>
<summary>
<time>
Output:
45
In this way we can use other semantic tags for accomplishment of
our purpose.
<main>: It defines the main content of the document. The content inside
main tag should be unique.
HTML provides you a lot of ways to layout your page better. Web
designers today are geared towards a more appealing way of separating
content into sections which is called the division-based layout.
46
It is mandatory to close the tag.
Most websites have put their content in multiple columns, multiple
columns can be created by using <div> tags.
Advantages of the Division-based Layout:
You can place layout styles externally, and then make the style changes
to many pages at once simply by modifying the style sheet.
It reduces the number of lines of code needed to produce a page.
The id attribute:
The id attribute can be used with any tag element. When used along
with the <div>tag, it will identify and define an area of your page.
As a unique identifier, the id’s value should only be used once on your
page.
Start the id value with a letter followed by any of these: letters, number
digits (1- 9), dashes (-) and underscore (_). Don’t use space or special
characters.
The value is case-sensitive.
<div id=” title”>is different from <div id=” Title”>
47
Output:
The output does not show a layout. You can clearly see how your
page is divided into different sections.
48
Figure 4.1 Semantic tags layout
</p>
</article>
<aside>
<figure>
<imgsrc="Images/laptop.jpeg" height="100px" width="60px" />
<figcaption>Figure caption goes here</figcaption>
49
</figure>
<p>
I aside tag
</p>
</aside>
<section>
<h1>This is a section heading</h1>
<p>
Hello world! Hello world! Hello world!
</p>
</section>
<footer>
<hr />
Copyright (C) 2021. All rights reserved.
</footer>
</body>
</html>
header
{
padding:0px;
text-align: center;
}
aside
{
margin-top:5px;
background-color: #f0eaea;
padding:5px;
text-align: center;
font-style: italic;
border: double 3px #b200ff;
}
50
section
{
padding:5px;
border: dashed 3px #0026ff;
margin-top:5px;
}
footer
{
padding:5px;
text-align: center;
font-weight: bold;
}
nav
{
text-align: center;
}
ul li
{
display: inline;
padding-left:5px;
padding-right:5px;
text-align: left;
font-size:16px;
font-weight: bold;
}
Output:
51
4.5 POSITIONING AND FORMATING DIVISIONS
If you insert an additional <aside>division to your web page
layout, and place your division beside another either to the right or left,
you can easily use the float style rule.
Positioning Style –
If you want to place a division on a specific spot of your page, you
can use the position style rule.
Position Style:
You must use each of these values in combination with top, right,
bottom, and /or left style rule that specifies the location to which the
position style rules refers.
Example: To position a section at exactly 100px from the top of the page
and 200px from the left side, the syntax should be:
<section style= “top:100px; left:200px; position: absolute”>
Horizontal Lines
Horizontal Lines can be useful as a visual divider between sections of text
in a web page.
You can add a horizontal line after your header then add another
horizontal line before your footer.
This will clearly show your division in your web page.
You can simply add the horizontal line <hr> (horizontal rule) tag where
you want the line to appear.
52
4.6 SUMMARY
This chapter covered semantic mark-up elements of HTML5 that
can be used in the proper layout of the web pages. Unlike the <div>
element, the semantic elements are intended to be used for a specific
purpose. The elements we covered in this article include <header>, <nav>,
<footer>, <section>, <article> and <aside>.as well as we covered the div
tags with positioning.
4.7 BIBLIOGRAPHY
1. https://www.freecodecamp.org/news/semantic-html5-elements/
2. https://www.geeksforgeeks.org/html5-semantics/
3.https://www.slideshare.net/grayzon21/html5-create-divisions-in-a-web
53
5
TABLES
Unit Structure
5.0 Objectives
5.1 Introduction
5.2 Creating simple table
5.3 Specifying the size of the table
5.4 Specifying the width of the column
5.5 Merging table cells
5.6 Using tables for page layout
5.7 Applying table borders
5.8 Applying background and foreground fills
5.9 Changing cell padding
5.10 Spacing and alignment
5.11 Summary
5.12 Bibliography
5.13 Unit End Exercise
5.0 OBJECTIVES
5.1 INTRODUCTION
54
5.2 CREATING SIMPLE TABLES
Example:
The following table is an example of a basic table with two rows and two
columns of data.
Html code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td>Department</td>
<td>Subject</td>
</tr>
<tr>
<td>IDOL</td>
<td>Web Programming</td>
</tr>
</table>
</body>
</html>
55
Output:
The width attribute specifies the width of a table. The width can be set
either as an absolute value in pixels, or as in percentage (%).
If the width attribute is not set, it will take up the space of longest
single word in each cell.
Table width in pixels:<table width=100>
Table width in percentage (%): <table width=100%>
Example:
Html code:
<html>
<body >
<table width=100>
<tr>
<td>
Table width is 100 pixels
</td>
</tr>
</table>
<br>
<table width=100%>
<tr>
<td>
Table width is 100 %
</td>
</tr>
</table>
</body>
</html>
Output:
The above HTML code display two tables, one is 100-pixel width and
another one is 100% width.
56
First table is only 100-pixel width in any changes in browser window
state, while other table will always stretch the full width of the
window.
Example:
Html code
<html>
<head>
</head>
<body>
<table border="1" width="100%">
<col style="width:40%">
<col style="width:30%">
<col style="width:30%">
<tr>
<th>Fruits</th>
<th>Vitamin A</th>
<th>Vitamin C</th>
</tr>
<tr>
<th>Apples</th>
<td>98 ui</td>
<td>8.4 mg</td>
</tr>
<tr>
<th>Oranges</th>
<td>295 ui</td>
<td>69.7 mg</td>
</tr>
</table>
</body>
</html
Output:
57
5.5MERGING TABLE CELLS
Colspan:
The colspan attribute defines the number of columns a cell should span
(or merge) horizontally.
That is, we merge two or more Cells in a row into a single Cell.
<td colspan=2 >
The above code will merge two Cells as one Cell horizontally.
HTML code:
<html>
<body >
<table border=1 >
<tr>
<td colspan=2 >Merge</td>
</tr>
<tr>
<td>Third Cell</td>
<td>Forth Cell </td>
</tr>
</table>
</body>
</html>
Rowspan:
The rowspan attribute specifies the number of rows a cell should span
vertically.
58
That is, we merge two or more Cells in the same column as a single
Cell vertically.
<td rowspan=2 >
The above code will merge two Cells as one Cell vertically.
HTML code:
<html>
<body >
<table border=1 >
<tr>
<td>First Cell</td>
<td rowspan=2 >Merged</td>
</tr>
<tr>
<td valign=middle>Third Cell </td>
</tr>
</table>
</body>
</html>
Rowspan merged Cells vertically, that is from top to bottom.
HTML tables are most often used to define the layout of an entire Web
page.
If we want to design a page that displays text in newspaper style
columns, or separates the page into distinct sections, we’ll find tables
an essential and useful tool.
By default, tables that you create do not have visible borders (a line
around the table that visually defines the table).
Borders can help to make your table stand out more and adds visual
interest.
After creating an HTML table, you should add a border to it,
Output:
Each table, row, and cell is its own distinct area, and each can have its
own background.
For example, you might want to apply a different color background to
a heading row to make it stand out, or change the color of every other
line in a listing to help visitors track a line across the table.
Table elements support the bgcolor attribute.
To specify a background color for all of the cells in a table, all of the
cells in a row, or for individual cells, by adding the bgcolor attribute to
either the <table>, <tr>, <td>, or <th> tags as follows:
<table bgcolor= “color”>
<tr bgcolor= “color”>
<td bgcolor= “color”>
<th bgcolor= “color”>
color is either a color name or hexadecimal color value
60
Specifying Table, Row, and Cell Colors:
Html code
<html>
<table border="5" bgcolor="white">
<caption><b>State and Capital City</b></caption>
<tr bgcolor="yellow">
<th > State</th>
<th> City</th>
</tr>
<tr >
<td bgcolor="lightblue" > Maharashtra</td>
<td> Mumbai</td>
</tr>
<tr >
<td > Karnataka</td>
<td bgcolor="lightgreen"> Bangalore</td>
</tr>
</table
</html>
Output:
61
Example:
<html>
<table border="7" bordercolor="lightblue" background="parch.jpg" >
<caption><b>State and Capital City</b></caption>
<tr style="color: blue;">
<th > State</th>
<th> City</th>
</tr>
<tr >
<td > Maharashtra</td>
<td> Mumbai</td>
</tr>
<tr >
<td > Karnataka</td>
<td style="color: red;"> Bangalore</td>
</tr>
</table
</html>
Output:
To control the space between the table text and the cell borders, add
the cellpadding attribute to the table tag.
The syntax for this attribute is:
<table cellpadding=“value”>
– value is the distance from the table text to the cell border,
as measured in pixels
– the default cell padding value is 1 pixel
Cell padding refers to the space within the cells.
62
5.10 PACING AND ALIGNMENT
63
5.11 SUMMARY
5.12 BIBLIOGRAPHY
1.https://its.temple.edu/creating-tables-html
2.http://www.corelangs.com/html/tables/width-height.html
3.https://htmlreference.io/tables/
4.http://www.corelangs.com/html/tables/colspan-rowspan.html
5.https://www.teachucomp.com/add-table-borders-using-
html5/#:~:text=To%20assign%20a%20border%2C%20insert,and%20not
%20the%20individual%20cells.
64
6
FORMS AND MEDIA
Unit Structure
6.0 Objectives
6.1 Introduction
6.2 Creating basic form
6.3 Using check boxes and option buttons
6.4 Creating lists
6.5 Additional input types in HTML5
6.6 Audio and Video in HTML5
6.7 HTML multimedia basics
6.8 Embedding video clips
6.9 Incorporating audio on web page
6.11 Summary
6.12 Bibliography
6.13 Unit End Exercise
6.0 OBJECTIVES
1. To gain familiarity with what web forms are, what they are used for,
how to think about designing them, and the basic HTML elements
we'll need for simple cases.
2. To understand the newer input type values available to create native
form controls, and how to implement them using HTML.
3. To learn how to embed video and audio content into a webpage, and
add captions/subtitles to video.
6.1 INTRODUCTION
The first article in our series provides you with your very first
experience of creating a web form, including designing a simple form,
implementing it using the right HTML form controls and other HTML
elements, adding some very simple styling via CSS, and describing how
data is sent to a server. We'll expand on each of these subtopics in more
detail later on in the module.
65
6.2 CREATING BASIC FORMS
Our form will contain three text fields and one button.
We are asking the user for their name, their e-mail and the message
they want to send.
Hitting the button will send their data to a web server.
66
All forms start with a <form> element, like this:
<form action="/my-handling-form-page" method="post">
</form>
This element formally defines a form.
The action attribute defines the location (URL) where the form's
collected data should be sent when it is submitted.
The method attribute defines which HTTP method to send the data with
(usually get or post).
The data entry portion contains three text fields, each with a
corresponding <label>:
The input field for the name is a single-line text field.
The input field for the e-mail is an input of type email: a single-line text
field that accepts only e-mail addresses.
The input field for the message is a <textarea>; a multiline text field.
Output:
67
6.3 USING CHECK BOXES AND OPTION BUTTONS
<input type="checkbox">:
The <input type="checkbox"> defines a checkbox.
The checkbox is shown as a square box that is ticked (checked) when
activated.
Checkboxes are used to let a user select one or more options of a
limited number of choices.
Example:
<html>
<head>
<title> Input type = "checkbox" </title></head>
<body>
<h2> input type="checkbox" </h2>
<p>Choose your Ice-cream flavours :</p>
<div>
<input type="checkbox" id="Vanilla" name="Vanilla"checked>
<label for="Vanilla">Vanilla</label>
</div>
<div>
<input type="checkbox" id="horns" name="Strawberry">
<label for="Strawberry">Strawberry</label>
</div>
</body>
</html>
Output:
Option Buttons:
Option buttons are sometimes called Radio Buttons, and they force the
user into choosing only one item in a list, such as a Male/Female
option, or selecting a payment method.
The Option button HTML look like this:
<INPUT TYPE="Radio" Name="Gender" Value="Male">
68
Male
<INPUT TYPE="Radio" Name="Gender"
Value="Female">Female
After typing the INPUT tag, the word TYPE comes next. For Option
Buttons, the type is "Radio".
The NAME is definitely needed here, and note that the NAME for
both in our code above is "Gender".
We use the same name for each group of option buttons we are adding
to your form.
So if you wanted payment option buttons, the code might be this:
<INPUT TYPE="Radio" Name="payment" Value="CC">
Credit Card
<INPUT TYPE="Radio" Name="payment" Value="DC">
Debit Card
<INPUT TYPE="Radio" Name="payment" Value="PP">
PayPal
This time, each radio button has the name "payment".
The reason you keep the same name for each group of option buttons
is simply to distinguish one group of option buttons from another.
The VALUE attribute is quite useful.
When the user submits the form to us using the Submit button, these
VALUES are going to be returned.
If we just got Radio1 and Radio2, you won't know (or won't
remember, more likely) which option the user has selected.
Manipulating values with scripts is also a lot easier if the Value is the
same as the text the user sees.
If you want to have a default option button selected, use the word
"Checked":
<INPUT TYPE="Radio" Name="payment" Value="CC">
Credit Card
<INPUT TYPE="Radio" Name="payment" Value="DC">
Debit Card
<INPUT TYPE="Radio" Name="payment"
Value="PP" Checked>PayPal
Attaching a label to each button is very useful for your visitors.
When the label is clicked it will select the option button it is named
for:
Example:
<html>
<head>
<title> Input type = "Option" </title></head>
<body>
<h2> input type="Option" </h2>
69
<p>Choose your Payment option :</p>
<div>
<LABEL FOR="R1">Credit Card</LABEL>
<INPUT TYPE="Radio" Name="payment" ID="R1"
Value="Credit Card">
</div>
<div>
<LABEL FOR="R2">Debit Card</LABEL>
<INPUT TYPE="Radio" Name="payment" ID="R2" Value="Debit
Card">
</div
<div>
<LABEL FOR="R3">PayPal</LABEL>
<INPUT TYPE="Radio" Name="payment" ID="R3" Value="PayPal"
Checked>
</div>
</body>
</html>
Output:
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Grocery list</h2>
<ul>
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ul>
</body>
</html>
Output:
Example:
<! DOCTYPE html>
<html>
<body>
<h2>Grocery List</h2>
<ol>
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ol>
</body>
</html>
71
Output:
Example:
<! DOCTYPE html>
<html>
<body>
<h2>A Description List</h2>
<dl>
<dt>Coffee</dt>
<dd>- 500 gms</dd>
<dt>Milk</dt>
<dd>- 1 ltr Tetra Pack</dd>
</dl>
</body>
</html>
Output:
72
When this type is used, the user is required to type a valid email
address into the field.
Any other content causes the browser to display an error when the
form is submitted. You can see this in action in the below screenshot.
Search field:
Search fields are intended to be used to create search boxes on pages
and apps.
This type of field is set by using the value search for
the type attribute:
<input type=”search” id= “search” name=” search”>
The main difference between a text field and a search field is how the
browser styles its appearance.
Often, search fields are rendered with rounded corners; they also
sometimes display an "Ⓧ", which clears the field of any value when
clicked.
The below screenshots show a non-empty search field in Firefox 71,
Safari 13, and Chrome 79 on macOS, and Edge 18 and Chrome 79 on
Windows 10.
Note that the clear icon only appears if the field has a value, and,
apart from Safari, it is only displayed when the field is focused.
73
Phone number field
A special field for filling in phone numbers can be created
using tel as the value of the type attribute:
< input type=”tel”id= “tel”name=” tel”>
When accessed via a touch device with a dynamic keyboard, most
devices will display a numeric keypad when type="tel" is
encountered, meaning this type is useful whenever a numeric keypad
is useful, and doesn't just have to be used for telephone numbers.
URL field
A special type of field for entering URLs can be created using the
value url for the type attribute:
< input type=”url” id= “url”name=” url”>
It adds special validation constraints to the field.
The browser will report an error if no protocol (such as http:) is
entered, or if the URL is otherwise malformed.
Numeric field:
Controls for entering numbers can be created with
an <input> type of number.
This control looks like a text field but allows only floating-point
numbers, and usually provides buttons in the form of a spinner to
increase and decrease the value of the control.
Let's look at some examples. The first one below creates a number
control whose value is restricted to any value between 1 and 10, and
whose increase and decrease buttons change its value by 2.
< input type=”number” id= “number”name=” number” min= “1”
max= “10” step= “2” >
The number input type makes sense when the range of valid values is
limited, for example a person's age or height.
74
<input type="datetime-local"> creates a widget to display and pick a
date with time with no specific time zone information.
< input type= “datetime-local” id= “datetime”name=” datetime”>
<video controls
<source src= “sample.mp4” type= “video /mp3>
<p> your browser doesn’t support HTML5 video. Here is a <a
href= “sample.mp4”> link to the video</a> instead.<p>
</video>
controls
Users must be able to control video and audio playback (it's
especially critical for people who have epilepsy.) You must either use
the controls attribute to include the browser's own control interface
75
This takes up less space than a video player, as there is no visual
component — you just need to display controls to play the audio. Other
differences from HTML video are as follows:
The <audio> element doesn't support the width/height attributes —
again, there is no visual component, so there is nothing to assign a
width or height to.
It also doesn't support the poster attribute — again, no visual
component
What is Multimedia?
Multimedia comes in many different formats.
It can be almost anything you can hear or see, like images, music,
sound, videos, records, films, animations, and more.
Web pages often contain multimedia elements of different types and
formats.
A combination of video and audio files can also be used in websites to
gain popularity in terms of viewership or provide information and
entertainment to the users.
HTML helps you to add multimedia files on your website by providing
various multimedia tags.
These tags include AUDIO, VIDEO, EMBED, and OBJECT.
The AUDIO tag is used to display the audio file on the Web page,
whereas the VIDEO tag is used to display the video files on the Web
page.
The EMBED and OBJECT tags display the multimedia files on a Web
page as well as embed the files from other websites.
Browser Support:
The first web browsers had support for text only, limited to a single
font in a single color.
Later came browsers with support for color, fonts, images, and
multimedia!
76
Multimedia Formats:
Multimedia elements (like audio or video) are stored in media files.
The most common way to discover the type of a file, is to look at the
file extension.
Multimedia files have formats and different extensions like: .wav,
.mp3, .mp4, .mpg, .wmv, and .avi.
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="color: green;">
IDOL Video Songs
</h1>
<h3>
How to embed Video in a HTML document?
</h3>
<video controls width= "400" height= "300">
<source src="aapla.mp4" type= "video/mp4">
</video>
</body>
</html>
77
The HTML5 video player supports three formats, but not all of them
have the same level of browser support.
This means you can add sources in different formats to ensure the
user can see the video.
It is always recommended to add HTML5 video controls to your
player.
Using special buttons in the player window, the user can manually
start and stop the video, skip to specific place using the slider, or
toggle between window and full screen video display.
To add video controls, include the controls attribute.
Player Dimensions:
To define the size of your player, you can use the height and width
attributes.
The video will keep the same aspect ratio.
In the HTML5 video example above, the values are set to 300 for the
height and 400 for the width.
Syntax:
<audio>
<source src="sample.mp3" type="audio/mpeg">
</audio>
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="color: green;">
IDOL Audio Songs
</h1>
<h3>
How to embed audio in a HTML document?
</h3>
<audio controls>
78
<source src="Test.mp3" type="audio/mp3">
<source src="Test.ogg" type="audio/ogg">
</audio>
</body>
</html>
Output:
6.10 SUMMARY
In this chapter we have studied basic input types of html and new
HTML5 input type as well as controls.
We build the form by using controls and input types.
We focusing on multimedia to embed video and audio in to web pages.
6.11 BIBLIOGRAPHY
1. https://developer.mozilla.org/en-US/docs/Learn/Forms/Your_first_form
2. https://www.w3schools.com/tags/att_input_type_checkbox.asp
3. https://www.homeandlearn.co.uk/WD/wds8p5.html
4. https://www.tutorialspoint.com/html5/html5_audio_video.htm
5. https://www.bitdegree.org/learn/html5-video-player
6.https://www.geeksforgeeks.org/how-to-embed-audio-element-in-a-html-
document/
7. https://codescracker.com/html/html-multimedia-working.htm
7
JAVASCRIPT
Unit Structure :
7.1 Objective
7.2 Introduction
7.2.1 Client side JavaScript
7.2.2 Server side JavaScript
7.2.3 JavaScript objects
7.2.4 JavaScript security
7.3 Operators
7.3.1 Assignment
7.3.2 Arithmetic
7.3.3 Comparison
7.3.4 Modulus
7.3.5 Increament
7.3.6 Decreament
7.3.7 Unary negation
7.3.8 Logical operators
7.3.9 Short circuit evaluation
7.3.10 String operators
7.3.11 Special operators
7.3.12 Conditional operators
7.3.13 Comma operators
7.3.14 Delete
7.3.15 New
7.3.16 This
7.3.17 Void
7.4 Statements
7.4.1 Break
7.4.2 Comment
7.4.3 Continue
7.4.4 Delete
7.4.5 Do while
7.4.6 Export
7.4.7 For
7.4.8 For in
80
7.4.9 Function
7.4.10 Ifelse
7.4.11 Import
7.4.12 Labelled
7.4.13 Return
7.4.14 Switch
7.4.15 Var
7.4.16 While
7.4.17 With
7.5 Core java script
7.5.1 Array
7.5.2 Boolean
7.5.3 Object
7.5.3.1Date
7.5.3.2 Math
7.5.4 Number
7.5.5 Object
7.5.6 String
7.5.7 reg Exp
7.0 OBJECTIVE
7.1INTRODUCTION
81
Javascript is originally a scripting language developed by European
Computer Manufacturer’s association (ECMA)
Javascript that runs at the client side (ie at the client’s browser) is
client side java script (CCJS) and javascript that runs at the server is
serverside java script (SSJS)
Javascript being object oriented, uses number of built in javascript as
well as objects can be created.
Every object has properties and methods. Property is value(s)
associated with an object. Methods are actions associated with an
object.
Example:<scripttype="text/javascript">
document. write("This message is written by JavaScript");
</script>
in above example, ‘document’ is object and write() is a method of
document object.
Javascript runs in a web browser, and when a script written by a third
party is executed on the browser, there is a risk of running a spyware
or a virusprogram.
Hence, each time javascript is loaded on the browser implements a
security policy designed to minimise the risk of such unknown code.
Security policy is set of rules governing what scripts can do under
which circumstances.
Modern javascript security is based upon Java. Scripts downloaded are
isolated from the operating system and then executed. This is known
as the ‘sandbox’ model. Some scripts are often stored randomly here
and there. And hence, many times obtain more power than expected by
design or by accident.
Scripts in general are given limited access and more access is only
given with the user consent. Taking a consent for every execution is
not a practical solution.
Scripts from ‘trusted’ source are many times excluded from this
consent procedure.
A policy called ‘same origin’ does not block scripts coming from the
same origin as trusted scripts. This same origin check is performed on
all methods of windows object, also on embedded and externally
linked objects.
82
7.3 JAVASCRIPT OPERATORS
83
! Not Negation !(x==y) TRUE As x and y are
not equal.
String
+ Concatenation Connects If x = “5” x+y=“55”
two strings. and y= “5”
then
Conditional
? Variable If a = 0, a =8, If condition is
=(condition)? b=7 b =7 satisfied, first
value1:value2 a=(b= value is
=10)?5:8 assigned, else
the second
value is
assigned.
Short circuit evaluation
&& Sand Short circuit If x = 0; x = 66 If p is not null,
and p = 66 then assign
x=p && value of p to x.
p.getvalue()
84
New Creates new var x= new x becomes new instance of
instance of Fn() function Fn and gets all its
the object properties and methods.
Void Evaluates Void expr Undefined
expression .
and
return
s undefined
Output
85
7.4 JAVASCRIPT STATEMENTS
86
JavaScript Comments
88
Conditional statements
Conditional statements are used to perform different actions based on
different conditions.
In JavaScript we have the following conditional statements:
If statement - This statement is used to execute some code only if a
specified condition is true.
Syntax:
if (condition)
{
code to be execute difconditionis
true
}
If...elsestatement-This statement is used to execute some code if the
condition is true and another code if the condition is false
Syntax:
if (condition)
{
code to be executed if condition is true
}
else
{
code to be executed if condition is not true
}
If...else if ............... else statement - This statement is used to select
one of many blocks of code to be executed
Syntax:
if (condition1)
{
code to be executed if condition1 is true
}
89
else if (condition2)
{
code to be executed if condition2 is true
}
else
{
code to be executed if neither condition1 nor condition2 istrue
}
Example
Output
90
case 1:
execute code block 1 break;
case 2:
execute code block 2 break;
default:
code to be executed if n is different from case 1 and 2
}
Example:
Output
91
Loop statements
Loops execute a block of code a specified number of times, or while a
specified condition is true.
Often when you write code, you want the same block of code to run
over and over again in a row. Instead of adding several almost equal
lines in a script we can use loops to perform a task like this.
In JavaScript, there are two different kind of loops:
o for - loops through a block of code a specified number of times. It can
be used only when it is known in advance, how many times we have to
run the loop.
o while - loops through a block of code while a specified condition is
true.
For Loop Syntax:
for (variable=startvalue;variable<=endvalue;variabl
e=variable+increment)
{
code to be executed
}
Example:
Javascript given below will print 5 numbers. Each time, value of
the variable is incremented by 1.
92
While loop syntax
while(var<=end value)
{
code to be executed
}
While loop can be used with any comparison operator.
Do While loop is a variation to the while loop. In this case block will
be executed at least once, as the statements are executed before the
condition is tested. Syntax for do while is as follows–
do
{
code to be executed
}
while (var<=endvalue);
Consider the example where number is printed after incrementing
itby1.This is performed while the number is less than orequalto
5. Script and the outputs with while and do while loop are as given below
<html>
<body>
<script type="text/javascript">var i=6;
do
{
document.write("The number is " + i); document.write("<br />");
i++;
}
while (i<=5);
</script>
</body>
</html>
93
Changes in script with just while loop and corresponding output--
while (i<=5)
{
document.write("The number is " + i); document.write("<br />");
i++;
}
document.write(“value of i is printed outside the loop”);
document.write(“<br>\” + i);
94
Function
Function is a segment of program that performs a given task.
A function contains code that will be executed by an event or by a call
to the function.
You may call a function from anywhere within a page (or even from
other pages if the function is embedded in an external JavaScript file).
Functions can be defined both in the <head> and in the <body> section
of a document.
However, to assure that a function is read/loaded by the browser
before it is called, it should be put functions in the<head>section.
Syntax of the function is as follows–
function name(var1,var2,...,varX)
{
some code
}
Function always includes parenthesis after the name of function‘()’
95
Function calls are case sensitive as javascript is case sensitive.
The return statement is used to specify the value that is returned from
the function.
So, functions that are going to return a value must use the return
statement.
If a variable is declared using "var", within a function, the variable can
only be accessed within that function.
The variable is destroyed once function call is over. These variables
are called local variables. Local variables can have the same name in
different functions, because each is recognized only by the function in
which it is declared.
If a variable is declared outside a function, all the functions on your
page can access it.
The lifetime of these variables starts when they are declared, and ends
when the page is closed.
Following is an example of function. Function products computes and
returns product of variables a and b.
Basic advantage of using a function is reusability. Same task can be
performed again and again simply by calling the function which
performs the task.
Example:
96
7.5 COREJAVASCRIPT
Math object –
The Math object allows you to perform mathematical tasks.
The Math object includes several mathematical constants and methods.
round() – rounds the number to nearest integer value.
random() - returns a random number between 0 and1.
max() - returns the number with the highest value of two specified
numbers.
min() - returns the number with the lowest value of two specified
numbers.
Array –
An Array is an ordered collection of data values.
In JavaScript, an array is just an object that has an index to refer to its
contents. In other words, the fields in the array are numbered, and you
can refer to the number position of the field.
The array index is included in square brackets immediately after the
array name. In JavaScript, the array index starts with zero, so the first
element in an array would be array Name[0], and the third would be
array Name[2].
JavaScript does not have multi-dimensional arrays, but you can nest
them, which is to say, an array element can contain another array.
You access them listing the array numbers starting for the outmost
array and working inward. Therefore, the third element (position 2) of
or inside the ninth element (position 8) would bearrayName[8][2].
99
7.6 SUMMARY
7.7 EXERCISE
100
8
DOCUMENT AND ITS ASSOCIATED
OBJECTS &
EVENT AND EVENT HANDLERS
Unit Structure :
8.0 Objective
8.1 Document and associated objects
8.1.1 Document
8.1.2 Link
8.1.3 Area
8.1.4 Anchor
8.1.5 Image
8.1.6 Applet
8.1.7 Layer
8.2 Events and Event Handlers
8.2.1 General information about events
8.2.2 Defining event handlers
8.3 Event
8.3.1 on Abort
8.3.2 on Blur
8.3.3 on Change
8.3.4 on Click
8.3.5 on DblClick
8.3.6 on Drag Drop
8.3.7 on Error
8.3.8 on Focus
8.3.9 on Key Down
8.3.10 on Key Press
8.3.11 on Key Up
8.3.12 on Load
8.3.13 on Mouse Down
8.3.14 on Mouse Move
8.3.15 on Mouse Out
8.3.16 on Mouse Over
8.3.17 on Mouse Up
8.3.18 on Move
8.3.19 on Reset
101
8.3.20 on Resize
8.3.21 on Select
8.3.22 on Submit
8.3.23 on Unload
8.1 OBJECTIVE
8.1.1 Document
Each HTML document loaded into a browser window becomes a
Document object.
The Document object provides access to all HTML elements in a
page, from within a script.
The Document object is also part of the Window object, and can be
accessed through the ‘window. Document’ property.
Document object is part of document object model.
This model has a fixed hierarchy, where topmost object in the
hierarchy is Browser itself.
After browser window object and inside window, as shown below,
comes the document object.
Relation of document object to the window object can be depicted in
the fig given below –
102
|-> Document
|-> Anchor
|-> Link
|-> Images
|->Tags
|->Form
|-> Text-box
|-> Text Area
|-> Radio Button
|-> Check Box
|->Select
|->Button
Fig 8.3 Script and output Demonstrating write method and title
property of Document object.
104
Fig 8.4 Script Demonstrating the Document. open() method to open a
text stream
Fig 8.5 Output of the script Before and After Clicking the ‘New
Document’ button.
105
8.1.2 Link
The Link object represents an HTML link element.
The link element must be placed inside the head section of an HTML
document, and it specifies a link to an external resource.
In other words, link tag defines how a click on object can redirect or
take the browser window to a new location specified by the address
specified.
A common use of the <link> tag is to link to external style sheets.
Some of the properties of javascript link objects are as given below—
charset: -Sets or returns the character encoding of a linked document
href: -Sets or returns the URL of a linked document
hreflang:- Sets or returns the language code of the linked document
media: - Sets or returns the media type for the link element
type: - Sets or returns the content type of the linked document
In addition to above properties, link object supports all standard
properties like id, length, chartypeetc.
106
Fig 8.6 Script and Outputs Demonstrating length property of link
8.1.3 Area
The Area object represents an area inside an HTML image-map (an
image-map is an image with clickable areas).
For each <area> tag in an HTML document, an Area object is created.
In addition to standard properties and methods, javascript area object
supports following properties –
alt: Sets or returns the value of the alt attribute of an area
cords: Sets or returns the value of the coords attribute of an area
hash: Sets or returns the anchor part of the href attribute value
host: Sets or returns the hostname: port part of the href attribute value
hostname: Sets or returns the hostname part of the href attribute value
href: Sets or returns the value of the href attribute of an area
noHref: Sets or returns the value of the no href attribute of an area
pathname: Sets or returns the pathname part of the href attribute value
port: Sets or returns the port part of the href attribute value
protocol: Sets or returns the protocol part of the href attribute value
search: Sets or returns the query string part of the href attribute value
shape: Sets or returns the value of the shape attribute of an area
target: Sets or returns the value of the target attribute of an area
107
Following example shows an image map and returns the shape of an
area marked in the image map.
8.1.4 Anchor
The Anchor object represents an HTML hyperlink.
For each <a> tag in an HTML document, an Anchor object is created.
An anchor allows you to create a link to another document (with the
href attribute), or to a different point in the same document (with the
name attribute).
You can access an anchor by using get Element ById(), or by
searching through the anchors[] array of the Document object.
In addition to standard properties and methods, javascript anchor
object supports following properties–
108
charset Sets or returns the value of the charset attribute of a link href Sets
or returns the value of the href attribute of a link hre flang Sets or returns
the value of the hre flang attribute of a link name Sets or returns the value
of the name attribute of alink
rev Sets or returns the value of the rev attribute of a link target Sets or
returns the value of the target attribute of a link type Sets or returns the
value of the type attribute of alink
109
align : Sets or returns the value of the align attribute of an image
alt : Sets or returns the value of the alt attribute of an image
border : Sets or returns the value of the border attribute of an
image
complete :Returns whether or not the browser is finished loading an
image
height : Sets or returns the value of the height attribute of an image
hspace : Sets or returns the value of the hspace attribute of an image
longDesc :Sets or returns the value of the longdesc attribute of an image
lowsrc : Sets or returns a URL to a low-resolution version of an image
name : Sets or returns the name of an image
src : Sets or returns the value of the src attribute of an image
useMap : Sets or returns the value of the use map attribute of an image
vspace : Sets or returns the value of the vspace attribute of an image
width : Sets or returns the value of the width attribute of an image
110
Fig 8.9 Before and after using the anchor link.
8.1.5 Image
The Image object represents an embedded image.
For each <img> tag in an HTML document, an Image object is
created.
Notice that images are not technically inserted into an HTML page,
images are linked to HTML pages. The <img> tag creates a holding
space for the referenced image.
Image object, in addition to the standard properties and methods,
supports following properties and events.
Image ObjectEvents
111
Alt attribute gives the text to be displayed, if the image can not be
displayed.
Also, a lower version of image to speed up loading, can be shown
using a lowsrc option attribute.
Example:
Fig 8.10 source code for demonstrating some image properties and
attributes.
112
Fig 8.12 After click of the command buttons, border added and a
increased sized image.
8.1.6 Applet
Applet tag was used in earlier version of HTML (HTML4) to embed
anjavaappletina browser. It is not supported in HTML
5.0 and is replaced by the object tag.
The <object> tag defines an embedded object within an HTML
document. It is used to embed multimedia (like audio, video, Java
applets, ActiveX, PDF, and Flash) in your webpages.
You can also use the <object> tag to embed another webpage into your
HTML document.
You can use the <param> tag to pass parameters to plugins that have
been embedded using the <object>tag.
An object element must appear inside the body element. The text
between the <object> and </object> is an alternate text, for browsers
that do not support this tag.
At least one of the "data" and "type" attributes MUST be defined
where data specifies a URL that refers to the object's data and type
Specifies the MIME type of data specified in the data attribute.
(Multipurpose Internet Mail Extensions (MIME) is an Internet
113
standard that extends the format of email to support Text in
character sets other than ASCII, Non-text attachments, Message bodies
with multiple parts, Header information in non-ASCII character sets.
They are JavaScript code that are not added inside the <script> tags,
but rather, inside the html tags, that execute JavaScript when
something happens, such as pressing a button, moving your mouse
over a link, submitting a formetc.
The basic syntax of these event handlersis:
name_of_handler="JavaScript code here"
For example:
When events are associated with functions, the functions are written in
the head section within the <script> tag and are called from the event
handlers.
Example :
<html>
<body>
<h1 onclick="this.innerHTML='Welcome to
EventHandlers'">Click on this text</h1>
</body>
</html>
114
This code will generate following output–
8.3 EVENT
Fig 8.13 Script to demonstrate on mouse over event and its event
handler
116
Fig 8.14 Newly Loaded page
117
Fig 8.17 Cursor pointing venus.
8.4 EXERCISES