You are on page 1of 200

Mahavir Education Trust’s

Shah & Anchor Kutchhi Engineering College,


Chembur, Mumbai-400088
UG Program in Computer Engineering

Internet Programming

Ms. Karuna Borhade


Asst. Professor
Course Outcomes
• Implement interactive web page(s) using HTML, CSS. and Java Script.
• Demonstrate Server Side Scripting and database connectivity using
JDBC.
• Demonstrate Rich Internet Application using Ajax.
• Demonstrate and differentiate various Web Extensions.
• Demonstrate web application using Reactive Js
• Design a responsive web site using JavaScript.
Module 1. Introduction to Web Technology
(10 Hours)
• 1.1 Web Essentials: Clients, Servers and Communication, The Internet, Basic
Internet Protocols, World Wide Web, HTTP Request Message, HTTP Response
Message, Web Clients, Web Servers
• 1.2 HTML5: Fundamental syntax and semantics, Tables, Lists, Image, HTML5
control elements, Semantic 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, Animation, Basics of Bootstrap
Internet
• Internet is a global system of interconnected computers, using a
standardized Internet Protocol
• Internet is used for communication and sharing information.
Web
• Web is a subset of the Internet consisting of the pages that can be
accessed using a Web browser.
World Wide Web
• The World Wide Web, commonly known as the Web, is an information
system enabling documents and other web resources to be accessed over
the Internet.
• Documents are made available to the network through web servers.
• Documents can be accessed by programs such as web browsers.
• Servers and resources on the World Wide Web are identified and located
through character strings called Uniform Resource Locators (URLs).
• A common document type is a web page, which is formatted in Hypertext
Markup Language (HTML).
• The information in the Web is transferred across the Internet using the
Hypertext Transfer Protocol (HTTP).
Web Essentials: Clients, Servers and Communication
• A Client is any computer hardware or software device that requests access to a
service provided by a server.
• Client is a requesting program or user in a client-server architecture.
• In a client-server architecture, clients interact with servers by making requests for
data or resources that the client is not capable of providing.
• Clients and servers can be in different areas and connect via a network.
• The most common interface to the World Wide Web is a browser, such as Mosaic,
Netscape Navigator or Internet Explorer.
• With a browser, you can download web documents and view them formatted on
your screen.
• When you request a document with your browser, you supply a web address,
known as a Universal Resource Locator or URL.
Web Essentials: Clients, Servers and Communication
• The URL identifies the machine that contains the document.
• The browser contacts the remote machine and requests the document
you specified.
• After receiving the document, it formats it as needed and displays it on
your browser.
Servers
• A Server is a piece of computer hardware or software that provides
functionality for other programs or devices, called clients.
• This architecture is called the client-server model.
• Servers can provide various functionalities, called services, such as
sharing data or resources among multiple clients, or performing
computation for a client.
• A single server can serve multiple clients, and a single client can use
multiple servers.
• Typical servers are database servers, file servers, mail servers, print
servers, web servers, game servers and application servers.
Client Server Architecture
Client Server Architecture
Client Server Architecture
Client-Server Architecture
• Client-Server architcture is a network application that breaks down
tasks and workloads between clients and servers that reside on the
same system or are linked by a computer network.
• Client-Server architecture features multiple users’ wrkstations, PCs, or
other devices, connected to a central server via an Internet connection
or other network.
• The client sends their request via a network-enabled device.
• Then, the network server accepts and processes the user request.
• Finally, the server delivers the reply to the client.
Client-Server Architecture

Fig. Browser interaction with the server


Client-Server Architecture
• User enters the URL (Uniform Resource Locator) of the website. The
Browser then requests the DNS (Domain Name System) Server.
• DNS Server lookup for the address of the Web Server.
• DNS Server responds with the IP address of the Web Server.
• Browser sends over an HTTP/HTTPS request to Web Server’s IP
(provided by DNS Server)
• Server sends over the necessary files of the website.
• Browser then renders the files and the website is displayed.
Client-Server Architecture: Advantages
• Centralized system with all data in a single place.
• Cost effective requires less maintaiance cost and data recovery is
possible.
• The capacity of the Clients and Servers can be changes separately.
Client-Server Architecture: Disadvantages
• Clients are prone to viruses, Trojans and worms if present in the Server
or uploaded into the Server.
• Servers are prone to Denial of Servive (DOS) attacks.
• Data packets may be spoofed or modified during transmission.
• Phishing or capturing login credentials or other useful information of
the user are common and MITM (Man in the middle) attacks are
common.
Types of Client-Server Architecture
• 1-tier architecture
• 2-tier architecture
• 3-tier architecture
• N-tier architecture
1-tier Architecture
• This architecture contains all kinds of settings,
such as configuration settingand marketting
logic, on a single device.
• This architecture consists of several layers,
such as presentation layer, business layer and
data layer, conbined using software package.
• The data is present in local systems or on a
shared drive.
• Handling such an architecture is difficult due to
data variance.
2-tier Architecture
• The user interface is stored on the client’s side.
• The database is stored on the server.
• Database logic and business logic is maintained
either on the client’s side or on the server’s side.
• This architecture is faster in comparison to the 1-
tier architecture.
• Example: Online ticket reservation system.
3-tier Architecture

• A middleware lies between the client and the server.


• Client request will first be received by the middleware.
• It will then be dispatched to the server for further actions.
• The same pattern wil be followed when the server sends the response to
the client.
• The 3-tier architecture is categorized into 3 layers namely, presentation
layer, application layer and the database layer.
3-tier Architecture
• The presentation layer is controlled by the client.
• The application layer is handled by the middleware.
• The database layer is handled by the server.
• Due to the presence of a third layer that provides data control, 3-tier
architecture is more secure, has invisible data structure and provides data
integrity.
N-tier Architecture

• It is also called multi-tier architecture.


• It is scaled from the other three types of architecture.
• This architecture has a provision for locating each function as an isolated
layer that includes presentation, application processing and management
of data functionalities.
Basic Internet Protocols:
• TCP
• IP
• UDP
• FTP
• TFTP
• Telnet
• HTTP
• Email
• SMTP
• POP
• IMAP
Mapping of TCP/IP protocols with the OSI model
Transmission Control Protocol
• TCP is a connection-oriented protocol and offers end-to-end packet delivery.
• It acts as a backbone for connection.
• It corresponds to the transport layer of OSI model.
• It offers:
• Stream data transfer
• Reliability
• Efficient flow control
• Full-duplex operation
• Multiplexing
Internet Protocol(IP)
• Internet Protocol is connectionless and unreliable protocol.
• It ensures no guarantee of successful transmission of data.
• In order to make it reliable, it must be paired with reliable protocol such as TCP at the
transport layer.
• Internet protocol transmits the data in the form of a datagram as shown in the following
diagram.
Internet Protocol(IP)

Fig. IP Datagram
• The length of the datagram is variable.
• The datagram is divided into two part: header and data
• The length of the header is 20 to 60 bytes
• The header contains information for routing and delivery of the packet.
User Datagram Protocol(UDP)
• Like IP, UDP is connectionless and unreliable protocol.
• It doesn’t require making a connection with the host to exchange data.
• Since UDP is unreliable protocol, there is no mechanism for ensuring that data sent is
received.
• UDP is used by the application that typically transmit small amount of data at one time.
• UDP transmits the data in the form of a datagram.
• The UDP datagram consists of five parts as shown in the below diagram.

Fig. UDP Datagram


File Transfer Protocol (FTP)
• FTP is used to copy files from one host to another.
• FTP creates two processes such as Control Process and Data Transfer Process at both ends.
• Control connection is made between control processes and data connection is made
between data transfer processes.
• FTP uses port 21 for control connection and port 20 for data connection.
Trivial File Transfer Protocol (TFTP)
• Trivial File Transfer protocol is also used to transfer the files but it transfers the files without
authentication.
• Unlike FTP, TFTP does not separate control and data information.
• Since there is no authentication exists, TFTP lacks in security features.
• Therefore, it is not recommended to use TFTP.
Comparison between FTP and TFTP
S.N. Parameter FTP TFTP

