Web Design Notes
Web Design Notes
After the completion of the course, students are expected to have the ability to:
1. CO-1. Understand the internet related concepts that are vital in understanding web
application
development.
2. CO-2. Analyze and apply the role of markup languages like HTML, DHTML, and
XML in the
and also develop the web application using servlet and JSP.
Unit-1 Introduction: Introduction and web development strategies, history of web and
internet, protocols governing web, introduction to client-server computing, web applications,
web project, and web team.
Unit-2 Web Page Designing: HTML: List, table, images, frames, forms, CSS, document
type definition, object Models, presenting and using XML, XML Processors: DOM and
SAX, and dynamic HTML.
Unit-4 Server Site Programming: Introduction to active server pages (ASP), introduction to
Java Server Page (JSP), JSP application design, JSP objects, conditional processing, declaring
variables and methods, sharing data between JSP pages.
Text Books:
Reference Books:
• Web technology refers to the various tools and techniques that are u@lized in the
process of communica@on between different types of devices over the internet.
• A web browser is used to access web pages. Web browser can be defined as
programs that display text, data, pictures, anima@on, and video on the internet.
• Linked resources on the World Wide Web can be accessed using soIware interfaces
provided by Web browsers.
The World Wide Web is a system of interlinked hypertext documents accessed via the
internet. Web is a huge collec@on of pages of informa@on linked to each other around the
globe.
History of WWW
• WWW is created by Sir Tim Berners Lee in 1989 at CERN (European Organiza.on for
Nuclear Research is an intergovernmental organiza@on that operates the
largest par@cle physics laboratory in the world) in Geneva.
• In 1990, the first text only browser were setup and CERN scien@st could access
hypertext files and other informa@on at CERN. HTML was based on a subset of the
standard generalized markup language (SGML). To transfer HTML document to
remote sites a new protocol was devised called HTTP.
• In 1993, there are only about 50 websites worldwide. A browser that allowed user to
take advantages of the web’s graphical capabili@es was developed at the Na@onal
Center for Super Compu@ng Applica@on (NCSA). NCSA called the browser Mosaic.
• Web editor (First web browser), first web server (h_p://info.cern.ch).
• It is the crea@on of an applica@on that works over the internet i.e., websites.
• Web development is done in two ways:
o Frontend Development
o Backend Development
• Frontend Development: The part of the website that the user interacts directly is
termed as front end. Also refers as ‘client-side’ of the applica@on.
o HTML
o CSS
o JavaScript
o AJAX
• Backend Development: It is referred as ‘server-side’ of the applica@on. Backend
development covers server-side development, applica@on integra@on, and ac@vi@es
like crea@ng libraries and wri@ng APIs. The backend por@on is built by using some
languages. These are men@oned below:
o Java
o PHP
o Python
o Node.js
o Ruby
Types of Protocol
TCP/IP Protocol: TCP is a protocol that converts data into packets so that it can be sent
between a server and a client. Organiza@ons use TCP to transfer content such as files, text,
images, and emails because it guarantees that the packets will be delivered accurately and in
the correct order.
It’s worth no@ng that TCP will establish a connec@on between the origin and the des@na@on
devices before a_emp@ng to transfer data. This three-way handshake is outlined briefly
below:
• The client or web browser sends the des@na@on server a Synchronize Sequence
Number (SYN).
• The des@na@on server sends an acknowledgement message known as SYN-ACK.
• The origin device receives the SYN-ACK message and generates an ACK
acknowledgement message, which finalizes the connec@on.
User Datagram Protocol (UDP): UDP is a communica@on protocol that’s designed to send
packets from one device to another on a network. Many organiza@ons use UDP as an
alterna@ve to TCP because it offers higher transfer speeds.
While this increase in speed comes at the cost of accuracy, UDP be_er supports video/audio
streaming services, online games, or voice-over-internet-protocol (VoIP) calls, which can
handle some degree of data loss.
Another key difference between the two is that UDP won’t a_empt to establish a connec@on
before sending packets on to the des@na@on. At the same @me, it also doesn’t guarantee the
delivery of data to the other device.
File Transfer Protocol: FTP is a network protocol that’s used to transfer files from one device
to another over an unencrypted TCP/IP connec@on. With FTP, a user can load up a web
browser or FTP client such as FileZilla or FTP Voyager and send up to 2GB at once.
Many organiza@ons use FTP because of its ability to send large files or lots of files at once in
a way that’s fast and efficient. Unfortunately, this efficiency comes at the cost of security as
FTP transmits all data in plain text.
For this reason, many organiza@ons opt to use a secure version of FTP called File Transfer
Protocol Secure Sockets Layer (FTPS), which func@ons the same but uses SSL encryp@on to
obscure the transferred data.
Hypertext Transfer Protocol (HTTP): HTTP is a communica@on protocol that enables systems
to communicate on the World Wide Web. With HTTP, a client will send a hypertext message
request to a web server asking for access to the resources needed to load a web page.
The server hos@ng the content will then respond and enable the client to load all the
necessary text, images and videos featured on the page. HTTP’s request-response cycle is
outlined briefly below:
SNMP is an applica@on layer protocol that’s used to collect management informa@on from
devices such as computers, routers, switchers, firewalls and printers.
Network monitoring planorms oIen use SNMP to monitor the performance and status of
devices throughout a network in real @me.
The protocol works with an SNMP manager or soIware client sending SNMP GET requests
to SNMP-enabled devices.
POP3 is a network protocol that enables a server to retrieve emails from a remote server
and download them to the local device. Whenever the client connects to the server via TCP,
it automa@cally downloads all the new messages to it, making them accessible to the user
both online and off-line.
Email planorms like MicrosoI Outlook can use POP3 to collect email messages from remote
servers via TCP/IP so that they’re available off-line.
SMTP is a mail delivery protocol that allows a device to send and deploy email to a remote
endpoint with a TCP connec@on. Many providers including MicrosoI Outlook, Gmail and
Yahoo Mail use SMTP to send messages to remote servers.
Briefly, an organiza@on will first create an SMTP server, which employees can connect to and
communicate with via a mail user agent (MUA) or email client such as Gmail. Through this
connec@on, they can deliver emails to the SMTP server and other users.
Unlike POP3, SMTP cannot retrieve emails from a mailbox, and unlike POP3, it doesn’t
automa@cally delete emails.
• The client sends a request to the server (e.g., asking for a webpage or data).
• The server processes the request and sends back the required response (e.g., the HTML of
a webpage, a file, or data from a database).
• This interaction typically takes place over a network, such as the internet or a local area
network (LAN).
• Web Browsing: The browser (client) requests a webpage from a web server, which
returns the content of the page.
• Email: An email client (like Outlook or Gmail) sends and receives emails by
communica@ng with email servers.
• Database Access: A client applica@on requests informa@on from a database server,
which retrieves and returns the requested data.
• Centraliza.on: Resources, applica@ons, and data are centralized on the server, which
simplifies maintenance, updates, and security.
• Scalability: Servers can handle mul@ple clients simultaneously, making it possible to
scale the system by adding more servers as demand increases.
• Security: Since data is stored on the server, access control and security measures can
be centrally enforced.
Disadvantages:
• Single Point of Failure: If the server goes down, all clients lose access to the services
it provides.
• Cost: Sefng up and maintaining a server infrastructure can be costly, especially for
large systems.
Web Applica.on
A web applica@on is a soIware applica@on that runs on a web server and is accessed by
users through a web browser over a network, typically the internet or an intranet. Unlike
tradi@onal desktop applica@ons, which are installed locally on a computer, web applica@ons
are hosted online and do not require installa@on on individual devices.
1. Cross-PlaTorm Access: Web applications can be accessed from any device with a web
browser and an internet connection, regardless of the operating system (Windows,
macOS, Linux, iOS, Android, etc.).
2. No Installa.on Needed: Users don't need to install software on their devices. They
simply navigate to a URL in their web browser to access the application.
3. Client-Server Architecture: Web applications typically follow the client-server
architecture, where the client (web browser) interacts with the server (web server
hosting the application). The server processes the requests, performs necessary
computations, and returns the appropriate responses.
4. Real-Time Updates: Web applications are centrally hosted, so updates or changes to
the application are deployed on the server, making them instantly available to all users
without needing manual updates on individual devices.
5. Interac.ve User Interface: Modern web applications often provide rich, interactive
user interfaces that are similar to desktop applications, using technologies like
HTML5, CSS, and JavaScript.
• Frontend (Client-Side):
o Languages: HTML, CSS, JavaScript.
o Frameworks/Libraries: React, Angular, Vue.js, Bootstrap, jQuery.
• Google Docs: A cloud-based word processor that allows users to create, edit, and
share documents online.
• Gmail: A web-based email client where users can send, receive, and organize their
emails via a web browser.
• Facebook/TwiUer: Social media planorms that are fully accessible through a web
browser, offering interac@ve features like pos@ng updates, messaging, and more.
• eCommerce Sites: Planorms like Amazon or eBay where users can browse products,
make purchases, and manage their accounts.
Web Project
A web project refers to the process of planning, designing, and developing a website or web
application. It typically involves multiple stages, from conceptualizing the idea to deploying
the final product. Web projects can range from simple websites, like blogs or personal
portfolios, to complex web applications, such as eCommerce platforms or social networking
sites.
• Goal: Create a simple web app where users can add, edit, delete, and manage tasks.
• Target Audience: Users who need a lightweight and easy-to-use task manager.
• Technology Stack: HTML, CSS, JavaScript (frontend); Node.js/Express (backend);
MongoDB (database).
Design:
• Create wireframes showing how the task list will look and where buttons (e.g., "Add
Task," "Delete Task") will be placed.
• Focus on user experience (UX) and user interface (UI) design.
• Ensure responsive design for multiple devices.
• Development:
• Frontend development (HTML, CSS, JavaScript) for the visual and interactive
components.
• Backend development (server, database, APIs) for logic and data management.
• Integrate the frontend and backend components.
• Testing:
• Conduct functionality tests to ensure features work as expected.
• Perform usability and performance testing.
• Test cross-browser and cross-device compatibility.
• Deployment:
• Set up hosting and domain configurations.
• Deploy the web project to a live server.
• Implement search engine optimization (SEO) and analytics.
• Maintenance:
• Monitor the project for bugs and security issues.
• Update the web application with new features and improvements.
• Provide ongoing support and maintenance.
Web Team
A web team is a group of professionals with different skill sets working together to plan,
design, develop, test, and maintain a web project. The composition of a web team varies
depending on the complexity and scale of the project, but it typically includes the following
roles:
1. Project Manager:
o Oversees the en@re project from start to finish.
o Manages @melines, budgets, communica@on, and the team’s workload.
o Acts as the liaison between the client and the web team.
2. Frontend Developer:
o Responsible for the visual and interac@ve aspects of the web project.
o Works with HTML, CSS, and JavaScript to build the user interface.
o Ensures responsive design and browser compa@bility.
Collabora@on Tools:
Topic- I
Web Casting
Webcas@ng refers to the process of broadcas@ng live or recorded audio or video content
over the internet. Webcas@ng is widely used for various purposes, including business
presenta@ons, webinars, live events, entertainment shows, and educa@onal content.
1. Live Webcas.ng:
o Defini.on: Broadcas@ng live events in real @me over the internet.
o Use Cases: Sports events, conferences, concerts, webinars.
o Technology: Requires encoding soIware/hardware, content delivery
networks (CDNs), and streaming planorms like YouTube Live or Facebook Live.
o Pros: Instantaneous interac@on with the audience, real-@me engagement.
o Cons: Requires strong internet connec@on and technical setup to ensure
smooth delivery.
2. On-Demand Webcas.ng:
o Defini.on: Pre-recorded content that can be accessed by users at any @me.
o Use Cases: Training videos, recorded webinars, product demos.
o Technology: Media is stored on servers and streamed using planorms like
Vimeo, YouTube, or company-specific planorms.
o Pros: Flexibility for users to access content whenever they want.
o Cons: Limited real-@me interac@on with the audience.
3. Interac.ve Webcas.ng:
o Defini.on: Broadcas@ng that includes interac@ve features such as polls,
quizzes, or live chats to engage viewers ac@vely.
o Use Cases: Educa@onal webinars, corporate mee@ngs, online conferences.
o Technology: Webcas@ng planorms with built-in engagement tools (Zoom
Webinars, Webex).
o Pros: High engagement and par@cipa@on from the audience.
o Cons: Requires more prepara@on and planorm capabili@es.
4. Social Media Live Webcas.ng:
o Defini.on: Broadcas@ng live video content directly via social media planorms.
o Use Cases: Social media influencers, businesses reaching out to customers,
marke@ng events.
o Technology: Facebook Live, Instagram Live, LinkedIn Live, etc.
o Pros: Easy access to a wide audience through familiar planorms.
o Cons: Limited control over planorm features and data.
5. 360-Degree and VR Webcas.ng:
o Defini.on: A more immersive webcas@ng experience using 360-degree
cameras and virtual reality.
Topic- II
TCP/IP
The TCP/IP model is divided into four layers, each responsible for specific aspects of data
transmission.
1. Application Layer
o Func.on: The Applica@on Layer is the top layer and is responsible for
interac@ng with the user and providing network services directly. It defines
protocols that allow soIware to communicate over a network, providing
interfaces for end-users.
o Protocols: HTTP (Hypertext Transfer Protocol), FTP (File Transfer Protocol),
SMTP (Simple Mail Transfer Protocol), DNS (Domain Name System), and
more.
o Examples: Web browsers, email clients, and file transfer applica@ons work at
this layer.
o Purpose: It allows users to interact with network services and applica@ons,
such as browsing the web, sending emails, or accessing files.
2. Transport Layer
o Func.on: The Transport Layer ensures reliable data transmission between
devices. It is responsible for error detec@on and correc@on, flow control, and
data segmenta@on.
o Protocols:
§ TCP (Transmission Control Protocol): Ensures reliable, ordered, and
error-checked delivery of data.
§ UDP (User Datagram Protocol): Provides faster, connec@onless
transmission without error checking or ordering.
o Purpose: The Transport Layer controls the flow of data and ensures that data
packets are transmi_ed correctly, received in order, and are error-free. TCP
provides acknowledgment, while UDP priori@zes speed over reliability.
3. Internet Layer
Conclusion
The TCP/IP model is the backbone of modern internet communication. Each layer plays a
critical role in ensuring that data is transmitted, routed, and received correctly across a
network, enabling seamless communication between devices.
Topic- III
Web browser:
• Function: A web browser is a client-side application that allows users to access and view
content on the internet. It sends requests to web servers and displays the returned content
(e.g., websites, web apps) to users.
• Examples: Google Chrome, Mozilla Firefox, Safari, Microsoft Edge.
• Role:
• Interprets and renders HTML, CSS, JavaScript, and other web content.
• Provides a user interface for navigating websites, managing bookmarks, and
interacting with web apps.
• Uses HTTP/HTTPS protocols to communicate with web servers.
Web Server:
Topic- IV
Website and the steps for developing a website with suitable example.
Website: A website is a collec@on of web pages that are accessed via the internet, typically
through a web browser like Chrome, Firefox, or Safari. Websites can serve various purposes,
such as providing informa@on, selling products, offering services, or facilita@ng
communica@on.
This example outlines the basic steps for developing a simple website. More complex sites,
like e-commerce planorms or social networks, will require addi@onal considera@ons like
advanced security measures, payment gateways, and custom func@onality.
Topic- V
The Internet Protocol (IP) is a fundamental communica@on protocol in the Internet Protocol
Suite that enables the transfer of data across the internet. IP is responsible for addressing,
rou@ng, and delivering data packets from the source host to the des@na@on host based on
their IP addresses.
IPv4 is the fourth version of the Internet Protocol and the first widely deployed IP protocol. It
uses a 32-bit address scheme, allowing for approximately 4.3 billion unique IP addresses.
IPv6 is the successor to IPv4, designed to address the limitations of IPv4, particularly the
exhaustion of IP addresses. IPv6 uses a 128-bit address scheme, vastly expanding the number
of available addresses.
• Address Format: IPv6 addresses are wri_en in hexadecimal and separated by colons,
consis@ng of eight 16-bit blocks (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
• Address Space: 128 bits, allowing for 2^128 (about 3.4×10^38) unique addresses,
which is a virtually limitless supply.
• Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334, fe80::1
• Header Size: 40 bytes (fixed)
HTML Introduction
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Web Page</title>
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
</header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<section id="home">
<h2>Home Section</h2>
<p>This is the home section of the website.</p>
</section>
<section id="about">
<h2>About Section</h2>
<p>Information about this site and its purpose.</p>
</section>
<footer>
<p>© 2024 My Website</p>
</footer>
</body>
</html>
HTML History
HTML has a rich history that spans several decades. Here’s a brief overview of
its development:
• W3C: The World Wide Web ConsorDum (W3C) was established in 1994
to manage the development of web standards. HTML 2.0 was published
in 1995, and it added new features such as forms and tables, enhancing
the ability to create interacDve and structured web pages.
• Improvements: HTML 3.2 introduced support for style sheets (CSS) and
scripDng languages like JavaScript. This version allowed for more
complex and visually appealing web designs, including the ability to
integrate mulDmedia elements such as audio and video.
6. HTML5 (2014)
List
HTML provides several ways to create lists, allowing you to organize content
in a structured manner. There are three main types of lists in HTML:
Syntax:
<ol>
<li>First item</li>
<li>Second item</li>
Common A]ributes:
Syntax:
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
Output:
• First item
• Second item
• Third item
Common A]ributes:
Syntax:
<dl>
<dt>Term 1</dt>
<dd>Defini@on of term 1</dd>
<dt>Term 2</dt>
<dd>Defini@on of term 2</dd>
</dl>
Output:
Term 1
Definition of term 1
Term 2
Definition of term 2
Table
In HTML, tables are used to organize and display data in rows and columns. A
table consists of several elements, each playing a role in defining the structure
of the data.
Example:
<table border="1">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
Output:
First Name Last Name Age
John Doe 30
Jane Smith 25
1. Table Borders:
By default, HTML tables do not display borders. You can add borders using
the border attribute or CSS:
Syntax:
<table border="1">
<!-- Table content -->
</table>
You can divide a table into three parts using <thead>, <tbody>, and <tfoot> to
help structure complex tables.
Syntax:
<table border="1">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>30</td>
</tr>
<tr>
<td>Jane</td>
<td>Smith</td>
<td>25</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Footer Information</td>
</tr>
</tfoot>
</table>
Output:
Images
In HTML, the <img> tag is used to embed images into a webpage. Unlike other
elements, the <img> tag is self-closing, meaning it doesn't need a closing tag.
A]ributes:
1. src (Source): Specifies the path to the image file. This can be a relative
path (for images stored locally) or an absolute URL (for images hosted
online).
o Example: src="images/picture.jpg"
o Example: src="hBps://example.com/picture.jpg"
2. alt (Alternate Text): Provides a text description of the image, which is
useful for accessibility and displayed if the image cannot load.
o Example: alt="A scenic view of a mountain"
3. width and height: Specifies the dimensions of the image (in pixels or
percentage).
o Example: width="500" (sets width to 500 pixels)
o Example: height="300" (sets height to 300 pixels)
Responsive Images:
You can create responsive images that automatically resize based on the
device's screen size. This is done using CSS or by setting the width to a
percentage:
Image as a Link:
You can also make an image clickable by wrapping it inside an <a> tag:
<a href="https://example.com">
<img src="image.jpg" alt="Clickable image" width="300">
</a>
In HTML, frames were originally used to divide a web page into multiple
sections where each section could display a different HTML document.
The <frameset> element was used to define a set of frames, and
the <frame> element would define each individual frame within the set.
<!DOCTYPE html>
<html>
<head>
<title>Frames Example</title>
</head>
<frameset cols="50%,50%">
<frame src="https://example.com" name="leftFrame">
<frame src="https://www.wikipedia.org" name="rightFrame">
</frameset>
</html>
ExplanaDon:
Forms
HTML forms are used to collect user input and send it to a server for
processing. A form is created using the <form>element, and it can contain
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Form Example</title>
</head>
<body>
<h1>Contact Form</h1>
<form action="/submit_form" method="POST">
• GET: Appends form data to the URL, visible in the browser (good for
simple searches).
• POST: Sends data in the body of the request, more secure for sending
sensiDve informaDon (like passwords).
CSS
h1 {
color: blue;
}
.menu {
background-color: #f2f2f2;
}
#header {
font-size: 24px;
}
body {
background-color: #fff;
font-family: Arial, sans-serif;
line-height: 1.6;
}
.container {
display: flex;
justify-content: center;
align-items: center;
}
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
Benefits of Using CSS in Web Design:
CSS Proper)es:
Comment: CSS
• Single line comment
• Multi line comment
/* This is a comment */
e.g.
background-image: linear-gradient: (to top right , #051937, #004d7a, #008793,
#00bf72, #a8eb12);
Lengths: CSS
There are two types of length in CSS which are:
1) Absolute length
a) px(Pexel)
b) in(Inches)
c) pt(Points)
2) Relative length
a) em
b) rem(Root em)
c) %(Percentage)
Absolute length: The absolute length units are fixed, and a length expressed in any of
these will appear as exactly that size.
RelaDve length: Relative length units specify a length relative to another length property.
Relative length units scale better between different rendering medium.
Percentage(%): Percentage are relative units based on the parent element’s size or the
containing block. Widely used in creating responsive layouts.(100%=16px)
Root Em(rem): rem is also a relative unit like em, but it’s based on the font size of the root
(html). Using rem ensures that the size is consistent throughout the entire document,
making it especially user responsive design.(1rem=16px or 1rem=10px)
Font Family: The ‘font family’ property allows you to specify the font used for text.
Font Size: The ‘font size’ property controls the size of text.
Value: px, em, rem, %, keywords(small,medium,large).
Font Weight: The ‘font weight’ property defines the thickness of text characters, ranging
from ‘100’ (thin) to ‘900’ (bold).
Font Style: The ‘font style’ property allows you to apply styles like italic to text.
Value: normal(default), italic, oblique.
Font Variant: The ‘font variant’ property is used to control the appearance of text
characters by modifying their variant forms.
Value: normal, small-caps.
Text Alignment: The ‘text alignment’ property controls the horizontal alignment of text
within an element’s box.
Value: left, right, center, and justify.
Text Transform: The ‘text transform’ property allows you to control the capitalization of
text.
Value: lowercase, uppercase, capitalize.
Word-spacing property: The word spacing property controls the spacing between
words in a text.
The line-height property: The line height property is used to specify the space
between lines.
Text shadow: The text shadow property allows you to add a shadow effect to text
characters.
Value: horizontal shadow offset, ver@cal shadow offset, and shadow color.
Border Property:
1.Border style:
e.g.
border-style: solid;
2.Border width:
3.Border color:
e.g.
border-color: #003180;
Other proper@es:
e.g.
border-top-width: 15px;
border-top-style: solid;
border-top-color: #003b99;
4.Border radius:
e.g.
border-radius: 10px;
Padding:
e.g.
padding: 10px; /* Apply to all four sides */
padding: 10px 20px; /* top and bo_om | leI and right */
padding: 5px 10px 15px 20px; /* top | right | bo_om | leI */
padding: 5px 10px 15px; /* top | right-leI | bo_om
padding-leI:5px;
Margin:
e.g.
margin: 10px;
margin: 10px 20px; /* top and bo_om | leI and right */
margin: 10px 20px 30px; /* top | right | bo_om | leI */
A Document Type Definition (DTD) in web design refers to a set of rules that defines the
structure, elements, and attributes that can be used in an HTML or XML document. The DTD
specifies how the document should be formatted and ensures that it follows certain
standards, making it easier for browsers to correctly interpret and display the content.
1. Defines Document Structure: It tells the web browser the rules the HTML or XML
document follows, such as the types of elements allowed and their relationship to
one another.
There are different types of DTDs used in HTML, each providing different rules and flexibility
in writing the document.
• Strict DTD: It does not allow deprecated elements or attributes (those no longer
recommended in modern HTML). Example:
• Transitional DTD: Allows deprecated elements, making it easier to use older HTML
elements. Example:
HTML5 doesn’t require a formal DTD declaration because it simplifies the syntax, but the
following declaration is still recommended:
<!DOCTYPE html>
The DTD is declared at the very beginning of an HTML or XML document. It helps the
browser or parser to understand which version of HTML or XML is being used, thus ensuring
proper rendering of the page
XML
XML (Extensible Markup Language) is widely used in web design and development to store,
transport, and organize data. Unlike HTML, which is focused on displaying data, XML is
designed to store and transport data in a structured and self-descriptive format.
1. Data Storage and Transfer: XML is commonly used to store and transport data
between servers and clients or between different systems. It provides a flexible and
readable format for data that can be processed and displayed dynamically by web
applications.
2. Separation of Data from HTML: XML allows designers to separate the content (data)
from the presentation (HTML). This promotes cleaner design and makes it easier to
update or reuse data without changing the presentation layer.
3. Interoperability between Systems: XML is platform-independent and language-
neutral, allowing different systems and applications (like web services) to
communicate and exchange data seamlessly. It is often used in APIs and web
services (SOAP, REST) for data exchange.
4. Configuration Files: XML is used for configuration files in web applications. These
files define settings, preferences, and other parameters for the web app, making it
easy to update or modify the behavior of the app without changing the code.
5. Custom Markup Language: XML allows developers to define their own custom tags.
This flexibility is beneficial when there is a need to create domain-specific markup
languages, for example, RSS feeds or SVG (Scalable Vector Graphics).
6. Data Exchange in Web Services: XML is commonly used in SOAP (Simple Object
Access Protocol) for exchanging structured information in web services, where XML
messages are sent over HTTP.
XML by itself does not have a predefined way of displaying data like HTML. Therefore,
additional technologies are used to present or style XML data.
XSLT is used to transform XML documents into other formats, such as HTML, PDF, or
another XML document. XSLT can be used to apply style rules to the XML data, making it
presentable on the web.
#Style Sheet
The Document Object Model (DOM) is a programming interface for web documents. It
represents the structure of an HTML or XML document as a tree of objects. Through the
DOM, developers can interact with, manipulate, and update the content, structure, and
style of a webpage in a dynamic manner.
Advantages:
SAX is an event-driven model for parsing XML documents, typically used in scenarios where
memory efficiency is crucial. Unlike DOM, SAX doesn’t load the entire document into
memory but instead parses the document sequentially and triggers events when it
encounters specific components (e.g., opening tags, closing tags, text content).
import xml.sax
class MyHandler(xml.sax.ContentHandler):
def startElement(self, name, attrs):
print(f"Start element: {name}")
parser = xml.sax.make_parser()
parser.setContentHandler(MyHandler())
parser.parse("example.xml")
Advantages:
• Uses less memory than DOM, making it ideal for large documents.
• Simple for parsing sequential data without needing random access.
Disadvantages:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic HTML Example</title>
<div id="myDiv"></div>
<button onclick="changeColor()">Change Color</button>
<script>
function changeColor() {
document.getElementById("myDiv").style.backgroundColor = "blue";
}
</script>
</body>
</html>
Explanation:
• JavaScript dynamically manipulates the CSS of the element with the ID myDiv,
changing its background color from red to blue when the button is clicked.
Features:
Uses of DHTML:
1. Lightweight and Interpreted: JavaScript is easy to learn and runs in the browser
without needing compilation.
2. Dynamic Typing: Variables in JavaScript are not bound to any specific type, meaning
their types can change during execution.
3. Prototype-based Object Orientation: JavaScript uses prototypes rather than classes
for inheritance, giving it unique object-oriented capabilities.
4. Event-driven and Asynchronous: JavaScript can handle events and perform tasks
asynchronously, making it well-suited for web interactions.
5. Cross-platform: JavaScript can run in various environments, from web browsers to
servers (via Node.js), desktop apps, and more.
• DOM Manipulation: JavaScript interacts with the HTML DOM to update, remove, or
add elements in real time.
• Form Validation: Before sending data to the server, JavaScript can validate user
inputs (like email, passwords, etc.).
• Asynchronous Programming (AJAX): JavaScript can fetch data from a server without
needing to reload the page.
• Animations and Effects: JavaScript is used in conjunction with CSS to add transitions,
animations, and effects.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Example</title>
<script>
function showMessage() {
alert("Hello, JavaScript!");
}
</script>
</head>
<body>
<button onclick="showMessage()">Click Me</button>
In JavaScript, when we talk about "documents," we’re typically referring to the Document
Object Model (DOM), which is the programming interface for web documents. The DOM
represents the structure of a webpage as a tree of objects, where each part of the
document (like elements, attributes, and text) is a node.
JavaScript interacts with the DOM to modify the structure, style, and content of a webpage
dynamically. Here are key concepts and methods related to working with documents in
JavaScript.
Here are some essential methods for interacting with the DOM:
• document.getElementById():
This method returns an element by its unique ID.
e.g.
• document.getElementsByClassName()
This method returns a live HTMLCollection of elements that match a specific class
name.
e.g.
var elements = document.getElementsByClassName("myClass");
elements[0].style.backgroundColor = "yellow";
• document.getElementsByTagName()
This method returns an HTMLCollection of elements with the given tag name.
e.g.
var paragraphs = document.getElementsByTagName("p");
paragraphs[0].innerHTML = "New content in the first paragraph.";
• document.querySelector()
This method returns the first element that matches a specified CSS selector.
• document.querySelectorAll()
This method returns all elements that match a specified CSS selector.
e.g.
var allDivs = document.querySelectorAll("div");
allDivs.forEach(div => div.style.color = "green");
Once you have accessed elements, you can modify their properties, content, or even their
structure.
You can modify the text inside an element using innerHTML or textContent.
e.g.
document.getElementById("myElement").innerHTML = "New text content!";
You can change the CSS styles of elements dynamically using the style property.
e.g.
document.getElementById("myElement").style.backgroundColor = "lightblue";
JavaScript allows you to add or remove CSS classes, which can alter the styling.
e.g.
document.getElementById("myElement").classList.add("newClass");
document.getElementById("myElement").classList.remove("oldClass");
You can also add or remove elements dynamically from the DOM.
e.g.
// Create a new element
// Remove an element
var elementToRemove = document.getElementById("myElement");
elementToRemove.remove();
Handling Events
JavaScript allows you to attach event listeners to elements to respond to user interactions,
such as clicks or key presses.
document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});
You can also attach events directly to HTML elements using attributes.
e.g.
e.g.
var parent = document.getElementById("parentElement");
var firstChild = parent.firstChild;
var childNodes = parent.children; // Returns all child elements
e.g.
var element = document.getElementById("myElement");
var parent = element.parentElement; // Access parent element
JavaScript makes form manipulation easy with methods to get and set form values.
e.g.
function validateForm() {
var input = document.getElementById("myInput").value;
if (input == "") {
alert("Input cannot be empty!");
return false;
}
return true;
}
e.g.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Example</title>
<style>
.highlight { background-color: yellow; }
</style>
</head>
<body>
<h1 id="title">Hello, JavaScript!</h1>
<button id="changeText">Change Text</button>
<button id="addClass">Highlight Text</button>
<script>
document.getElementById("changeText").addEventListener("click", function() {
document.getElementById("title").innerHTML = "Text Changed!";
document.getElementById("addClass").addEventListener("click", function() {
document.getElementById("title").classList.add("highlight");
});
</script>
</body>
</html>
Conclusion
The document in JavaScript represents the webpage and allows developers to interact with
it. By manipulating the DOM, developers can create dynamic and responsive user interfaces.
Whether you’re modifying text, handling user input, or altering styles, JavaScript is a
powerful tool for web development.
JavaScript
What is JavaScript?
Features of JavaScript
Variables
In JavaScript, variables are used to store and manipulate data. They allow you to label values
for later use. JavaScript provides three ways to declare variables: var, let, and const. Each has
different characteris@cs, and choosing the right one is important for wri@ng clear,
maintainable code.
Example:
Drawbacks:
• var has issues with hois.ng (variables declared with var are moved to the top of their
scope but ini@alized with undefined).
• The scope of var can some@mes lead to unexpected behavior, especially in loops or
when variables are redeclared.
Example:
let age = 30;
console.log(age); // 30
Benefits:
• Block scoping makes the variable's scope easier to manage and reduces errors.
• Unlike var, let avoids hois.ng issues and provides more predictable behavior.
Example:
const pi = 3.14;
console.log(pi); // 3.14
In JavaScript, a data type defines the kind of value that a variable can hold. JavaScript has a
set of built-in data types, which are used to store and manipulate values in a program. There
are two main categories of data types in JavaScript:
Example:
Example:
Example:
Example:
e. Undefined: Indicates a variable that has been declared but not assigned a value.
Example:
let x;
console.log(x); // undefined
Example:
let id = Symbol("uniqueID");
console.log(id); // Symbol(uniqueID)
Non-primitive types are objects, which are mutable and can store collections of values.
Example:
let person = {
name: "Alice",
age: 30
};
console.log(person.name); // "Alice"
Example:
Example:
func@on greet() {
console.log("Hello");
}
d. Date: Represents dates and @mes.
Example:
Dynamic Typing
JavaScript is dynamically typed, meaning variables can hold any data type.
Type Checking
Type Conversions
Explicit Conversion
In JavaScript, the term document typically refers to the Document Object Model (DOM),
which represents the structure of an HTML document as a tree of objects that can be
manipulated using JavaScript. The document object provides a way to access and interact
with the content and structure of a webpage, enabling you to dynamically change HTML
elements, CSS styles, and handle events.
Here are some of the most commonly used methods and properties of the document object
in JavaScript:
Event Handling
bu_on.removeEventListener("click", myFunc@on);
b. document..tle: Gets or sets the @tle of the document (shown in the browser's @tle bar or
tab).
Forms
In JavaScript, forms are a crucial part of web development. Forms are used to collect user
input, and JavaScript allows you to interact with forms to validate, submit, and manipulate
form elements. Here’s a guide to working with forms in JavaScript.
JavaScript:
You can access individual form elements (like text fields, checkboxes, etc.) by their name, id,
or querySelector.
a. Text Inputs
To get or set the value of a text input, you can use the .value property.
JavaScript
b. Checkboxes
JavaScript
c. Radio BuUons
Similar to checkboxes, radio buttons use the .checked property, but only one radio button in
a group can be selected at a time.
JavaScript
let selectedGender =
document.querySelector('input[name="gender"]:checked').value; // Get selected
value
document.getElementById("male").checked = true; // Set radio bu_on
For dropdowns (select elements), you use the .value property to get the selected option’s
value.
<select id="fruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
</select>
JavaScript
3. Form Validation
JavaScript is often used to validate form data before submission to ensure it meets specific
criteria (e.g., required fields, valid email format).
a. Basic Valida.on
You can check if a field is empty or meets a condition before submitting the form.
You can use regular expressions to validate inputs, such as email format.
if (!emailPa_ern.test(email)) {
alert("Please enter a valid email address.");
event.preventDefault();
}
a. Submigng a Form
You can submit a form either using the HTML <form> element’s submit() method or
manually via JavaScript.
<form id="myForm">
<input type="text" id="username" />
<input type="submit" />
</form>
document.getElementById("myForm").submit();
If you want to handle the form submission using JavaScript (e.g., for AJAX or custom
handling), prevent the default form submission.
You can reset a form’s fields to their default values using the .reset() method.
document.getElementById("myForm").reset();
The FormData object allows you to easily collect and send form data, especially for AJAX
requests.
You can send form data asynchronously (without reloading the page) using the fetch API.
fetch("/submit", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
console.log("Form submi_ed successfully", data);
})
.catch(error => {
console.log("Error:", error);
});
Func.on
In JavaScript, a function is a block of reusable code that performs a specific task. Functions
are a fundamental concept in JavaScript programming, enabling you to group logic, reuse it,
and keep your code modular and maintainable.
There are several ways to define a function in JavaScript. Here's an overview of the common
methods:
1. Function Declaration
func@on greet(name) {
console.log("Hello, " + name + "!");
}
Syntax:
2. Function Expression
A function expression involves creating a function and assigning it to a variable. The function
is anonymous, meaning it doesn't have a name, but you can still call it using the variable.
Syntax:
let func@onName = func@on(parameter1, parameter2, ...) {
// Code to be executed
};
Arrow functions provide a shorter syntax for writing functions. They are often used for
simple functions or callbacks. Arrow functions also do not bind their own this context (unlike
regular functions).
Syntax:
let func@onName = (parameter1, parameter2, ...) => {
// Code to be executed
};
An IIFE is a function that runs as soon as it is defined. It is often used to create a local scope
and avoid polluting the global namespace.
(func@on() {
console.log("This is an IIFE!");
})();
By: Mr. Amrit Jaiswal 58
Syntax:
(func@on() {
// Code to be executed
})();
a. Parameters
Functions can take zero or more parameters. You define the parameters in the function
declaration, and when calling the function, you pass the actual arguments.
func@on add(a, b) {
return a + b;
}
You can set default values for function parameters. If an argument is not passed for that
parameter, the default value is used.
c. Return Statement
The return statement is used to send a value back from the function. If no return statement
is used, the function returns undefined by default.
func@on mul@ply(a, b) {
return a * b;
}
JavaScript functions create their own local scope. Variables declared inside a function are
not accessible from outside the function. However, they can access variables from the outer
scope.
func@on showMessage() {
let localVar = "I'm local";
console.log(globalVar); // Can access global variable
console.log(localVar); // Can access local variable
}
showMessage();
// console.log(localVar); // Error: localVar is not defined
In regular functions, the value of this depends on how the function is called. In an object
method, this refers to the object itself.
let person = {
name: "Alice",
greet: function() {
console.log("Hello, " + this.name);
}
};
In arrow func@ons, this is lexically bound, meaning it inherits the value of this from its
surrounding context.
let person = {
name: "Bob",
greet: () => {
console.log("Hello, " + this.name); // `this` does not refer to `person`
}
};
A recursive function is a function that calls itself to solve a problem. It's important to include
a base case to prevent infinite recursion.
function factorial(n) {
if (n === 0) return 1; // Base case
return n * factorial(n - 1); // Recursive case
}
Objects
In JavaScript, objects are a fundamental data structure used to store collec@ons of key-value
pairs. They are highly versa@le and form the backbone of JavaScript programming, enabling
you to represent real-world en@@es, store data, and define behavior through methods.
1. Defining an Object
a. Object Literal: The most common way to create an object is using curly braces {}.
let person = {
name: "Alice",
age: 25,
greet: func@on() {
console.log("Hello, my name is " + this.name);
}
};
// Accessing proper@es
console.log(person.name); // Output: Alice
console.log(person.age); // Output: 25
// Calling a method
person.greet(); // Output: Hello, my name is Alice
b. Object Constructor
The Object.create() method allows you to create a new object with a specified prototype
object.
let prototypePerson = {
greet: func@on() {
console.log("Hello!");
}
};
a. Dot Nota.on
b. Bracket Nota@on
Bracket notation allows you to use dynamic keys or keys with special characters.
a. Adding Proper.es
b. Modifying Proper.es
person.age = 26;
console.log(person.age); // Output: 26
delete person.address;
console.log(person.address); // Output: undefined
Introduc.on to AJAX
AJAX (Asynchronous JavaScript and XML) is a web development technique used to create
dynamic and interactive web applications. It allows web pages to update content
dynamically without requiring a full reload of the page. This leads to faster and more user-
friendly web experiences.
Features of AJAX:
1. Asynchronous Updates: AJAX can send and receive data asynchronously in the
background while the user interacts with the page.
2. Par.al Page Updates: Instead of reloading the en@re page, only specific parts of a
webpage are updated.
3. Independent Communica.on: It communicates with the server independently of the
page load process.
4. Cross-Technology: Although its name includes "XML," AJAX can handle various data
formats like JSON, HTML, and plain text.
1. User Interac.on: The user interacts with the webpage (e.g., clicking a bu_on).
2. JavaScript Execu.on: JavaScript makes an asynchronous HTTP request to the server
using the XMLH_pRequestobject or the newer fetch API.
3. Server Response: The server processes the request and sends back data (in formats
like JSON, XML, or plain text).
4. DOM Update: JavaScript processes the response and updates the DOM to reflect the
new data without reloading the page.
Benefits of AJAX:
A simpler and modern way to make AJAX calls is using the fetch API:
// Fetch example
fetch("/example")
.then(response => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.text();
})
.then(data => {
// Update the content of a page element
document.getElementById("output").innerHTML = data;
})
.catch(error => console.error("Fetch error:", error));
VB Script
Syntax Basics
Dim myVariable
myVariable = "Hello, VBScript!"
Dim age
age = 20
Loops: VBScript supports various loops like For, While, and Do Un@l.
Dim i
For i = 1 To 5
MsgBox "Itera@on: " & i
Next
Func.ons: You can create custom func@ons using the Func@on keyword.
Func@on AddNumbers(a, b)
AddNumbers = a + b
End Func@on
VBScript can be embedded in HTML pages (though only supported in old versions of
Internet Explorer).
Limita.ons of VBScript
Server-side programming involves wri@ng code that runs on the server to manage the back-
end opera@ons of a web applica@on. It focuses on tasks like processing user inputs,
interac@ng with databases, authen@ca@ng users, and delivering dynamic content to the
client's browser.
Active Server Pages (ASP) is a server-side scripting technology developed by Microsoft, used
to create dynamic and interactive web pages. Introduced in the late 1990s, ASP allows
developers to embed server-side scripts (usually written in VBScript or JScript) into HTML
pages, enabling functionalities like accessing databases, handling user inputs, and delivering
personalized content.
Features of ASP:
1. Server-Side Execu.on: ASP code is executed on the server before the HTML is sent to
the client.
2. Dynamic Content: It enables dynamic genera@on of web content based on user
interac@ons or database queries.
3. Interoperability: Works well with databases like MicrosoI Access, SQL Server, and
other ODBC-compliant databases.
4. Integra.on with IIS: ASP is @ghtly integrated with Internet Informa@on Services (IIS),
MicrosoI's web server.
1. Client Request: The user’s browser sends a request for an ASP file to the server.
2. Server Processing: The IIS server processes the ASP file, executes the embedded
scripts, and generates HTML.
3. Response: The server sends the dynamically generated HTML back to the client,
which is displayed in the browser.
Benefits of ASP:
1. Dynamic Web Applica.ons: Makes it easy to create dynamic and interac@ve web
pages.
2. Integra.on with Microsol Technologies: Works seamlessly with MicrosoI databases
and tools.
3. Ease of Learning: Familiarity with VBScript or JavaScript makes ASP easy to learn for
beginners.
Limita.ons of ASP:
JavaServer Pages (JSP) is a server-side technology developed by Sun Microsystems (now part
of Oracle) as part of the Java EE platform. JSP enables the creation of dynamic, platform-
independent web content by combining HTML, XML, and Java code. It simplifies the
development of web applications by embedding Java code into HTML pages, allowing the
generation of dynamic content based on user interactions or backend data.
Features of JSP:
1. Dynamic Content Genera.on: JSP enables the crea@on of web pages with dynamic
content.
2. Java-Based: Leverages the Java programming language for flexibility and robustness.
3. PlaTorm Independence: Runs on any server that supports a Java Virtual Machine
(JVM).
4. Separa.on of Concerns: Encourages the separa@on of presenta@on (HTML) and logic
(Java) using frameworks like MVC.
5. Reusable Components: Facilitates the reuse of JavaBeans and custom tags in JSP
files.
1. Client Request: The browser sends a request for a JSP file to the server.
2. JSP Processing:
o The server translates the JSP file into a servlet (a Java class).
o The servlet is compiled into bytecode and executed on the server.
3. Response: The server generates an HTML response based on the processed JSP and
sends it to the client.
A JSP file is a mix of HTML and Java code, with special tags for embedding Java:
Advantages of JSP:
JSP Lifecycle:
In web applications, sharing data between different JSP pages is a common requirement. JSP
provides several mechanisms for transferring data, depending on the scope and the use
case. Below are the most commonly used techniques for sharing data between JSP pages:
• Query Parameters
• Form Submission
• Request Attributes
• Session Attributes
• Application Attributes
• Cookies