Unit I Website Basics
Unit I Website Basics
0 7
Web Essentials: Clients, Servers and Communication – The Internet – World wide web –
HTTP Request Message – HTTP Response Message – Web Clients – Web Servers –
HTML5 – Tables – Lists – Image – HTML5 control elements – Drag and Drop – Audio –
Video controls - CSS3 – Inline, embedded and external style sheets – Rule cascading –
Inheritance – Backgrounds – Border Images – Colors – Shadows – Text – Transformations
– Transitions – Animations. Bootstrap Framework
Server:
The software that distributes the information and the machine where the
information and software reside is called the server.
provides requested service to client
e.g., Web server sends requested Web page
Client:
The software that resides on the remote machine, communicates with
the server, fetches the information, processes it, and then displays it on
the remote machine is called the client.
initiates contact with server (speaks first)
typically requests service from server
Web client is implemented in browser
Web server: Software that delivers Web pages and other documents to
browsers using the HTTP protocol.
Website: A collection of pages on the World Wide Web those are accessible
from the same URL and typically residing on the same server.
1
URL: Uniform Resource Locator, the unique address which identifies
aresource on the Internet for routing purposes.
CLIENT-SERVER PARADIGM
The Client-Server paradigm is the most prevalent model for distributed
computing protocols. It is the basis of all distributed computing paradigms at a
higher level of abstraction.
It is service-oriented, and employs a request-response protocol.
2
3
TYPES OF CLIENT-SERVER ARCHITECTURE
4
this, providing that the tiers are logically separated can be hosted
(e.g. development and testing) on the same computer.
Advantages:
Ease in Developing Applications:
User Satisfaction:
Applicable for Homogeneous Environment:
High Performance:
Limitations:
The two tier architecture proved to be a good solution when user population
work is usually small (up to about 100 concurrent users) but it rapidly proved to
have a number of limitations:
Performance: Performance begins to deteriorate as the population
grows.
Security: Each user must have their own individual access to the
database, and be granted whatever rights may be required in order to
run the application.
Capability: Independent of the type of client, much of the data
processing has to be located in database making it totally dependent
upon the capabilities and implementation provided by the database
manufacturer.
Portability: As the two-tier architecture is dependent upon the specific
database implementation, porting an existing application to a different
DBMS becomes a major issue.
1) Three-Tier Architecture
In the three-tier architecture the functional process logic, data access,
computer data storage and user interface are developed and maintained
as independent modules on separate platform.
(i) Presentation Tier: Occupies the top level and displays information related
to service available on a website. This tier communicates with other tiers by
sending results to the browser and other tiers in the network.
5
(ii) Application Tier: Also called the middle tier, logic tier or business logic,
this tier is pulled from the presentation tier. It controls application functionality
by performing detailed processing.
(iii) Data Tier: Houses database server where information is stored and
retrieved. Data in this tier is kept independent of application servers or business
logic.
Advantages:
Improved Data Integrity
Enhanced Security
Hidden Database Structure
Limitations:
Complexity of Communication: Usually more efforts should be ensured
when creating 3-tier applications as the communication points are
increased (client to middle tier to server) and the performance increased
by tools like Visual Basics, Power Builder etc.
2) N-Tier Architecture
N Tier Architecture often referred as Multitier Architecture. It is
client-server architecture in which presentation, application
processing, and data management functions are physically separated.
it is an expanded form of three-tierarchitecture.
6
Advantages:
It provides a model by which developers can create flexible and reusable
applications. By segregating an application into tiers, developer acquires
the option of modifying or adding a specific layer, instead of reworking
the application.
Limitations:
Difficult to Implement: Due to componentization of tiers, the
complex structure is difficult to implement or maintain.
INTERNET:
The Internet is a massive network of networks that connects
millions of computers together globally. It forms a network in which any
computer can communicate with any other computer with the help of
TCP/IP protocol as long as they are both connected to the Internet.
IP ADDRESSING:
Each host on a TCP/IP network is assigned a unique 32 bit logical
address and it is called as Internet Protocol Address (IP Address). IP
address is used to identify a particular host on the internet.
FIREWALLS:
The hardware and software that sits between the internet and the local
network, checking all the data that comes in and out to make sure that it is
legitimate is called a Firewall.
The most basic firewall is a packet filter that inspects each packet coming in
or out of a network and uses a set of rules to determine whether that traffic is
allowed.
PROXY SERVERS:
A proxy server is computer that functions as an intermediary between a web
browser (such as Internet Explorer) and the Internet. Proxy servers help improve web
performance by storing a copy of frequently used webpages. When a browser requests
a webpage stored in the proxy server's collection (its cache), it is provided by the
proxy server, which is faster than going to the web. Proxy servers also help improve
security by filtering out some web content and malicious software.
8
GATEWAYS:
Gateway is a machine used to route packets form one network to
another network. In internet gateways provide all interconnections
between physical networks.
Gateways have two responsibilities:
1. Route packets based on network id to a gateway connected to that
network.
2. If they are connected to destination network, make sure that the packet
gets delivered to correct machine on that network.
u1 u2 u3 tec
cse ece it
Uniquely traced with the help of domain name space (http://www.cse.tec.ac.in)
9
HOW INTERNET WORKS?
The internet is a world-wide network of computers linked together by
telephone wires, satellite links and other means.
All computers on the internet can be divided into two categories: servers
and browsers.
Servers are where most of the information on the internet "lives". These are
specialized computers which store information, share information with other
servers, and make this information availableto the general public.
Browsers are what people use to access the World Wide Web from any
standard computer. Chances are, the browser you’re using to view this page is
either Netscape Navigator/Communicator or Microsoft Internet Explorer.
These are by far the most popular browsers, but there are also a number of
others in common use.
When you connect your computer to the internet, you are connecting to a
special type of server which is provided and operated by your Internet
Service Provider (ISP). The job of this "ISP Server" is to provide the link
between your browser and the rest of the internet. A single ISP server
handles the internet connections ofmany individual browsers - there may
be thousands of other people connected to the same server that you are
connected to right now.
The following picture shows a small "slice" of the internet with several home
computers connected to a server:
10
To view a web page from your browser, the following sequence happens:
1. You either type an address (URL) into your "Address Bar" or click on a
hyperlink.
2. Your browser sends a request to your ISP server asking for the page.
3. Your ISP server looks in a huge database of internet addresses and finds the
exact host server which houses the website in question, then sends that
host server a request for the page.
4. The host server sends the requested page to your ISP server.
5. Your ISP sends the page to your browser and you see it displayed on your
screen.
11
BASIC INTERNET PROTOCOLS
Definition: Protocol
A protocol can be defined as the set of rules
governing the syntax, semantics and
synchronization of communication between
two end points.
Some common protocols used in Internet
Communications:
12
ends must establish a connection between each other.
Reliable Service – It uses the acknowledgement mechanism to ensure the safe
and sound arrival of data.
TCP Segment Format:
Header Data
The unit of data transfer between two devices using TCP is called as
Segment. The segment consists of 20 to 60 byte header followed by data from
the application program.
2. User Datagram Protocol (UDP):
Destination Port Number: 16 bit port number used by the process running
on the destination host.
Length: 16 bit field that defines the total length of the user datagram [header
+ data].
Checksum: This field is used to detect errors over the entire user datagram
[header+data]. This ensures that the fields have not changed from the source to
destination.
Applications:
IP Header Format:
Protocol Version(4 bits) : This is the first field in the protocol header.
This field occupies 4 bits. This signifies the current IP protocol version being
used.
Header Length(4 bits) : This field provides the length of the IP header. The
length of the header is represented in 32 bit words.
Uses of IP Protocol:
Addressing
While sending datagrams, an addressing mechanism is needed to send the
datagrams accurately. In order to achieve this, IP uses a technique for host
addressing. The addressing of devices (to which the datagrams are delivered)
needs to be unique as this system needs to work across networks.
Routing
When a datagram is sent from one network to another, which aredistant and not
directly connected, the delivery is indirect. IPsupports this functionality
by routing the datagram through intermediate devices
(routers). It uses Internet Control MessageProtocol (ICMP) and routing protocols
like Routing Information Protocol (RIP) and Border Gateway Protocol (BGP) to
achieve this. DATA Encapsulation
IP provides security to networks by encapsulating the data into an IP
datagram. This makes sure it is received and interpreted by the intended
recipient.
Formatting/Packaging
IP uses a specific formatting and packaging prior to transmission. IP
accepts data from the transport layer protocols above it in the OSI layer--
UDP and TCP--and passes them to the data layers. This format and package
is only decipherable by the recipient.
Fragmentation
Since the frame size of each physical and data link network usingIP may be
different, IP fragments datagrams into pieces, so that they can each be
carried on the local network. This helps with network reliability.
Reassembly
IP reassembles the datagrams received into the full IP datagram (as they may
be fragmented) for the receiving device and passes it on to the higher layers
for interpretation.
Internet WWW
Internet is a massive WWW is a way of accessing
Definition network of networks, a information over the
networking infrastructure medium of the internet
It connects millions of
computers together
globally forming a network
It is an information sharing
in which any computer can
Purpose communicate with any model that is built on the
other computer as long as top of internet.
both are connected to
internet
Name of the
ARPANET NSFnet
first version
Network of computers,
Files, folders & documents
Comprises copper wires, fiber-optic
cables 7 wireless networks stored in various computers
Governed Hyper Text Transfer
Internet Protocol
by Protocol
This is the base, It depends on internet to
Dependency
independent of the WWW work
Created by Tim Berners Lee
Creator No such creator
in 1992.
Nature Hardware Software
1.4 HTTP: Hyper Text Transfer Protocol
Start line
Header Field(s)
Blank line
Optionally, a message body
301 - Moved Permanently The resource has permanently moved to a different URI.
404 - Not Found The requested resource does not exist on the server.
408 - Request Timeout The client failed to send a request in the time allowed by
the server.
WEB SERVER:
A Web Server is basically a computer that is designed to
accept requests from remote computers and send on the
information requested over the internet. It is also used to host
website / web application.
29
30
31
WEB SITE:
A Web Site is a set of interconnected webpages on WWW that
includes a beginning file called homepage.
Web sites are accessed by using URLs provided by the authority of
the web site.
Web sites are generally located on the same server, and prepared
and maintained as a collection of information by a person, group, or
organization.
Example: http://www.w3schools.com
DIFFERENCE BETWEEN WEB SERVER AND WEB SITE:
WEB APPLICATION:
A web application or web app is any computer program that runs in a
web browser. It is created in a browser-supported programming language
(such as the combination of JavaScript, HTML and CSS) and relies on a
web browser to render the application.
It is usable only with an active Internet connection
It uses HTTP as its primary communications protocol.
Examples: Online ticket booking applications, Online games, google
docs, etc.,
32
Advantages of HTML:
1. It is plain text so is easy to edit.
2. It is also fast to download.
3. Is very easy to pick up\learn .
4. It is now a standard.
5. It is supported by most browsers.
6. Simple to edit only requires a text editor.
7. Can be easily edited with WYSIWYG editors (no coding required) .
8. Can be used to present just about any kind of data.
9. Tags can be used very loosely (i.e. used to be able to omit end tags
etc).
10. It is user friendly.
11. It is open technology.
Disadvantages of HTML:
1. It can create only static and plain pages so if we need dynamic
pages then HTML is not useful.
2. It is static needs to be manually updated or needs some
scripting support to change it in some way.
3. Need to write lot of code for making simple webpage.
4. Security features are not good in HTML.
5. If we need to write long code for making a webpage then it
produces some complexity.
33
<head>
<title> title of the page </title> Head Section
</head>
<body>
Page design goes here Body Section
</body>
<html>
Common Declarations
HTML 4.01:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
XHTML 1.0:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
34
HTML CONSTRUCTS:
There are two main constructs in HTML:
1. Elements (also called tags)
2. Entities.
1. Elements:
HTML tags are keywords (tag names) surrounded by angle
brackets. HTML element or tag is a signal to the browser that it
should do something other than just throwing text on the screen. Tags
are descriptions that are embedded directly into the informational text
of the document.
Syntax: <tagname>content</tagname>
35
<applet width=‖100‖
height=‖100‖>
3. Entities:
Entities are character sequences that reproduce special
characters on the browser screen.
Reserved characters in HTML must be replaced with characterentities
(references).
If you use the less than (<) or greater than (>) signs in your text,the
browser might mix them with tags.
Character entities are used to display reserved characters inHTML.
A character entity looks like this:
&entity_name; OR &#entity_number;
3. <base> tag:
Type: Standalone tag
Function: Specifies the base URL of the document.
Syntax:
<base href=‖base-url‖> (or) <base target=‖frame_name‖>
Target – specifies the default frame name to which all the linked
documents should be loaded.
Related Tags: None.
4. <link> tag:
Type: Standalone tag
Function: Makes a link between an external source and this html
file.
Syntax: <link href=‖url-of-the-linked-file‖
title=‖title‖ rel=‖forward-relationaship‖ rev=‖reverse-
relationship‖>
Attributes:
Href – denotes the URL of the file to be linked.
Title – gives the link a descriptive title.
38
Attributes:
language – Scripting language used to write the script.
src – Specifies the URL of a file containing the script code, if
the code is not written between <script> and </script> tags.
type – MIME type of the script code.
Example:
<head>
<script src=‖external.js‖ type=‖text/javascript‖></script>
</head>
Example:
<body bgcolor=‖yellow‖ >
<body bgcolor= ‖#0000FF ‖ >
<body background=‖flower1.jpg‖>
40
FORMATING TAGS:
1. <b> tag:
Type: Container tag
Function: Makes the enclosed text bold.
Syntax: <b> text </b>
Attributes: None
Example:
<b> Welcome </b>
2. <i> tag:
Type: Container tag
Function: Makes the enclosed text italic.
Syntax: <i> text </i>
Attributes: None
Example:
<i> Welcome </i>
3. <u> tag:
Type: Container tag
Function: Makes the enclosed text underlined.
Syntax: <u> text </u>
Attributes: None
Example:
<u> Welcome </u>
4. <big> tag:
Type: Container tag
Function: Renders the text in the font size bigger than the default
font size.
Syntax: <big> text </big>
Attributes: None
Example: <big> Welcome </big>
5. <small> tag:
Type: Container tag
Function: Renders the text in the font size smaller than the
default font size.
Syntax: <small> text </small>
Attributes: None
Example:<small> Welcome </small>
41
7. <sub> tag:
Type: Container tag
Function: contains the text to be subscript to the text that
precedes it.
Syntax: <sub> text </sub>
Attributes: None
Example:
a<sub>1</sub>, a<sub>2</sub>
8. <sup> tag:
Type: Container tag
Function: contains the text to be super script to the text that precedes it.
Syntax: <sup> text </sup>
Attributes: None
Example:
a<sup>1</sup>, a<sup>2</sup>
9. <font> tag:
Type: Container tag
Function: contains the text whose font properties are to be
modified.
Syntax: <font size=‖size‖ color=‖color‖ face=‖font-face-type‖>
text </font>
Example:
<font face=‖Calibri‖ size=‖25pt‖ color=‖green‖> Welcome
</font>
10.<br> tag:
Type: Empty tag
Function: Inserts a line break in the document.
Syntax: <br/>
Example:<font face=‖Calibri‖ size=‖25pt‖color=‖green‖> Welcome
</font> <br/>
42
Downloaded from EnggTree.com
EnggTree.com
11.<center> tag:
Type: Container
tag
Function: Centers all the text and other page components.
Syntax: <center> text </center>
Example:
<center> <font face=‖Calibri‖ size=‖25pt‖ color=‖green‖>
Welcome </font> </center>
44
Output:
Heading 1
Heading 2
Heading 3
Example:
<!DOCTYPE html>
<html>
<body>
<h1> Heading 1 </h1>
<h2> Heading 2 </h2>
<h3> Heading 3 </h3>
<h4> Heading 4 </h4>
<h5> Heading 5 </h5>
<h6> Heading 6 </h6>
</body>
</html>
Output:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
1. <p> tag:
Type: Container tag
Function: denotes a paragraph.
Syntax: <p align=‖ LEFT | RIGHT | CENTER‖> paragraph text
</p>
Attributes:
Align – LEFT | RIGHT | CENTER. Controls the alignment
of the text in the paragraph.
Example:
<p align=‖center ‖ title=‖Greetings ‖> Welcome</p>
47
<pre
>
Welcome
To
HTML
</
pre>
</
body
>
</
html
>
O
u
t
p
u
t
:
Welcome To HTML
Welcome
To
HTML
18.<span> tag: Type:
Container tag
Function: Generic tag for defining document block. Used for
applying style information.
Syntax:
<span style=‖style-information‖ align=‖LEFT|RIGHT|CENTER‖>
Text
</span>
Example:
<span style=‖font-weight:bold; color:red;>
Welcome
To
HTML
</span>
48
Tables are used for presenting data in tabular form i.e. to organizedata into
rows and columns.
The fundamental building blocks of a table are cells, which can
contain either a data element or a heading for a column of data.
Columns and rows will automatically size to contain their data.
Individual table cells can span multiple rows or columns.
Header and footer rows can be supplied.
HTML Table Tags:
Tag Name Meaning Tag Name Meaning
table Represents start of a tbody Defines the table
table body
caption Describes the table tr Represents a table
content row
thead Defines the header th Represents a column
section header
tfoot Defines the footer td Defines data in the
section cell
49
Attribute Meaning
Align Specifies table alignment. An have values: left,
right, and center
Border Specifies the thickness of the table border in
number of pixels
Background Specifies the URL of the background image
Bordercolor Specifies the color of the table border. color
names or hexadecimal color codes are allowed
Bgcolor Specifies the background color of the table. color
names or hexadecimal color codes are allowed
Height Specifies the height of the table in pixels
Width Specifies the width of the table in pixels
Cols Specifies the number of columns to be created in
the table
Cellpadding Specifies the amount of space in number of
pixels between the cell border and its content
Cellspacing Specifies the amount of space in number of
pixels between table cells.
frame Specifies whether a frame around the table
should be created or not
50
Attributes of tr tag:
Attribute Meaning
Align Specifies the horizontal alignment of the content of
all cells in this row. Can have values: left, right and
center. Default value is left.
Bordercolor Specifies the border color of all cells in this row. color
names or hexadecimal color codes are allowed
Bgcolor Specifies the background color of all cells in this row.
color names or hexadecimal color codes are allowed
Height Specifies height, in pixels, of all cells in this row
Width Specifies width, in pixels, of all cells in this row
valign Specifies the vertical alignment of the content of all
cells in this row. Can have values: top, bottom and
middle. Default value is middle.
51
3. <td> Element:
Attribute Meaning
Align Specifies the horizontal alignment of the content of
all cells in this row. Can have values: left, right and
center. Default value is left.
Bordercolor Specifies the border color of all cells in this row. color
names or hexadecimal color codes are allowed
Bgcolor Specifies the background color of all cells in this row.
color names or hexadecimal color codes are allowed
Height Specifies height, in pixels, of all cells in this row
Width Specifies width, in pixels, of all cells in this row
valign Specifies the vertical alignment of the content of all
cells in this row. Can have values: top, bottom and
middle. Default value is middle.
Colspan Specifies the number of columns this cell must span
rowspan Specifies the number of rows this cell must span
52
Example:
<!DOCTYPE html>
<html>
<head>
<title>Simple Table Demo</title>
</head>
<body>
<table border="1" width="20%">
<caption><strong>Price of Fruits</strong></caption>
<thead>
<tr>
<th>Fruit</th>
<th>Price</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Total</th>
<th>$3.75</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Orange</td>
<td>$0.50</td>
</tr>
<tr>
<td>Banana</td>
<td>$1.00</td>
</tr>
<tr>
<td>pineapple</td>
<td>$2.00</td>
</tr>
<tr>
<td>Apple</td>
53
<td>$0.25</td>
</tr>
</tbody>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Simple Table Demo</title>
</head>
<body>
<table border="1" width="20%">
<caption><strong>Price of Fruits</strong></caption>
<thead>
<tr>
<th>Fruit</th>
<th>Price</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Total</th>
<th>$3.75</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Orange</td>
<td>$0.50</td>
</tr>
<tr>
<td>Banana</td>
<td>$1.00</td>
</tr>
<tr>
<td>pineapple</td>
<td>$2.00</td>
</tr>
<tr>
<td>Apple</td>
54
Year Subjects
Name
Branch TOC IP
Rowspan Colspan
<td rowspan=‖2‖>Name</td>
<td colspan=‖2‖>Subjects</td>
<td>Year</td><td>Branch</td>
<td>TOC</td><td>IP</td>
Example:
<html>
<head>
<title>Complex Table</title>
</head>
<body>
<table border="1" bgcolor="#FF9900">
<caption> Comparison of districts in Tamil nadu</caption>
<thead>
<tr>
<th rowspan="2"><img src="tamil-nadu-map.jpg" width="150"
height="150"></th>
<th colspan="3"><h1> District comparison in Tamil
nadu</h1></th>
</tr>
<tr>
<th>District</th>
<th>Population</th>
55
<th>Growth</th>
</tr>
</thead>
<tbody align="center">
<tr>
<th>1</th>
<td>Chennai</td>
<td>464673</td>
<td>6.98 %</td>
</tr>
<tr>
<th>2</th>
<td>Coimbatore</td>
<td>3458045</td>
<td>18.56 %</td>
</tr>
<tr>
<th>3</th>
<td>Madurai</td>
<td>3038252</td>
<td>17.84 %</td>
</tr>
</tbody>
</table>
</body>
</html>
56
57
</cetner>
</body>
</html>
58
INTERNAL LINKING:
Internal linking is a mechanism that enables the user to jump
between locations in the same document.
Internal linking is useful for long documents that contain many
sections.
59
60
3
4
5
6
7
8
9
10
</pre>
</font>
<center><a href="#top"> Go Up</a></center>
<hr color="orange">
<h1><a name="upper"><font color="yellow">UPPERCASE
ALPHABETS</font></a>
</h1>
<font size=5pt>
<pre>
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
61
U
V
W
X
Y
Z
</pre>
</font>
<center><a href="#top"> Go Up</a></center>
<hr color="orange">
<h1><a name="lower">
<font color="yellow">LOWERCASE ALPHABETS</font></a></h1>
<font size=5pt>
<pre>
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
62
x
y
z
</pre>
</font>
<center><a href="#top"> Go Up</a></center>
<hr color="orange">
</body>
</html>
Bullet Options:
Bullet Options Meaning Result
<ul> Default bullet shape is disc One
Two
<ul type=‖disc‖> Disc shaped bullets are used One
Two
<ul type=‖circle‖> Circle shaped bullets are used o One
63
o Two
<ul Square shaped bullets are used One
type=‖square‖> Two
2. Ordered Lists:
Numbering Options:
Numbering Numbering
Meaning Result Meaning Result
options options
Use
Use default
1. One <ol lowercase a. One
<ol> number
2. Two type=‖a‖> letters for b. Two
type
numbering
Use
Use default <ol lowercase
<ol 1. One d. One
number type=‖a‖ letters
type=‖1‖> 2. Two e. Two
type start=‖4‖> stating
from d
Use
Use small
<ol uppercase A. One <ol i. One
roman
type=‖A‖> letter for B. Two type=‖i‖> ii. Two
numbers
numbering
<ol Use default 3. One <ol type=‖i‖ Use small ii. One
type=‖3‖> number 4. Two start=‖2‖> roman iii. Two
64
starting numbers
form 3 starting
from ii
Use
Use
<ol uppercase
D. One <ol capital I. One
type=‖A‖ letters
E. Two type=‖I‖> roman II. Two
start=‖4‖> starting
numbers
from D
3. Definition List:
A definition list is the one where list items consist of two parts:
o a term
o its description
Definition List is created using <dl> tag.
The term part and the definition part of each item are created
using <dt> (definition term) and <dd> (definition description)
tags respectively.
Example:
<dl>
<dt> dl tag </dt>
<dd> it is the outermost tag of definition list</dd>
<dt> dt tag </dt>
<dd> Contains the item to be described</dd>
<dt> dd tag </dt>
<dd> Contains description of the item</dd>
<dd> Each term may have multiple descriptions</dd>
</dl>
dl tag
it is the outermost tag of definition
list
dt tag
Contains the item to be described
dd tag
Contains description of the item
Each term may have multiple
descriptions
65
NESTED LISTS:
Lists may be nested to represent hierarchical relationships.
A web browser indents each nested list to indicate a hierarchical
relationship.
Any of the three types of lists may be nested in another.
Arbitrary levels of nesting is possible
<!DOCTYPE html>
<html>
<head>
<title> List Example</title>
</head>
<body bgcolor="violet">
<center>
<h1> ABC ENGINEERING COLLEGE</h1>
</center>
<hr color="blue">
<ul>
<li> U.G Courses
<ol>
<li> B.E - CSE </li> Inner List
<li> B.E - ECE </li>
</ol>
</li>
<li> P.G Courses
<ol>
Outer List
<li> M.E - CSE </li>
<li> M.E - SE </li>
<li> MBA </li> Inner List
<li> MCA </li>
</ol>
</li>
</ul>
<hr color="red">
66
<ul type="square">
<li>
<dl>
<dt> CSE </dt>
<dd> Computer Science and
</dl> Engineering</dd>
</li>
<li>
<dl>
<dt> ECE</dt>
<dd> Electronics and
Communication
Engineering</dd>
</dl>
</li>
<li>
<dl>
<dt> SE </dt>
<dd> Software Engineering</dd>
</dl>
</li>
</ul>
</body>
</html>
Output:
67
Downloaded from EnggTree.com
EnggTree.com
CCS375-Web Technologies Unit – 1 V Semester CSE
HTML Forms
<form> ELEMENT:
The <form> element is used to create a form.
Syntax:
<form name=‖form_name‖ accept=‖MIME _type‖
action=‖URL_of_the_Script‖
Method=‖GET|POST‖ target=‖frame_name‖ >
- Form elements --
</form>
Attributes:
Attribute Description
accept- charset Specifies the charset used in the
submitted form (default: the page
charset).
Specifies an address (url) where to submit the
action form (default: the submitting page).
Specifies if the browser should autocomplete the form
autocomplete (default: on).
Specifies the encoding of the submitted data (default:
enctype is url-encoded).
68
Downloaded from EnggTree.com
EnggTree.com
Example:
<form name=‖form1‖ method=‖get‖
action="action_page.php">
----- form elements ----
</form>
<input> ELEMENT:
The <input> element is the most important form element.
The <input> element has many variations, depending on the type
attribute.
<html>
<body>
<form action="">
User name:<br>
<input type="text" name="userid">
<br>
User password:<br>
<input type="password" name="psw">
</form>
<p>The characters in a password field are masked (shown as
asterisks or circles).</p>
</body>
</html>
TEXTAREA ELEMENT:
This control allows the user to enter multiple lines of data.
It is generated on the web page using <textarea> and </textarea>
tag pair.
Size of the textarea is specified usingthe two attributes rows and
cols.
72
SELECT ELEMENT:
A menu is defined using ―select‖ element. It defines the drop-down
list.
It is used to produce scrollable option menus.
Syntax:
<select name=”Name” [size=”size”] [MULTIPLE] >
<option value=”value” [selected] > Option1
</option>
<option value=”value” [selected] > Option2
</option>
</select>
Option element is used to define the options to select.
[selected] attribute is used to specify which option should be
selected by default (predefined option).
Example:
<form action="action_page.php">
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
<br><br>
<input type="submit">
</form>
<label> Gender:
<input type="radio" name="gender" />Male
<input type="radio" name="gender" />Female </label><br />
<label> D.O.B: <input type="date" name="bday" /> </label>
<br />
<label> Qualification:
<select>
<option value="be">B.E</option>
<option value="ba">B.A</option>
<option value="bcom">B.COM</option>
<option value="bba">B.B.A</option>
</select></label>
<br />
<label> Hobbies:
<input type="checkbox" name="c1" />Playing
<input type="checkbox" name="c2" />Singing
<input type="checkbox" name="c3" />Dancing </label> <br />
Downloaded 80
from EnggTree.com
EnggTree.com
CCS375-Web echnologies Unit – 1 V Semester CSE
81
Downloaded from EnggTree.com
EnggTree.com
CCS375-Web echnologies Unit – 1 V Semester CSE
1. <datalist> Element:
The <datalist> element specifies a list of pre-defined options for an
<input> element.
Users will see a drop-down list of pre-defined options as they input
data.
The list attribute of the <input> element, must refer to the id
attribute of the <datalist> element.
Example
An <input> element with pre-defined values in a <datalist>:
<form action="action_page.php">
<input list="browsers">
<datalist id="browsers">
<option value="Internet
Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</form>
2. <keygen> Element:
The purpose of the <keygen> element is to provide a secure way to
authenticate users.
The <keygen> element specifies a key-pair generator field in a form.
When the form is submitted, two keys are generated, one private
and one public.
The private key is stored locally, and the public key is sent to the
server.
The public key could be used to generate a client certificate to
authenticate the user in the future.
3. <output> Element:
The <output> element represents the result of a calculation (like
one performed by a script).
Example:
<form action="action_page.asp"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0
<input type="range" id="a" name="a" value="50">
100 +
<input type="number" id="b" name="b" value="50">
=
<output name="x" for="a b"></output>
<br><br>
<input type="submit">
</form>
Input Restrictions:
Here is a list of some common input restrictions (some are new in
HTML5):
Tag Description
<details> Defines additional details that the user can view or hide
Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>...</title>
</head>
<body>
<header role="banner">
<h1>HTML5 Document Structure Example</h1>
<p>This page should be tried in safari, chrome or Mozila.</p>
</header>
<nav>
<ul>
<li><a href="http://www.tutorialspoint.com/html">HTML
Tutorial</a></li>
<li><a href="http://www.tutorialspoint.com/css">CSS
Tutorial</a></li>
<li><a
href="http://www.tutorialspoint.com/javascript">JavaScript
Tutorial</a></li>
</ul>
</nav>
<article>
<section>
<p>Once article can have multiple sections</p>
</section>
</article>
<footer>
<p>Created by <a href="http://tutorialspoint.com/">Tutorials
Point</a></p>
</footer>
</body>
</html>
The DataTransfer object holds data about the drag and drop
operation. This data can be retrieved and set in terms of various
attributes associated with DataTransfer object as explained below –
<!DOCTYPE HTML>
<html>
<head>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev)
{ ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</body>
</html>
<audio> element:
The HTML5 <audio> element specifies a standard way to embed audio in
a web page. To play an audio file in HTML, use the <audio> element:
<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
<video> element:
The HTML5 <video> element specifies a standard way to embed a video in
a web page. To show a video in HTML, use the <video> element:
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
The controls attribute adds video controls, like play, pause, and
volume.
It is a good idea to always include width and height attributes.
If height and width are not set, the browser does not know the size
of the video. The effect will be that the page will change (or flicker)
while the video loads.
Text between the <video> and </video> tags will only display in
browsers that do not support the <video> element.
Multiple <source> elements can link to different video files. The
browser will use the first recognized format.
Definition:
Cascading Style Sheet (CSS) is a W3C technology that allows document
authors to specify the presentation of elements on a web page (e.g fonts, spacing,
colors) separately from the structure of the document (section headers, body, links).
This separation ofstructure from presentation simplifies maintaining and modifying
a web page.
1. CSS allows separation between the information contained in the document and its
presentation. Hence any change in the presentation can be made without disturbing
the information of the document.
2. Style Sheets allow users to decide the style of presentation. This presentation style
can be defined in a separate file. Thus the presentation can be made persistent.
3. CSS allows the developer to give the consistent appearance to all the elements of
the web page.
4. CSS allows us to improve the consistent look and feel of a web site.
5. CSS provides precise control over font size, color, background color and so on.
</style>
TYPES OF SELECTOR STRING:
1. Type Selector:
It is the simplest form of selector string which consists of the name of a single element.
A rule can also apply to multiple elements types separating the elements by using comma (,)
Example:
h1, p {background-color:purple}
2. Universal Selector:
It is denoted by an asterisk (*).
A rule denoted by universal selector can be applied for every possible element in
the document.
Example:
* {background-color:purple; font-weight:bold}
3. Id Selector:
A selector preceded by a number sign (#) is called an ID selector.
It represents an id value rather than an element type name.
A rule defined by the ID selector can be applied to the element that matches with the
id attribute value with the ID selector string.
Example:
<style type=”text/css”>
#myid {background-color:green}
</style>
4. Class Selector:
A selector preceded by a period or dot (.) is called an Class selector.
It represents a generic value rather than an element type name.
A rule defined by the class selector can be applied to the element that matches with the class
attribute value with the Class selector string.
Example:
<style type=”text/css”>
.myclass {background-color:red}
</style>
<p class=”myclass”>
This is an class selector
</p>
Note: Class selectors can also be prefixed by an element name which restricts the selector
toelements of the specified type.
5. Pseudo classes:
Using pseudo-classes we can specify special effects on the selectors.
There are some pseudo classes which are more commonly used and those
are: Focus
Hover
hyperlink
General form of pseudo class and pseudo element:
Selector:pseudo-class { declaration
This rule will first read the rules form the specified file “filename.css” before continuing
with the other rule in the style sheet.
@import rule must appear at the beginning of the style sheet before any ruleset statements
and it must end with semicolon (;).
Links.css
a:hover {font-size:200%}
a:active {color:yellow}
a:visited {color:green}
mystyle.css
@import url("links.css");
li { font-size: 14pt; line-height: 25pt }
* { font-family: verdana }
.unorder { background-color:yellow }
#order { background-color:violet }
dl dd {color:blue}
lists.html
<!DOCTYPE html>
<html>
<head>
<title> List Example</title>
</head>
<link href="mystyle.css" rel="stylesheet" type="text/css">
<body >
<center>
<h1 color="green"> ABC ENGINEERING COLLEGE</h1>
</center>
<hr color="blue">
<ul id="order">
<li> U.G Courses
<ol class="unorder">
<li> B.E - CSE </li>
<li> B.E - ECE </li>
</ol>
</li>
<li> P.G Courses
<ol class="unorder">
<li> M.E - CSE </li>
<li> M.E - SE </li>
<li> MBA </li>
<li> MCA </li>
</ol>
</li>
</ul>
<hr color="red">
<ul type="square">
<li>
<dl>
<dt> <a href="">CSE </a></dt>
<dl>
</dl>
</li>
</dl>
<li> </li>
<dl> </ul>
</body>
</html>
</dl>
</li>
<li> <dd> Software Engineering</dd>
<head>
</head>
Example:
Style1.css
.heading
{
font-family: Arial, Helvetica, sans-serif;
background-color:violet;
color:blue;
}
Style_types.html
<!DOCTYPE html>
<html>
<head>
<title>Types of Style Sheets</title>
<style type="text/css">
h1 { font-weight:bold; font-size:12px; color:red }
</style>
<link href="style1.css" type="text/css" rel="stylesheet">
</head>
<body bgcolor="pink">
<center>
<h2>TYPES OF STYLE SHEETS</h2>
<hr>
<p style="background-color:yellow;text-decoration:underline">
This is Inline Style Sheet
</p>
<hr>
<h1> This is Embedded / Internal Style Sheet</h1>
<hr>
<h1 class="heading">This is External Style Sheet</h1>
<hr>
</center>
</body>
</html>
RULE CASCADING:
Consider the following declarations:
* { font-weight: bold } – this rule applies to every element of te HTML document.
#p1, #p3 { background-color:aqua } - both the rules are applied to to an element with id
attribute value p3 and p1.
If multiple rules apply to an element and these rules provide declarations for different properties,
then all of the declarations are applied to the element.
What will happen if multiple declarations that all apply to a single property of a single
element are available?
In order to choose between multiple declarations, the browser applies Rule Cascading. It
is a multi-stage sorting process that selects a single declaration that will supply the property
value.
Mypage.html
<html>
<head>
<style type=”text/css”>
P {color:red }
</style>
<link rel=”stylesheet” type=”text/css” href=”style1.css”>
<style type=”text/css”>
P {color: yellow}
</style>
</head>
In the above example, we find multiple declarations for the same property that all apply to the
same element.
p {color:red }
p {color:blue
}
p {color:green }
p {color: yellow} This declaration is selected and the text will be
displayed in yellow color.
STYLE INHERITANCE:
Rule Cascading is based on the structure of the style sheets.
Inheritance is based on the tree structure of the document.
If a value for a style option has not been specified for an element, the element will inherit
the style property form its parent.
If the parent element does not specify the style rule, it inherits from the grand parent and
so on up to the top-level element (either <html> tag or the element with style property).
Inherited style can be overridden by declaring specific style to the child.
Example:
Example:
<!DOCTYPE html>
<html>
<head>
<title>CSS Backgound</title>
<style type="text/css">
p{
background-color:#99FF99;
background-attachment:fixed;
}
</style>
</head>
<body>
<center> <h1> CSS Backgorund Property</h1>
<p> This paragraph contains a beatiful background image. </p>
<div>ABCD EFG.... HIJK LMNOP... QRSTUVW.....UVW
XYZ.</div>
</body> </center>
</html>
ridge: Defines a 3D ridged border. The effect depends on the border-color value inset:
outset: Defines a 3D outset border. The effect depends on the border-color value
Border Width: The border-width property is used to set the width of the border.
The width is set in pixels, or by using one of the three pre-defined values: thin, medium, or thick.
border-style: dotted;
o all four borders are dotted
Example:
p{
border: 5px solid red;
}
<!DOCTYPE html>
<html>
<head>
<style>
p.normal {
border: 2px solid red;
}
p.round1 {
border: 2px solid red;
border-radius: 5px;
}
p.round2 {
border: 2px solid red;
border-radius: 8px;
}
p.round3 {
border: 2px solid red;
border-radius: 12px;
}
</style>
</head>
<body>
Tip: The border-image property is actually a shorthand property for the following
properties:
o border-image-source,
o border-image-slice,
o border-image-width,
border-image-outset Specifies the amount by which the border image area extends
beyond the border box
Example:
<!DOCTYPE html>
<html>
<head>
<style>
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
border-image: url(grid.png) 20%
repeat; background-color:yellow
}
#borderimg2 {
border: 50px solid transparent;
padding: 15px;
border-image: url(rose.jpg) 20% repeat;
color:blue;
font-size:25px
}
#borderimg3 {
</body>
</html>
Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.
2) HEX Colors
A hexadecimal color is specified with: #RRGGBB, where the RR (red), GG (green) and
BB (blue) hexadecimal integers specify the components of the color.
HEX Value
In CSS, a color can be specified using a hexadecimal value in the form:
#rrggbb
Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff
(same as decimal 0-255).
For example, #ff0000 is displayed as red, because red is set to its highest value (ff) and
the others are set to the lowest value (00).
3) HSL Colors
HSL stands for hue, saturation, and lightness.
HSL Value
In CSS, a color can be specified using hue, saturation, and lightness (HSL) in the form:
hsl(hue, saturation, lightness)
Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue.
Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color.
Lightness is also a percentage, 0% is black, 50% is neither light or dark, 100% is white
Saturation
Saturation can be described as the intensity of a color.
100% is pure color, no shades of gray
50% is 50% gray, but you can still see the color.
0% is completely gray, you can no longer see the color.
With CSS you can add shadow to text and to elements with the help of the following properties:
1. text-shadow
2. box-shadow
1. Text Shadow
The CSS text-shadow property applies shadow to text.
In its simplest use, you only specify the horizontal shadow (2px) and the
vertical shadow (2px).
Multiple Shadows
To add more than one shadow to the text, you can add a comma-separated list of
shadows.
The following example shows a red and blue neon glow shadow:
2. box-shadow
The CSS box-shadow property applies shadow to elements.
In its simplest use, you only specify the horizontal shadow and the vertical
shadow.
Example:
<!DOCTYPE html>
<html>
<head>
<title> CSS Text Properties</title>
<style type="text/css">
p.test1 {
color:green;
text-align:center;
text-decoration:underline;
text-indent::10pt;
text-shadow:red;
text-transform:capitalize;
direction:rtl;
letter-spacing:5px;
}
</style>
</head>
<body>
<center><h1>CSS Text Properties</h1></center>
<p class="test1">abcd efgh ijkl mnop qrst uvw xyz</p>
</body>
</html>
Text Overflow:
The CSS3 text-overflow property specifies how overflowed content that is not displayed
should be signaled to the user.
Word Wrapping:
The CSS3 word-wrap property allows long words to be able to be broken and wrap onto
the next line. If a word is too long to fit within an area, it expands outside.
Word Breaking:
The CSS3 word-break property specifies line breaking rules.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
p.test1
{
width: 140px;
border: 1px solid
#ff00ff; word-break:
keep-all;
p.test2 {
width: 140px;
border: 1px solid #00ff00;
word-break: break-all;
Downloaded from EnggTree.com
EnggTree.com
CCS375-Web echnologies Unit – 1 V Semester CSE
}
p.test3 {
white-space:nowrap;
width: 140px;
border: 1px solid #0000ff;
overflow:hidden;
text-overflow:clip;
}
p.test4 {
width: 140px;
border: 1px solid
#f0f0f0; word-
wrap:break-word;
}
</style>
</head>
<body>
</body>
</html>
generic family - a group of font families with a similar look (like "Serif" or
"Monospace")
font family - a specific font family (like "Times New Roman" or "Arial")
Example:
<html>
Downloaded from EnggTree.com
EnggTree.com
CCS375-Web echnologies Unit – 1 V Semester CSE
<head>
<title>CSS Font Properties</title>
<style type="text/css">
p{
font-size:50px;
font-variant:small-caps;
font-family:Arial;
font-weight:bold;
font-style:italic;
color:green;
}
In the CSS3 @font-face rule you must first define a name for the font (e.g. myFirstFont),
and then point to the font file.
To use the font for an HTML element, refer to the name of the font (myFirstFont)
through the font-family property:
Example:
@font-face {
font-family: myFirstFont;
src: url(sansation_light.woff);
}
div {
font-family: myFirstFont;
}
<div>
This is an example for web fonts
</div>
CSS3 supports transform property. This transform property facilitates you to translate, rotate,
scale, and skews elements.
Transformation is an effect that is used to change shape, size and position.
There are two type of transformation i.e. 2D and 3D transformation supported in CSS3.
transform-origin Allows you to change the position on transformed elements. It allows you
to specify the location origin of the transform. By default, the origin is in
the center of the element.
For example, if you are using the transform: rotate property but want it to
div:hover {
transform: rotate(720deg);
}
CSS 2D Transforms
The CSS 2D transforms are used to re-change the structure of the element
as translate, rotate, scale and skew etc.
Function Description
translate(x,y) Defines a 2D translation, moving the element along the X- and the Y-
axis
The scale value allows you to increase or decrease the size of an element.
For example, the value 2 would transform the size to be 2 times its original size. The
value 0.5 would transform the size to be half its original size.
You can scale an element by setting parameters for the width (X-axis) or height (Y-
axis). For example, transform: scaleX(2).
Or, use the scale() shorthand to scale both axes at the same time: transform: scale(2);.
Or define them independently of each other: transform: scale(2, 4);
<!DOCTYPE html>
<html>
<head>
<style>
.square {
background:
darkturquoise; border-
radius: 5px;
height: 100px;
margin: 100px;
width: 100px;
}
.square:hover {
transform: scale(2);
}
</style>
</head>
<body>
<div class="square">
</div>
</body>
</html>
2. rotate
With the rotate value, the element rotates clockwise or counterclockwise
by a specified number of degrees.
A positive value, such as 90deg, rotates the element clockwise, while a
negative value, such as -90deg, rotates it counterclockwise.
You can rotate more than a full rotation with numbers over than 360, such as
1080deg, for three full rotations.
<!DOCTYPE html>
<html>
<head>
3. Translate
The translate value moves an element left/right and up/down. The
movement is based on the parameters given for the X (horizontal) Y
(vertical) axes.
A positive X value moves the element to the right, while a negative X moves
the element to the left. A positive Y value moves the element downwards and a
negative Y value, upwards.
In this example, the element will move 20 pixels to the right and 20 pixels
down.
<!DOCTYPE html>
<html>
<head>
<style>
.square2 {
background: #FA54DE;
transition: 2s;
height: 100px;
margin: 100px;
width: 100px;
position:absolute;
.square2:hover{
transform: translate(100px,100px);
}
</style>
</head>
<body>
<div class="square2">
</div>
</body>
</html>
4. Skew
With the skew value, the element skews (or tilts) one direction or the other
based on the values given for the X and Y axes.
A positive X value tilts the element left, while a negative X value tilts it right.
A positive Y value tilts the element down, and a negative Y value tilts is up. Or
use a shorthand to include both X and Y properties:
div {
transform: skewX(25deg);
transform: skewY(10deg);
transform: skew(25deg, 10deg);
}
div {
transition: transform 1s;
}
div:hover {
transform: skewX(-20px);
}
5. Matrix
The matrix() method combines all the 2D transform methods into one.
The matrix() method take six parameters, containing mathematic functions,
which allows you to rotate, scale, move (translate), and skew elements.
The parameters are as follow:
matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY())
Example
div {
transform: matrix(1,2,3,4,5,6);
}
CSS 3D Transforms
Transform Properties
The following table lists all the 3D transform properties:
Property Description
backface-visibility Defines whether or not an element should be visible when not facing the
screen
3D Transform Methods
Function Description
translateX(x) Defines a 3D translation, using only the value for the X-axis
translateY(y) Defines a 3D translation, using only the value for the Y-axis
CSS transitions allows you to change property values smoothly, over a given duration.
Transition properties:
transition
transition-delay
transition-duration
transition-property
transition-timing-function
transition- transition-timing-function:
timing- linear|ease|ease-in|ease-out|
Specifies the speed curve of the
function ease- in-out|step-start|step-
transition effect
end|steps(int,start|end)|cubic-
bezier(n,n,n,n)|initial|
inherit;
Note: If the duration part is not specified, the transition will have no effect, because the default
value is 0.
The following example shows a 100px * 100px red <div> element. The <div> element has also
specified a transition effect for the width property, with duration of 2 seconds:
Example
div {
width: 100px;
height: 100px;
background: red;
transition: width 2s;
}
The transition effect will start when the specified CSS property (width) changes value.
Now, let us specify a new value for the width property when a user mouses over the <div>
element:
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
div:hover {
width: 300px;
}
</style>
</head>
<body>
<p>Hover over the div element below, to see the transition effect:</p>
<div></div>
<p><b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions.</p>
</body>
</html>
Notice that when the cursor mouses out of the element, it will gradually change
back to its original style.
<!DOCTYPE html>
<html>
<head>
<style>
div {
div:hover {
width: 300px;
}
</style>
</head>
<body>
<p>Hover over the div elements below, to see the different speed curves:</p>
<div id="div1">linear</div><br>
<div id="div2">ease</div><br>
<div id="div3">ease-in</div><br>
<div id="div4">ease-out</div><br>
<div id="div5">ease-in-out</div><br>
<p><b>Note:</b> This example does not work in Internet Explorer 9 and earlier
versions.</p>
</body>
</html>
The transition-delay property specifies a delay (in seconds) for the transition effect.
The following example has a 1 second delay before starting:
Example
Transition + Transformation
Example
div {
transition: width 2s, height 2s, transform 2s;
}
The CSS transition properties can be specified one by one, like this:
Example
div {
transition-property: width;
transition-duration: 2s;
transition-timing-function: linear;
transition-delay: 1s;
}
Example
div {
transition: width 2s linear 1s;
}
CSS animations make it possible to animate transitions from one CSS style configuration to
another.
There are three key advantages to CSS animations over traditional script-driven animation
techniques:
They’re easy to use for simple animations; you can create them without even having to
know JavaScript.
The animations run well, even under moderate system load. Simple animations can often
perform poorly in JavaScript. The rendering engine can use frame-skipping and other
techniques to keep the performance as smooth as possible.
Letting the browser control the animation sequence lets the browser optimize
performance and efficiency by, for example, reducing the update frequency of animations
running in tabs that aren't currently visible.
To create a CSS animation sequence, you style the element you want to animate with the
animation property or its sub-properties.
This lets you configure the timing, duration, and other details of how the animation
sequence should progress.
This does not configure the actual appearance of the animation, which is done using the
@keyframes at-rule as described in Defining the animation sequence using keyframes
below.
1. animation-name
2. animation-duration
3. animation-timing-function
4. animation-delay
5. animation-iteration-count
6. animation-direction
7. animation-fill-mode
8. animation-play-state
Once you’ve configured the animation’s timing, you need to define the appearance of the
animation. This is done by establishing two or more keyframes using the @keyframes
at-rule.
o Each keyframe describes how the animated element should render at a given time
during the animation sequence.
Since the timing of the animation is defined in the CSS style that configures the
animation, keyframes use a <percentage> to indicate the time during the animation
sequence at which they take place.
o 0% indicates the first moment of the animation sequence, while 100% indicates
the final state of the animation.
Because these two times are so important, they have special aliases: from and to. Both are
optional.
o If from/0% or to/100% is not specified, the browser starts or finishes the
animation using the computed values of all attributes.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
div {
w
i
d
t
h
:
1
0
0
p
x
;
h
e
i
g
h
t
:
1
0
0
p
x
;
b
a
c
k
g
r
o
u
n
d
-
c
o
l
o
r
:
r
e
d
;
p
o
s
i
t
i
o
n
:
r
e
l
a
t
i
v
e
;
a
n
i
m
a
t
i
o
n
-
n
a
m
e
:
e
x
a
m
p
l
e
;
a
n
i
m
a
t
i
o
n
-
d
u
r
a
t
i
o
n
:
4
s
;
animation-iteration-count:infinite;
}
@keyframes example {
0% {background-color:red; left:0px; top:0px;}
25% {background-
color:yellow;
left:200px; top:0px;}
50% {background-
color:blue; left:200px;
top:200px;} 75%
{background-
color:green; left:0px;
top:200px;} 100%
{background-color:red;
left:0px; top:0px;}
}
<
/
s
t
y
l
e
>
<
/
h
e
a
d
>
<
b
o
d
y
>
<div></div>
</body>
</html>