1 Operation Transferring Files Transferring Files

2 Authentication Yes No

3 Protocol TCP UDP

4 Ports 21 – Control, 20 – Data Port 3214, 69, 4012

5 Control and Data Separated Not Separated

6 Data Transfer Reliable Unreliable


Telnet
• Telnet is a protocol used to log in to remote computer on the internet.
• The following diagram shows a person is logged in to computer A, and from there,
he remotely logged into computer B.

Fig. Remote login using Telnet


Hyper Text Transfer Protocol(HTTP)
• HTTP is a communication protocol.
• It defines mechanism for communication between browser and the web server.
• It is also called request and response protocol because the communication between
browser and server takes place in request and response pairs.
Hyper Text Transfer Protocol(HTTP)
HTTP request comprises of lines which contains:
● Request line
● Header Fields
● Message body
● The first line i.e. the Request line specifies the request method i.e. Get or Post.
● The second line specifies the header which indicates the domain name of the
server from where index.htm is retrieved.

HTTP response contains:


● Status line
● Headers
● Message body
Email
• Email is a service which allows us to send the message in electronic mode over
the internet.
• It offers an efficient, inexpensive and real time mean of distributing information
among people.
Email

Fig. Format of Email Header


Mahavir Education Trust’s
Shah & Anchor Kutchhi Engineering College,
Chembur, Mumbai-400088
UG Program in Computer Engineering

Internet Programming

Ms. Karuna Borhade


Asst. Professor
Module 1. Introduction to Web Technology
(10 Hours)
• 1.1 Web Essentials: Clients, Servers and Communication, The Internet, Basic
Internet Protocols, World Wide Web, HTTP Request Message, HTTP Response
Message, Web Clients, Web Servers
• 1.2 HTML5: Fundamental syntax and semantics, Tables, Lists, Image, HTML5
control elements, Semantic 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, Animation, Basics of Bootstrap
HTML
• HTML5 is the latest and most enhanced version of HTML.
• HTML stands for Hyper Text Markup Language.
• HTML is the standard markup language for creating Web pages.
• HTML describes the structure of a Web page.
• HTML consists of a series of elements.
• HTML elements tells the browser how to display the content.
HTML: Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Document</title>
</head>
<body>
<h1>HTML Tutorial</h1>
<p>Welcome to HTML Tutorial</p>
</body>
</html>
HTML: Example
• The <!DOCTYPE html> declaration defines that this document is an
HTML5 document.
• The <html> element is the root element of an HTML page.
• The <head> element contains meta information about the HTML page
• The <title> element specifies a title for the HTML page.
• The <body> element defines the document’s body, and is a container
for all the visible contents, such as headings, paragraphs, images,
hyperlinks, tables, lists, etc.
• The <h1> element defines a large heading.
• The <p> element defines a paragraph.
HTML Elements
• An HTML element defined by a start tag, some content and an end tag.
• Examples of HTML elements are as follows:
• <h1> Heading 1 </h1>
• <p> Paragraph 1 </p>
HTML Attributes
• HTML attributes provide additional information about HTML elements.
• All HTML elements can have attributes.
• Attributes provide additional information about elements.
• Attributes are always specified in the start tag.
• Attributes usually come in name/value pairs like: name=”value”
• For Example: The <a> tag defines a hyperlink. The href attribute
specifies the URL of the page the link goes to:
• <a href=”https://www.w3schools.com”> Visit W3Schools</a>
HTML: Heading tags
• You can change the size of your text.
• This can be done either using <font> tag or using <h...> tags.
• HTML headings are defined with <h1> to <h6> tags.
• <h1> defines the most important heading.
• <h6> defines the least important heading.
HTML: Heading tags
<!DOCTYPE html>
<html>
<head>
<title>HTML Headings Tag</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
HTML: Paragraphs
• The <p> tag defines a paragraph.
• Browsers automatically add a single blank line before and after each
<p> element.
HTML: Paragraphs
<!DOCTYPE html>
<html>
<head>
<title>HTML Paragraph Tag</title>
</head>
<body>
<p>Twinkle, twinkle little star</p>
<p>How I wonder what you are</p>
<p>Up above the world so high</p>
<p>Like a diamond in the sky</p>
</body>
</html>
HTML: Break tag
• The <br> or break tag makes output start on the next line down at the
beginning of a new line.
• This is a self-contained tag in that it does not need a closing tag.
HTML: Break tag
<!DOCTYPE html>
<html>
<head>
<title>Formatting Text: break tag</title>
</head>
<body>
The body section contains several new tags.<br>
The break tag makes output start on the next line down at the beginning of a
new line.<br>
This tag is self-contained in that it does not need a closing tag.
</body>
</html>
HTML: <pre> tag
• The <pre>...</pre> tag enables you to embed text that is already
formatted so you don’t have to put break tags in.
• The text is output in courier font which is not proportional spacing.
HTML: <pre> tag
<!DOCTYPE html>
<html>
<head>
<title>Formatting Text: pre tag</title>
</head>
<body>
<pre>
This is already set out in the way I want it.
It has some advantages and is quick.
You don't have to add line breaks but
It hasn't proportional spacing and is in courier font...!
</pre>
</body>
</html>
HTML: <hr> tag
• To break sections of a page the tag <hr> can be used.
• This creates a line or horizontal rule.
• This tag does not require an ending tag.
HTML: <hr> tag
<!DOCTYPE html>
<html>
<head>
<title>Formatting Text: hr tag</title>
</head>
<body>
<hr> Section 1: Programming Languages:<br>
C, C++, Java, Python
<hr> Section 2: Databases:<br>
Oracle, DB2, MongoDB
<hr>
</body>
</html>
HTML: Adding emphasis
Table 1. Adding emphasis
Tag Format
<i> ... </i> Italic
<b> ... </b> Bold
<tt> ... </tt> Typewriter effect
<em> ... </em> Emphasis
<blink> ... </blink> Blinking
<sup> ... </sup> Superscript
<sub> ... </sub> Subscript
HTML: Adding emphasis
<!DOCTYPE html>
<html>
<head>
<title>Formatting Text</title>
</head>
<body>
<i>Italic text</i><br>
<b>Bold text</b><br>
<tt>Typewriter effect</tt><br>
<em>Emphasized text</em><br>
<blink>blinking effect</blink><br>
<sup>Superscript</sup><br>
<sub>subscript</sub>
</body>
HTML: Comments
• HTML comments are not displayed in the browser, but they can help document your
HTML source code.
<!DOCTYPE html>
<html>
<head>
<title>Comments</title>
</head>
<body>
<!--This is a comment-->
<p> This is a paragraph </p>
</body>
</html>
HTML: Images
• Images can improve the design and the appearance of a web page.
• The HTML <img> tag is used to embed an image in a web page.
• Images are not technically inserted into a web page; images are linked
to web pages.
• The <img> tag creates a holding space for the referenced image.
• The <img> tag is empty, it contains attributes only, and does not have a
closing tag.
• The <img> tag has two required attributes:
• src- Specifies the path to the image.
• alt- Specifies an alternate text for the image
• Syntax: <img src=”url” alt=”alternate text”>
HTML: Images
<!DOCTYPE html>
<html>
<body>
<p>If a browser cannot find the image, it will display the alternate
text:</p>
<img src="C:\Users\Karuna\Desktop\SH2022\Internet
Programming\Notes\Images\car.jpg" alt="Car on the road">
</body>
</html>
HTML: Links
• HTML links are hyperlinks.
• You can click on a link and jump to another document.
• When you move the mouse over a link, the mouse arrow will turn into a
little hand.
• The HTML <a> tag defines a hyperlink. It has the following syntax:
• <a href=”url”> link text </a>
• The attribute href indicates the link’s destination.
• The link text is the part that will be visible to the reader.
• Clicking on the link text will send the reader to the specified URL
address.
• <a href="https://www.w3schools.com/">Visit W3Schools.com!</a>
HTML: Links
<!DOCTYPE html>
<html>
<head>
<title>Creating a Hyperlink</title>
</head>
<body>
<h1> This is the first page </h1>
<br>
<h1><a href="1.html">My First example </a></h1>
</body>
</html>
HTML: Links Target attribute
• By default, the linked page will be displayed in the current browser
window.
• The target attribute specifies where to open the linked document.
• The target attribute can have one of the following values:
• _self - Default. Opens the document in the same window/tab as it was
clicked
• _blank - Opens a document in a new window or tab
• _parent - Opens the document in the parent frame
• _top - Opens the document in the full body of the window
HTML: Links Target attribute
<!DOCTYPE html>
<html>
<head>
<title>Creating a Hyperlink</title>
</head>
<body>
<h1> This is the first page </h1>
<br>
<h1><a href="1.html" target="_blank">My First example </a></h1>
</body>
</html>
HTML: Links - Image as a link
• To use an image as a link, just put <img> inside the <a> tag.
<!DOCTYPE html>
<html>
<head>
<title>Image as a link </title>
</head>
<body>
<h1>Image as a link </h1>
<br>
<h1><a href="1.html"><img src="C:\Users\Karuna\Desktop\SH2022\Internet
Programming\Notes\Images\butterfly.jpg" alt="HTML Tutorial"> </a></h1>
</body>
</html>
HTML: Links
• By default, links will appear as follows in all browsers.
• An unvisited link is underlined and blue.
• A visited link is underlined and purple.
• An active link is underlined and red.
HTML: Tables
• HTML tables allows you to arrange data into rows and columns.
• A pair of <table> and </table> tags represents an HTML table.
• A pair of <tr> and </tr> tags represents a row in a table.
• A pair of <th> and </th> tags is used to add a column heading in a
column .
• A pair of <td> and </td> tags are used to add data values in a column.
• <tr> and </tr> tags determines the number of rows in a table.
• A caption is specified to a table with the <caption> tag.
HTML: Tables
• Table Attributes:
• You can add a border to a table with the border attribute of the <table> tag.
• You can align a table the align attribute. You can also align cell contents
using align attribute for <th> and <td> tag.
• A table width can be expressed as an absolute value in pixels or as a
percentage of screen width.
• To change the background color for the entire table, the bgcolor attribute is
used.
• To specify the space between the edges of the cell and cell content in terms
of pixel, the cellpadding attribute is used.
• To specify the space between the borders of the cells, cellspacing attribute is
used.
HTML: Tables
• Table Attributes:
• You can span cells vertically by using the rowspan attribute with the <td> or
<th> tag.
• You can span cells horizontally by using the colspan attribute with the <td> or
<th> tag.
HTML: Tables example 1
<html> <tr>

<head><title> Table </title> </head> <td align="center">Sumeet Sinha </td>


<td>12-03-1998</td>
<body bgcolor="Lightblue">
<td align="center"> Flat No.102, ABC chs.,
<table border="1" align="right" Mumbai-72 </td>
width="95%" bgcolor="pink"> </tr>
<caption><h2> Student Details </h2> <tr>
</caption> <td align="center">Swati Kumar </td>
<th width="15%">Name</th> <td>15-04-1998</td>
<th width="15%">Date of Birth </th> <td align="center"> Flat No.104, PQR chs.,
Mumbai-84 </td>
<th width="50%">Address</th>
</tr>
</table> </body> </html>
HTML: Tables example 2
<html> <tr>
<head><title> Table </title> </head> <td align="center">Sumeet Sinha </td>

<body bgcolor="Lightblue“> <td>12-03-1998</td>

<table border="1" align="right" <td align="center"> Flat No.102, ABC chs.,


Mumbai-72 </td>
width="95%" bgcolor="pink
“cellpadding="8" cellspacing="6" > </tr>
<caption><h2> Student Details </h2> <tr>
</caption> <td align="center">Swati Kumar </td>
<th rowspan="5">Student Name<br> <td>15-04-1998</td>
with<br> <td align="center"> Flat No.104, PQR chs.,
Mumbai-84 </td>
Date of Birth<br>
</tr>
and<br>
</table> </body> </html>
address</th>
HTML: Tables example 3
<html> <tr>
<head><title> Table </title> </head> <td align="center">Sumeet Sinha </td>

<body bgcolor="Lightblue“> <td>12-03-1998</td>

<table border="1" align="right" <td align="center"> Flat No.102, ABC chs.,


Mumbai-72 </td>
width="95%" bgcolor="pink
“cellpadding="8" cellspacing="6" > </tr>
<caption><h2> Student Details </h2> <tr>
</caption> <td align="center">Swati Kumar </td>
<th colspan=“3">Student Name<br> <td>15-04-1998</td>
with<br> <td align="center"> Flat No.104, PQR chs.,
Mumbai-84 </td>
Date of Birth<br>
</tr>
and<br>
</table> </body> </html>
address</th>
HTML: Lists
• HTML lists allow web developers to group a set of related items in lists.
• Lists are of 3 types:
• Unordered List
• Ordered List
• Description List
• Unordered List: A unordered list starts with the <ul> tag. Each list item
starts with the <li> tag.
• The list items will be marked with bullets, by default.
HTML: Lists
• The CSS list-style-type property is used to define the style of the list
item marker. It can have one of the following values:
• disc: Sets the list item marker to a bullet (default)
• circle: Sets the list item marker to a circle.
• square: Sets the list item marker to a square.
• none: The list items will not be marked.
HTML: Lists
• Example of unordered list
<!DOCTYPE html>
<html><body>
<h2>An unordered HTML list</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body> </html>
HTML: Lists
• Example of unordered list with list-style-type
<!DOCTYPE html>
<html>
<body>
<h2>Unordered List with Disc Bullets</h2>
<ul style="list-style-type:circle">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body> </html>
HTML: Lists
•Ordered List : An ordered list starts with the <ol> tag. Each list item
starts with the <li> tag.
• The list items will be marked with numbers by default.
• The type attribute of the <ol> tag, defines the type of the list item
marker:
• type=“1” The list items will be numbered with numbers (default).
• type=“A” The list items will be numbered with uppercase letters.
• type=“a” The list items will be numbered with lowercase letters.
• type=“I” The list items will be numbered with uppercase roman
numbers.
• type=“i” The list items will be numbered with lowercase roman
numbers.
HTML: Lists
• Example of ordered list
<!DOCTYPE html>
<html><body>
<h2>An unordered HTML list</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body> </html>
HTML: Lists
• Example of ordered list with uppercase type
<!DOCTYPE html>
<html>
<body>
<h2>Ordered List with Letters</h2>
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body> </html>
HTML: Lists
• Description List: A description list is a list of terms, with a description of
each term.
• The <dl> tag defines the description list, the <dt> tag defines the
term(name) and the <dd> tag describes each term.
HTML: Lists
•Example of description list:
<!DOCTYPE html>
<html>
<body>
<h2>A Description List</h2>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
Mahavir Education Trust’s
Shah & Anchor Kutchhi Engineering College,
Chembur, Mumbai-400088
UG Program in Computer Engineering

Internet Programming

Ms. Karuna Borhade


Asst. Professor
Module 1. Introduction to Web Technology
(10 Hours)
• 1.1 Web Essentials: Clients, Servers and Communication, The Internet, Basic
Internet Protocols, World Wide Web, HTTP Request Message, HTTP Response
Message, Web Clients, Web Servers
• 1.2 HTML5: Fundamental syntax and semantics, Tables, Lists, Image, HTML5
control elements, Semantic 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, Animation, Basics of Bootstrap
HTML5
• HTML5 is the latest and most enhanced version of HTML.
• HTML5 has introduced new multimedia features which support audio
and video controls by using <audio> and <video> tags.
• It has enriched semantic contents by including <header>, <footer>,
<article>, <section> and <figure> elements.
• Drag-and-Drop : The user can grab an object and drag it further
dropping it to a new location.
HTML5: <header>
• The <header> element represents the header of a document or a
section.
• A header should contain title and heading information about the
related content.
HTML5: <header>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML header Tag</title>
</head>
HTML5: <header>
<body>
<header>
<h1>W3Schools.com</h1>
<nav>
<p>
<a href="https://www.w3schools.com/html/default.asp">HTML
Tutorial</a> |
<a href="https://www.w3schools.com/css/">CSS Tutorial</a>
</nav>
</header>
</body>
</html>
HTML5: <footer>
• The <footer> element represents the footer of a document or a section.
• A footer typically contains information about the author of the
document, copyright information, links to related documents etc.
HTML5: <footer>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML footer Tag</title>
</head>
HTML5: <footer>
<body>
<footer>
<nav>
<p>
<a href=https://www.w3schools.com/html/default.asp">HTML
Tutorial</a> |
<a href="https://www.w3schools.com/css/">CSS Tutorial</a>
</p>
</nav>
<p>Copyright &copy; W3Schools.com Tutorial</p>
</footer>
</body>
</html>
HTML5 <article> tag
• The <article> tag is used to define independent piece of content in a
document, that may be a blog, a magazine or a newspaper article.
• Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML article Tag</title>
</head>
<body>
<article>
<h1>Introduction to HTML</h1>
<p>HTML is a markup language that is used for creating web pages.</p>
</article>
</body>
</html>
HTML5 <aside> tag
• The <aside> tag represents a section of the web page that encloses
content which is slightly related to the content around it.
HTML5 <aside> tag
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML aside Tag</title>
</head>
<body>
<h1>Apollo 13 Mission</h1>
<p>The Apollo 13 craft was launched on April 11, 1970 from the Kennedy Space Center,
Florida, but the lunar landing was aborted after an oxygen tank exploded two days later.</p>
<p>[...]</p>
<aside>
<h1>Apollo 13 Facts</h1>
<p>Apollo 13 was the seventh manned mission in the American Apollo space
program and the third intended to land on the Moon.</p>
</aside>
</body>
</html>
HTML5 <audio> tag
• The <audio> tag is used to embed audio content in an HTML document without
requiring any additional plug-in like Flash player.
• Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML audio Tag with Alternate Sources</title>
</head>
<body>
<audio controls="controls">
<source src="/examples/audio/birds.mp3" type="audio/mpeg">
<source src="/examples/audio/birds.ogg" type="audio/ogg">
</audio>
</body>
</html>
HTML5 <video> tag
• The <video> tag is used to embed video content in an HTML document
without requiring any additional plug-in like Flash player.
• There are 3 main video formats that are supported for the video
element: MP4, Ogg and WebM.
HTML5 <bdi> tag
• The <bdi> tag known as bi-directional isolation represents a span of text that
is isolated from other text for the purposes of formatting in a different
direction.
•Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML bdi Tag</title>
</head>
<body>
<p dir="ltr">This arabic word <bdi>ARABIC_PLACEHOLDER</bdi> is
automatically displayed right-to-left.</p>
</body>
</html>
HTML5 <canvas> tag
• The <canvas> tag defines a region in the document, which can be used
to draw graphics on the fly via scripting (usually JavaScript).
• getElementById() : Get the element with the specified id.
• getContext() : This method returns a drawing context on the canvas, or
null if the context identifier is not supported.
• moveTo(x,y) : This method begins a new sub-path at the point specified
by the given (x, y) coordinates.
• lineTo() : This method adds a new point and creates a line TO that point
FROM the last specified point in the canvas.
• Stroke() : Stroke() method is used to actually draw the path on the
canvas.
HTML5 <canvas> tag
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML canvas Tag</title>
<style type="text/css">
canvas{
border: 1px solid;
}
</style>
</head>
HTML5 <canvas> tag
<body>
<canvas id="myCanvas" width=“250" height=“300"></canvas>
<script type="text/javascript">
window.onload = function(){
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
context.moveTo(50, 220);
context.lineTo(220, 50);
context.stroke();
};
</script>
</body>
</html>
HTML5 <data> tag
• The <data> element links a piece of content with a machine-readable
translation.
HTML5 <data> tag
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of HTML data Tag</title>
<style>
data:hover::after {
content: ' (ID ' attr(value) ')';
font-size: .8em;
}
</style>
</head>
HTML5 <data> tag
<body>
<p>New Products</p>
<ul>
<li><data value="101">Green Tea</data></li>
<li><data value="102">Roasted Coffee Beans</data></li>
</ul>
</body>
</html>
HTML5 <datalist> tag
• The <data> element links a piece of content with a machine-readable
translation.
HTML5 <datalist> tag
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of datalist Tag</title>
</head>
<body>
<p>Enter your favorite browser name:</p>
<form action="/examples/html5/demo_datalist.php"
method="post">
<input type="text" list="browsers"
name="favorite_browser“>
HTML5 <datalist> tag
<datalist id="browsers">
<option value="Firefox">
<option value="Chrome">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
</datalist>
<input type="submit" value="Submit">
</form>
</body>
</html>
HTML5 <figure> and <figcaption> tag
• The <figure> element represents a unit of content, optionally with a
caption, that is self-contained and typically referenced as a single unit.
• Usually this is an image, an illustration, a diagram or a code snippet that
is referenced in the main text.
• The <figcaption> element defines a caption or legend for a figure.
HTML5 <figure> and <figcaption> tag
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML figure Tag</title>
</head>
<body>
<figure>
<img src="C:\Users\Karuna\Desktop\SH2022\Internet
Programming\Notes\Images\nature.jpg" alt="Nature Image">
<figcaption>Nature is our best friend</figcaption>
</figure>
</body>
</html>
HTML Drag and Drop
• Drag and Drop is a powerful User Interface concept which makes it easy
to copy, reorder and deletion of items with the help of mouse clicks.
• This allows the user to click and hold the mouse button down over an
element, drag it to another location and release the mouse button to
drop the element there.
• HTML5 came up with a Drag and Drop API.
• There are number of events which are fired during various stages of the
drag and drop operation.
• They are listed in given table.
HTML Drag and Drop
Event Description
Dragstart Fires when the user starts dragging of an object.
dragenter Fired when the mouse is first moved over the target element
while a drag is occurring.
dragover This event is fired as the mouse is moved over an element
when a drag is occurring.
dragleave This event is fired when the mouse leaves an element while a
drag is occurring.
drag Fires every time the mouse is moved while the object is being
dragged.
drop The drop event is fired on the element where the drop was
occurred at the end of the drag operation.
dragend Fires when the user releases the mouse button while dragging
an object.
HTML Drag and Drop
• The DataTransfer Object: The event listener methods for all the drag
and drop events accept Event object which has a readonly attribute
called dataTransfer.
• The DataTransfer object holds data about the drag and drop operation.
• Table shows the list of DataTransfer attributes.
HTML Drag and Drop
DataTransfer Attributes Description
dataTransfer.dropEffect Returns the kind of operation that is currently selected.
dataTransfer.effectAllowedReturns the kind of operations that are to be allowed.
dataTransfer.types Returns a DOMStringList listing the format that were set
in the dragstart event.
dataTransfer.clearData Removes the data of the specified formats.
dataTransfer.setData Adds the specified data.
data=dataTransfer.getData Returns the specified data.
dataTransfer.files Returns a FileList of the files being dragged, if any.
dataTransfer.setDragImage Uses the given element to update the drag feedback,
replacing any previously specified feedback.
dataTransfer.addElement Adds the given element to the list of elements used to
render the drag feedback.
HTML Drag and Drop
• Drag and Drop Process:
• If you want to drag an element, you need to set the draggable attribute to true
for that element.
• Set an event listener for dragstart that stores the data being dragged.
• The eventlistener dragstart will set the allowed effects (copy, move, link or some
combination).
HTML Drag and Drop: Example
<!DOCTYPE HTML> function drop(ev) {
<html> ev.preventDefault();
<head> var data = ev.dataTransfer.getData("text");
<style> ev.target.appendChild(document.getElementById(data));
#div1 { }
width: 350px; </script>
height: 70px; </head>
padding: 10px; <body>
border: 1px solid #aaaaaa; <p>Drag the W3Schools image into the rectangle:</p>
} <div id="div1" ondrop="drop(event)"
</style> ondragover="allowDrop(event)"></div>
<script> <br>
function allowDrop(ev) { <img id="drag1"
src="C:\Users\Karuna\Desktop\SH2022\Internet
ev.preventDefault(); Programming\Notes\Images\car.jpg" draggable="true"
} ondragstart="drag(event)" width="336" height="69">
function drag(ev) { </body>
ev.dataTransfer.setData("text", ev.target.id); </html>
}
Mahavir Education Trust’s
Shah & Anchor Kutchhi Engineering College,
Chembur, Mumbai-400088
UG Program in Computer Engineering

Internet Programming

Ms. Karuna Borhade


Asst. Professor
Module 1. Introduction to Web Technology
(10 Hours)
• 1.1 Web Essentials: Clients, Servers and Communication, The Internet, Basic
Internet Protocols, World Wide Web, HTTP Request Message, HTTP Response
Message, Web Clients, Web Servers
• 1.2 HTML5: Fundamental syntax and semantics, Tables, Lists, Image, HTML5
control elements, Semantic 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, Animation, Basics of Bootstrap
CSS Introduction
• Cascading Style Sheets (CSS) are text files that contain one or more rules in
the form of property/value pairs to determine how elements in a Web page
should be displayed.
• CSS deals with all the style-related aspects important to create a Web page.
• W3C has developed some specifications (or rules) to create and use style
sheets.
• These specifications are called as the Cascading Style Sheet specifications.
• The syntax of a CSS rule is as follows:
• Selector {property1: property1-value; property2:property2-value……..}
• Here, selector is the element that the rule defines, property1, property2 are
the properties (attributes) defined for the element, and property1-value,
property2-value are values assigned to these properties.
CSS Introduction
• Example of a CSS rule to set three background properties for the
<body> element, is as follows:
• body{ background-color:#0000ff; background-image:url(C:\Image1.jpg);
background-repeat: repeat-x}
• A shorthand property for the same is as follows:
• body{ background: #0000ff url(C:\Image1.jpg) repeat-x}
CSS Introduction
• It is also possible to attach few properties to more than one selector.
h1, h2 { color: red; font: italic 1em Times, serif; text-decoration:
underline; background: black; }
• To make a whole group of headers red:
h1,h2,h3,h4,h5,h6
{
color:red;
}
CSS Introduction
• There are 5 ways to create cascading styles in a Web page:
• Using inline styles
• Using external style sheets
• Using internal style sheets
• Using id
• Using class
CSS: Inline Styles
• In this method, style for an HTML element is specified using its style
attribute.
• Inline styles are useful when you want to define specific styles for
individual elements present on a Web page.
CSS: Inline Styles Example
<!DOCTYPE HTML>
<html>
<body>
<h1 style="color:blue;text-align:center;">This is a heading</h1>
<p style="color:red;">This is s paragraph.</p>
</body>
</html>
CSS: The Internal/Embedded Style Sheet
• The internal style sheet is written within the HEAD element of the
HTML document.
• This style is applied only to the documents in which it is defined and
not defined by any other Web document.
• The syntax of the internal style sheet is an follows:
<STYLE type=“text/css”>
selector { property: value;}
</STYLE>
CSS: The Internal/Embedded Style Sheet Example
<!DOCTYPE html>
<body>
<html>
<head> <h1>This is s heading</h1>
<style> <p>This is a paragraph.</p>
body{
</body>
background-color:cyan;
} </html>
h1{
color:red;
margin-left:40px;
}
</style>
</head>
CSS: The External Style Sheet
• With an external style sheet, you can change the look of an entire
website by changing just one file.
• Each HTML page must include a reference to the external style sheet
file inside the <link> element, inside the head section.
CSS: The External Style Sheet Example
<!DOCTYPE html> mystyle.css
<html>
<head>
body {
<link rel="stylesheet“
href="mystyle.css"> background-color: lightblue;
</head> }
<body> h1 {
<h1>This is a heading</h1> color: navy;
<p>This is a paragraph.</p>
margin-left: 20px;
</body>
}
</html>
CSS: Id selector
• The id selector uses the id attribute of an HTML element to select a
specific element.
• The id of an element is unique within a page, so the id selector is used
to select one unique element.
• To select an element with a specific id, write a (#) character, followed by
the id of the element.
CSS: Id selector Demo
<!DOCTYPE html> <body>
<html> <p id="para"> This paragraph is
<head> styled by id selector. </p>
<title> ID selector demo </title> <p> This paragraph is not affected by
<style> the style. </p>
</body>
#para {
</html>
text-align:center;
color:red;
}
</style>
</head>
CSS: Class selector
• The class selector selects HTML elements with a specific class attribute.
• To select elements with a specific class, write a period (.) character,
followed by the class name.
CSS: Class selector Demo
<!DOCTYPE html> <body>
<html> <h1 class="center"> This heading is
<head> styled by class selector </h1>
<title> Class selector demo </title> <p class="center"> This paragraph is
<style> styled by class selector. </p>
.center {
</body>
text-align:center;
</html>
color:red;
}
</style>
</head>
CSS Inheritance
• In CSS, some styles are inherited.
• It allows the child elements to inherit the CSS property values set on
parent elements.
• For example, if you set a color and font-family on an element, every
element inside it will also be styled with that color and font, unless you
have applied different color and font values directly to them.
CSS: Inheritance
<!doctype html> <body>
<html> <div class="container">
<head> <p>
<title> CSS Inheritance </title> When you think of the word “inheritance,”
your first thought is probably related to how
<style> children inherit certain physical
.container{ characteristics from their parents — if both
your parents have blue eyes, you’ll probably
font-family: Helvetica, inherit those same blue eyes. Well,
Arial, Sans-serif; understanding CSS inheritance isn’t too far
font-size: 24px; off from this simple concept.
</p>
border: 5px solid blue;
</div>
}
</body>
</style>
</html>
</head>
CSS Specificity
• CSS rules often conflict with one another.
• Specificity is one of the way to apply conflicting rules.
• Selectors have different values of importance ( or specificity).
• Those are listed below in order of importance.
• id selectors
• class and pseudo selectors
• element selectors
• If multiple CSS rules conflict with one another, the most important or
specific selector is the one that will apply.
CSS: Specificity
<!doctype html> <body>
<html> <div id="nav" class="links">
<head> <ul>
<title> CSS Specificity </title> <li class="active">link</li>
<style>
<li>link</li>
div {color:red;}
</ul>
div#nav {color:blue;}
</div>
div.links {color:yellow;}
</body>
</style>
</head> </html>
CSS: Calculating Specificity Level
• A simple scoring system has a three-value-layout like A-B-C.
• Add one to A for each id in the selector.
• Add one to B for each class or pseudo class in the selector.
• Add one to C for each element name.
• Read the result as a three-digit number
• For example:
div {color:red;} /* 0 – 0 – 1 */
div#nav {color:blue;} /* 1 – 0 – 1 */
div.links {color:yellow; /* 0 – 1 – 1 */
• As we can see, the div#nav selector has the highest score, the text color in the div
will be blue.
CSS: Rule Cascading
• In CSS, style sheets cascade by order of importance.
• If rules in different style sheets conflict with one another, the rules from the most
important style sheet wins.
• Below is a list of possible sources of a CSS rule. They are listed by order of
importance. As the creator of the style sheet, you’re the author.
• Author inline styles
• Author embedded styles (internal style sheets)
• Author external style sheet
• User style sheet
• Default browser style sheet

• All browsers have a default style sheet, which is designated as the least important.
• Whenever we define a CSS rule, we are actually overriding a default browser style
sheet rule. This is known as cascade in action.
CSS: Rule Cascading
• Sometimes two or more declarations are applied to the same element.
• When conflicts like this occur, the declaration with the highest weight is used.
• The weight is determined by the Cascade Rules.
• Cascade Rules:
1. Find all declarations whose selectors match a particular element.
2. Sort these declarations by weight and origin.
3. Sort the selectors by specificity.
4. Sort the order specified.
CSS: Rule Cascading Example
• Let’s use one HTML element <h2> as an example.
• Step 1. Find all declarations whose selectors match a particular element.
• After looking at all style sheets( browser, user and author), all the declarations that
match an <h2> element are found.
• The browser style sheet includes the following rule:
h2 { font-size: 1.5em; margin: .83em 0; color: black }
• The users style sheet includes the following rule:
h2 { color: brown !important; }
• The author style sheet includes the following rule:
h2 { color: green; font-size: 1.2em; padding: 10px; }
h2#main { color: red; }
h2.navigation { color: blue;}
CSS: Rule Cascading Example
• Step 2: Sort these declarations by weight and origin.
• For normal declarations, the author style sheets will override both user and browser
style sheets, unless there is an !important declaration in the user’s style sheet.
• For !important declarations , user style sheets override author and browser style
sheets.
font-size: 1.2em; /* author wins over browser */
margin: .83em 0; /* specified only by browser */
padding: 10px; /* specified only by author */
color: brown; /* user wins due to !important */
CSS: Rule Cascading Example
• Step 3: Sorting selectors by specificity.
h2 { font-size: 1.5em; margin: .83em 0; color: black }
0-0-1 > specificity = 001

h2 { color: brown !important; }


0-0-1 > specificity = 001

h2 { color: green; font-size: 1.2em; padding: 10px; }


0-0-1 > specificity = 001

h2#main { color: red; }


1-0-1 > specificity = 101

h2.navigation { color: blue;}


0-1-1 > specificity = 011
• For general users, not affected by !important rule, any >h2> will be
color: red;
CSS: Rule Cascading Example
• Step 4: Sort by order specified.
• If two rules have same weight, origin and specificity, the one written lower down in
the style sheet wins.
• For example,
h2 { color: blue;}
h2 { color: green; }
• The second rule, that appears later in the style sheet would win.
CSS Colors
• Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA,
HSLA values.
• In CSS, a color can be specified by using a predefined color name.
• CSS/HTML supports 140 standard color names.
• You can set the background color for HTML elements as follows:
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:LightSkyBlue;">Hello World</h1>
<p style="background-color:LightSeaGreen;">This is a paragraph</p>
</body>
</html>
CSS Colors
• You can set the color of the text as follows:
<!DOCTYPE html>
<html>
<body>
<h3 style="color:Salmon;">Hello World</h3>
<p style="color:DarkMagenta;">This is a color-styled paragraph.</p>
<p style="color:LimeGreen;">This is one more color-styled paragraph.</p>
</body>
</html>
CSS Colors
• You can also set the color of borders:
<!DOCTYPE html>
<html>
<body>
<h1 style="border: 2px solid Tomato;">Hello World</h1>
<h1 style="border: 2px solid DodgerBlue;">Hello World</h1>
<h1 style="border: 2px solid Violet;">Hello World</h1>
</body>
</html>
CSS Colors: RGB, HEX, HSL
• An RGB color value represents RED, GREEN and BLUE light sources.
• Each parameter defines the intensity of the color between 0 to 255.
• For example, rgb(255,0,0) represents RED color.
• A hexadecimal color is specified with #RRGGBB where RR, GG and BB are the
hexadecimal integers.
• For example, #ff0000 is displayed as RED color.
• A color can also be specified using hue, saturation and lightness in the form:
hsl(hue, saturation, lightness)
• Hue is the degree on the color wheel from 0 to 360. 0 is red.
• Saturation is a percentage value. 0% means a shade of gray, 100% is full color.
• Lightness is also a percentage. 0% is black, 100% is white.
CSS Colors: RGB, HEX, HSL
<!DOCTYPE html>
<html>
<body>
<p>Same as color name "Tomato":</p>
<h1 style="background-color:rgb(255, 99, 71);">rgb(255, 99, 71)</h1>
<h1 style="background-color:#ff6347;">#ff6347</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">hsl(9, 100%, 64%)</h1>
<p>Same as color name "Tomato", but 50% transparent:</p>
<h1 style="background-color:rgba(255, 99, 71, 0.5);">rgba(255, 99, 71, 0.5)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">hsla(9, 100%, 64%, 0.5)</h1>
<p>In addition to the predefined color names, colors can be specified using RGB, HEX, HSL, or even
transparent colors using RGBA or HSLA color values.</p>
</body>
</html>
CSS Colors: rgba() function
• The rgba() function defines colors using the Red-green-blue-alpha
(RGBA) model.
• RGBA color values are the extension of RGB color values with an alpha
channel – which specifies the opacity of the color.
• The opacity is a number between 0.0 (fully transparent) and 1.0 (fully
opaque).
CSS Colors: rgba() function
<!DOCTYPE html> <body>
<html> <h1>The rgba() Function</h1>
<head> <p>RGB colors with
<style> opacity:</p>
#p1 {background- <p id="p1">Red</p>
color:rgba(255,0,0,0.8);} <p id="p2">Green</p>
#p2 {background- <p id="p3">Blue</p>
color:rgba(0,255,0,0.8);}
</body>
#p3 {background-
color:rgba(0,0,255,0.8);} </html>
</style>
</head>
CSS Backgrounds
• Background-color
• Background-image
• Background-repeat
• Background-attachment
• background
CSS Backgrounds: background-color
• The background-color property specifies the background color of an
element.
CSS Backgrounds: background-color
<!DOCTYPE html> p{
<html> background-color: green;
<head> opacity:0.6;
<style> }
body { </style>
</head>
background-color: lightblue;
<body>
}
<h1>Hello World!</h1>
h1 { <p>This page has a light blue
background-color: green; background color!</p>
opacity:0.9; </body>
} </html>
CSS Backgrounds:background-image
• The background-image property specifies the background image of an
element.
• By default, the image is repeated, so it covers the entire element.
CSS Backgrounds: background-image
<!DOCTYPE html> <body>
<html> <h1>Hello World!</h1>
<p>This page has an image as
<head>
the background!</p>
<style> </body>
body { </html>
background-image:
url(“bg_image.jpg");
}
</style>
</head>
CSS Backgrounds:background-repeat
• By default, the background-image property repeats an image both
horizontally and vertically.
• Some images should be repeated only horizontally or vertically, or they
will look strange.
• Set background-repeat: repeat-x to repeat the image horizontally.
• Set background-repeat: repeat-y to repeat the image vertically.
• Set background-repeat: no-repeat to show the background image only
once.
CSS Backgrounds:background-position
• The background-position property sets the starting position of a
background image.
• background-position:value
• Values are left top, left center, left bottom, right top, right center, right
bottom, center top, center center, center bottom.
CSS Backgrounds:background-attachment
• The background-attachment property specifies whether the
background image should scroll or be fixed.
CSS Backgrounds:background-size
• The background-size property specifies the size of the background images.
• background-size:auto displays the image in its original size.
• background-size:length sets the width and height of the background image.
• background-size:percentage sets the width and height of the background
image in percent of the parent element.
• background-size:cover resizes the background image to cover the entire
container.
• background-size:container resizes the background image to make sure that
the image is fully visible.
• Initial: Sets this property to its default value.
CSS Backgrounds
<!DOCTYPE html> </style>
<html> </head>
<head> <body>
<style> <h1>Hello World!</h1>
body { <p>This page has an image as
background-image: the background!</p>
url(“bg_image.jpg"); </body>
background-repeat:no-repeat; </html>
background-position:right top;
margin-right:200px;
background-attachment:fixed;
}
CSS3
• CSS3 is the latest version of the CSS specification CSS3 adds several new
styling features and improvements to enhance web presentation
capabilites.
CSS3: Rounded corners
• CSS3 rounded corners are used to add special colored corner to body or
text by using the border-radius property.
CSS: Rounded corners
<html> </head>
<head> <body>
<style> <p id = "rcorners1">Rounded
#rcorners1 { corners!</p>
border-radius: 25px; </body>
</html>
background: #8AC007;
padding: 20px;
width: 200px;
height: 150px;
}
</style>
CSS3: Border Image
• CSS3 border image property is used to add image border to some
elements.
CSS3: Border Image
<html> </head>
<head> <body>
<style> <p id = "rcorners1">Rounded
#rcorners1 { corners!</p>
border-radius: 25px; </body>
</html>
background: #8AC007;
padding: 20px;
width: 200px;
height: 150px;
}
</style>
CSS3: Multi Background
• CSS3 Multi Background property is used to add one or more images at a
time without HTML code.
CSS3: Border Image
<html> </head>
<head> <body>
<div id = "multibackground">
<style> <h1>Multibackground
#multibackground { Example</h1>
<p>
background-image:
CSS Multi background
url(“image1.jpg”), url(“image2.jpg”);
property is used to add one or more
background-position: left top, right top; images at a time without HTML code,
background-repeat: no-repeat, We can add images as per our
no-repeat; requirement.A sample syntax of multi
background images is as given.
padding: 25px; </p>
} </div>
</body>
</style>
</html>
CSS3: Shadow
• CSS3 supports to add shadow to text or elements.
h1{
text-shadow: 2px 2px;
}
• Above specification applies the horizontal shadow (2px), as well as the
vertical shadow (2px).
CSS3: Text Shadow
<html> <body>
<head> <h1>Internet Programming</h1>
<style> <h1>Internet Programming</h1>
h1 { </body>
text-shadow: 2px 2px; </html>
}
h2 {
text-shadow: 2px 2px red;
}
</style>
</head>
CSS3: Box Shadow
<html> <body>
<head> <div>This is a div element with a
<style> box-shadow</div>
div { </body>
width: 200px; </html>
height: 100px;
padding: 15px;
background-color: LightBlue;
box-shadow: 10px 10px;
}
</style>
</head>
CSS3: 2D Transform
• 2D Transforms are used to re-change the element structure as
translate, rotate, scale and skew.
• matrix(n,n,n,n,n,n) : Used to define matrix transforms with six values.
• translate(x,y): Used to transform the element along with x-axis and y-
axis.
• translateX(n): Used to transform the element along with x-axis.
• translateY(n): Used to transform the element along with y-axis.
• scale(x,y): Used to change the width and height of element.
• scaleX(n): Used to change the width of element
• scaleY(n): Used to change the height of element.
CSS3: 2D Transform
• rotate(angle) : Used to rotate the element based on an angle.
• skewX(angle): Used to define skew transforms along with X axis.
• skewY(angle): Used to define skew transforms along with Y axis.
CSS3: 2D Transform Rotate 20deg
<html> /* Standard syntax */
<head> transform: rotate(20deg);
<style> }
div { </style>
width: 250px; </head>
height: 90px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#myDiv { </div>
/* IE 9 */
<div id = "myDiv">
Internet Programming
-ms-transform: rotate(20deg);
</div>
/* Safari */
</body>
-webkit-transform: rotate(20deg);
</html>
CSS3: 2D Transform Rotate -20deg
<html> /* Standard syntax */
<head> transform: rotate(-20deg);
<style> }
div { </style>
width: 250px; </head>
height: 90px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#myDiv { </div>
/* IE 9 */
<div id = "myDiv">
Internet Programming
-ms-transform: rotate(-20deg);
</div>
/* Safari */
</body>
-webkit-transform: rotate(-20deg);
</html>
CSS3: 2D Transform skewX
<html> /* Standard syntax */
<head> transform: skewX(20deg);
<style> }
div { </style>
width: 250px; </head>
height: 90px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#skewDiv { </div>
/* IE 9 */
<div id = “skewDiv">
Internet Programming
-ms-transform: skewX(20deg);
</div>
/* Safari */
</body>
-webkit-transform: skewX(20deg);
</html>
CSS3: 2D Transform skewY
<html> /* Standard syntax */
<head> transform: skewY(20deg);
<style> }
div { </style>
width: 250px; </head>
height: 90px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#skewDiv { </div>
/* IE 9 */
<div id = “skewDiv">
Internet Programming
-ms-transform: skewY(20deg);
</div>
/* Safari */
</body>
-webkit-transform: skewY(20deg);
</html>
CSS3: 2D Transform matrix
<html> /* Standard syntax */
<head> transform: matrix(1, -0.5, 0, 1, 0, 0);
<style> }
div { </style>
width: 250px; </head>
height: 90px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#myDiv1 { </div>
/* IE 9 */ <div id = “myDiv1">
-ms-transform: matrix(1, -0.5, 0, 1, 0, 0); Internet Programming
/* Safari */ </div>
-webkit-transform: matrix(1, -0.5, 0, 1, 0, </body>
0);
</html>
CSS3: 2D Transform scale
<html> /* Standard syntax */
<head> transform: scale(0.7, 0.7);
<style> }
div { </style>
width: 250px; </head>
height: 90px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#myDiv2 { </div>
/* IE 9 */
<div id = “myDiv2">
Internet Programming
-ms-transform: scale(0.7, 0.7);
</div>
/* Safari */
</body>
-webkit-transform: scale(0.7, 0.7);
</html>
CSS3: 3D Transform
• With 3D transforms, we can move element to x-axis, y-axis and z-axis.
• matrix(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) : Used to transforms the element by
using 16 values of matrix.
• translate3d(x,y,z): Used to transform the element by using x-axis, y-axis and
z-axis.
• translateX(x): Used to transform the element by using x-axis.
• translateY(y): Used to transform the element by using y-axis.
• translateZ(z): Used to transform the element by using z-axis.
• scaleX(x): Used to scale transforms the element using x-axis.
• scaleY(y): Used to scale transforms the element using y-axis.
• scaleZ(z): Used to scale transforms the element using z-axis.
CSS3: 3D Transform
• rotateX(angle): Used to rotate transforms the element using x-axis.
• rotateY(angle): Used to rotate transforms the element using y-axis.
• rotateZ(angle): Used to rotate transforms the element using z-axis.
CSS3: 3D Transform rotateX
<html> /* Standard syntax */
<head> transform: rotateX(150deg);
<style> }
div { </style>
width: 200px; </head>
height: 100px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#xDiv { </div>
/* IE 9 */
<div id = “xDiv">
Internet Programming
-ms-transform: rotateX(150deg);
</div>
/* Safari */
</body>
-webkit-transform: rotateX(150deg);
</html>
CSS3: 3D Transform rotateY
<html> /* Standard syntax */
<head> transform: rotateY(150deg);
<style> }
div { </style>
width: 200px; </head>
height: 100px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#yDiv { </div>
/* IE 9 */
<div id = “yDiv">
Internet Programming
-ms-transform: rotateY(150deg);
</div>
/* Safari */
</body>
-webkit-transform: rotateY(150deg);
</html>
CSS3: 3D Transform rotateZ
<html> /* Standard syntax */
<head> transform: rotateZ(150deg);
<style> }
div { </style>
width: 200px; </head>
height: 100px; <body>
background-color: LightBlue; <div>
border: 1px solid black; } Internet Programming
div#zDiv { </div>
/* IE 9 */
<div id = “zDiv">
Internet Programming
-ms-transform: rotateZ(150deg);
</div>
/* Safari */
</body>
-webkit-transform: rotateZ(150deg);
</html>
CSS Transitions
• CSS Transitions allows you to change property values smoothly, over a
given duration.
• Following are the properties of transition:
• transition
• transition-delay
• transition-duration
• transition-property
• transition-timing-function
CSS Transitions
• To create a transition effect, you must specify two things:
• The css property you want to add an effect to
• The duration of the effect
• If the duration part is not specified, the transition will have no effect.
• The transition effect will start when the specified CSS property changes
value.
CSS:Transition Property
<html> <body>
<head> <h1>The transition property</h1>
<style> <p>Hover over the div element
div { below, to see the transition effect:</p>
width: 100px; <div></div>
</body>
height: 100px;
</html>
background: LightGreen;
transition: width 2s; }
div:hover {
width: 300px; }
</style>
</head>
CSS:Transition Property
<!DOCTYPE html> </style>
<html> </head>
<head>
<body>
<style>
<h1>The transition Property</h1>
div {
width: 100px; <p>Hover over the div element
height: 100px; below, to see the transition
background: Purple; effect:</p>
transition: width 2s, height 5s; <div></div>
} </body>
div:hover { width: 300px; height:
300px; } </html>
CSS Transitions Speed Curves
• The transition-timing-function property specifies the speed curve of the
transition effect.
• The transition-timing-function property can have the following values:
• ease: Specifies a transition effect with a slow start, then fast, then end slowly.
• linear: Specifies a transition effect with the same speen from start to end.
• ease-in: Specifies a transition effect with a slow start.
• ease-out: Specifies a transition effect with a slow end.
• ease-in-out: Specifies a transition effect with a slow start and end.
• cubic-bezier(n,n,n,n): Lets you define your own values in a cubic-bezier
function.
CSS Transitions Speed Curves
<!DOCTYPE html> div:hover { width: 300px; }
<html> </style>
<head> </head>
<style> <body>
div { width: 100px; <h1>The transition-timing-function
height: 100px;
Property</h1>
<p>Hover over the div elements below,
background: Grey;
to see the different speed curves:</p>
transition: width 4s;} <div id="div1">linear</div><br>
#div1 {transition-timing-function: linear;} <div id="div2">ease</div><br>
#div2 {transition-timing-function: ease;} <div id="div3">ease-in</div><br>
#div3 {transition-timing-function: ease-in;} <div id="div4">ease-out</div><br>
#div4 {transition-timing-function: ease-out;} <div id="div5">ease-in-out</div><br>
#div5 {transition-timing-function: ease-in-out;} </body>
</html>
CSS Transition Delay
• The transition-delay property specifies a delay (in seconds) for the
transition effect.
• The given example has a 2 seconds delay before starting.
CSS Transition Delay
<!DOCTYPE html> <body>
<html>
<head> <h1>The transition-delay Property</h1>
<style>
div { <p>Hover over the div element below,
width: 100px;
to see the transition effect:</p>
height: 100px;
<div></div>
background: LightPink;
transition: width 3s; <p><b>Note:</b> The transition effect
transition-delay: 2s; has a 2 seconds delay before
} starting.</p>
div:hover { width: 300px; }
</style> </body>
</head>
</html>
CSS Transition Properties
Property Description

transition A shorthand property for setting the four transition


properties into a single property
transition-delay Specifies a delay (in seconds) for the transition
effect
transition-duration Specifies how many seconds or milliseconds a
transition effect takes to complete
transition-property Specifies the name of the CSS property the
transition effect is for
transition-timing- Specifies the speed curve of the transition effect
function
CSS Animations
• CSS allows animation of HTML elements without using JavaScript or
Flash.
• Following are the animation properties:
• @keyframes
• animation-name
• animation-duration
• animation-delay
• animation-iteration-count
• animation-direction
• animation-timing-function
• animation-fill-mode
• animation
CSS Animations
• An animation lets an element gradually change from one style to
another.
• To use CSS animation, you must first specify some keyframes for the
animation.
• Keyframes hold what styles the element will have at certain times.
CSS Animations: The @keyframes rule
• When you specify CSS styles inside the @keyframes rule, the animation will
gradually change form the current style to the new style at certain times.
• To get an animation to work, you must bind the animation to an element.
• The given example binds the “example” animation to the <div> element. The
animation will last for 5 seconds, and it will gradually change the
background-color of the <div> element from “LightBlue” to “Green”.
• In the example, from represents 0%(start) and to represents
100%(complete).
• The animation-duration property defines how long an animation should take
to complete.
• If the animation-duration property is not specified, no animation will occur.
CSS Animation
<!DOCTYPE html> @keyframes example {
<html> from {background-color: LightBlue;}
to {background-color: Green;}
<head> }
<style> </style>
div { </head>
<body>
width: 100px; <h1>CSS Animation</h1>
height: 100px; <div></div>
background-color: LightBlue; <p><b>Note:</b> When an
animation is finished, it goes
animation-name: example;
back to its original style.</p>
animation-duration: 5s; </body>
} </html>
CSS Animation
<!DOCTYPE html> @keyframes example {
0% {background-color: Blue;}
<html> 25% {background-color: Green;}
<head> 50% {background-color: Yellow;}
100% {background-color: Red;}
<style> }
</style>
div { </head>
width: 100px; <body>
<h1>CSS Animation</h1>
height: 100px; <div></div>
background-color: LightBlue; <p><b>Note:</b> When an
animation is finished, it goes back
animation-name: example; to its original style.</p>
</body>
animation-duration: 5s;
</html>
}
CSS Animations
• The animation-delay property specifies a delay for the start of an
animation.
• The animation-iteration-count property specifies the number of times
an animation should run.
• The animation continues forever by setting the animation-iteration-
count with infinite value.
CSS Animation
<!DOCTYPE html> @keyframes example {
0% {background-color: Blue;}
<html> 25% {background-color: Green;}
<head> 50% {background-color: Yellow;}
<style> 100% {background-color: Red;}
}
div { </style>
width: 100px; </head>
<body>
height: 100px; <h1>CSS Animation</h1>
background-color: LightBlue; <div></div>
<p><b>Note:</b> When an
animation-name: example; animation is finished, it goes back
animation-duration: 5s; to its original style.</p>
</body>
animation-delay: 2s; </html>
}
CSS Animation
<!DOCTYPE html> @keyframes example {
0% {background-color: Blue;}
<html> 25% {background-color: Green;}
<head> 50% {background-color: Yellow;}
<style> 100% {background-color: Red;}
}
div { </style>
width: 100px; </head>
<body>
height: 100px; <h1>CSS Animation</h1>
background-color: LightBlue; <div></div>
<p><b>Note:</b> When an
animation-name: example; animation is finished, it goes back
animation-duration: 5s; to its original style.</p>
</body>
animation-iteration-count: 3; </html>
}
CSS Animation
<!DOCTYPE html> @keyframes example {
0% {background-color: Blue;}
<html> 25% {background-color: Green;}
<head> 50% {background-color: Yellow;}
<style> 100% {background-color: Red;}
}
div { </style>
width: 100px; </head>
<body>
height: 100px; <h1>CSS Animation</h1>
background-color: LightBlue; <div></div>
<p><b>Note:</b> When an
animation-name: example; animation is finished, it goes back
animation-duration: 5s; to its original style.</p>
</body>
animation-iteration-count: infinite; </html>
}
CSS Animations
• The animation-direction property specifies whether an animation
should be played forwards, backwards or in alternate cycles.
• The animation-direction property can have the following values:
• normal: The animation is played as normal (forwards).
• reverse: The animation is played in reverse direction (backwards).
• alternate: The animation is played forwards first, then backwards.
• alternate-reverse: The animation is played backwards first, then
forwards.
CSS Animation
<!DOCTYPE html> @keyframes example {
0% {background-color: Blue;}
<html> 25% {background-color: Green;}
<head> 50% {background-color: Yellow;}
<style> 100% {background-color: Red;}
}
div { </style>
width: 100px; </head>
<body>
height: 100px; <h1>CSS Animation</h1>
background-color: LightBlue; <div></div>
<p><b>Note:</b> When an
animation-name: example; animation is finished, it goes back
animation-duration: 5s; to its original style.</p>
</body>
animation-direction: reverse; </html>
}
CSS Animation Properties
Property Description
@keyframes Specifies the animation code
animation A shorthand property for setting all the animation properties
Animation-delay Specifies a delay for the start of an animation
Animation-direction Specifies whether an animation should be played forwards, backwards or in
alternate cycles
Animation-duration Specifies how long time an animation should take to complete one cycle

Animation-fill-mode Specifies a style for the element when the animation is not playing (before
it starts, after it ends, or both)
Animation-iteration-count Specifies the number of times an animation should be played

Animation-name Specifies the name of the @keyframes animation


Animation-play-state Specifies whether the animation is running or paused
Animation-timing-function Specifies the speed curve of the animation

You might also like