internet and web technology^
internet and web technology^
The Internet is a global network of interconnected computers that allows for communication, data
sharing, and access to services like websites, email, file sharing, and more. It is a system that links
millions of private, public, academic, business, and government networks worldwide using standard
protocols.
• Interconnected Network: The internet is composed of millions of smaller networks that are
interconnected via various technologies.
• Protocols: The internet uses standardized protocols to allow data to be transmitted across
different devices, such as Transmission Control Protocol (TCP) and Internet Protocol (IP).
• Accessibility: The internet is accessible through wired and wireless technologies, including
fiber optics, 4G/5G, Wi-Fi, and satellite communication.
• Services: The internet provides a variety of services like email, file sharing, online banking, e-
commerce, video conferencing, and more.
• Internet Backbone: High-capacity data routes that connect different regions and countries.
Large data centers and internet service providers (ISPs) operate these backbones.
The World Wide Web (WWW) is a system of interlinked hypertext documents and multimedia
content, accessed through the Internet using web browsers (like Chrome, Firefox, etc.). It allows
users to view websites, access applications, and interact with resources using web pages.
• Web Pages: Web pages are the core components of the WWW. They contain text, images,
videos, and hyperlinks (links to other pages or websites).
• URLs (Uniform Resource Locators): A URL is the web address used to locate resources on the
WWW (e.g., https://www.example.com).
• Web Browsers: Software applications (such as Chrome, Firefox, Safari, Edge) that allow users
to navigate the WWW by requesting and displaying web pages.
• HTML (Hypertext Markup Language): The standard language used to create and structure
web pages. It defines the structure of text, images, links, and multimedia.
• HTTP/HTTPS (Hypertext Transfer Protocol): Protocols used to request and transfer web
pages and resources over the Internet. HTTPS (secure) ensures encrypted communication
between the client (browser) and the server.
3. Difference Between the Internet and the World Wide Web (WWW)
Although often used interchangeably, the Internet and the World Wide Web are distinct concepts:
Feature Internet World Wide Web (WWW)
Encompasses all forms of communication and Primarily used for accessing websites
Scope
services (e.g., email, file transfer). and browsing information.
Provides infrastructure for services like email, Provides access to web pages,
Services
FTP, and social media. multimedia, and online applications.
• Client: The device or application (e.g., a computer, smartphone, web browser) that requests
information or services.
• Server: The computer or system that hosts and provides the requested data or services.
Key Components:
• IP Address: Every device connected to the internet is assigned a unique IP address (e.g.,
192.168.1.1).
• DNS (Domain Name System): DNS translates human-readable domain names (e.g.,
www.example.com) into IP addresses that computers can understand.
• Routers: Devices that direct data packets to their destinations across the network.
• Web Servers: These host websites and handle requests from clients (browsers) for specific
web pages or resources.
• Data Transmission: Information is broken down into smaller packets and sent across various
paths, where routers forward them to the correct destination. At the destination, the packets
are reassembled into the original content.
• Pre-Internet Era: Before the internet, computer networks like ARPANET were used for
research and communication, but there was no global connectivity.
• Creation of the WWW: In 1989, Tim Berners-Lee developed the concept of the World Wide
Web to enable researchers to share documents and data easily. The first website was
launched in 1991 at CERN (European Organization for Nuclear Research).
• Commercialization: In the mid-1990s, the internet became widely available to the public,
and commercial services like AOL, Yahoo, and Amazon started to emerge.
• Web 2.0: In the early 2000s, the web evolved with the advent of more interactive features,
social media, and dynamic content.
• Web 3.0: The future of the web, where semantic web technologies (data-driven, AI-based
web applications) and decentralized systems like blockchain are expected to play a large
role.
• HTML (Hypertext Markup Language): The foundation for web page structure and content.
HTML uses tags to define elements like headings, paragraphs, images, and links.
• CSS (Cascading Style Sheets): Defines the appearance and layout of a webpage (colors, fonts,
spacing).
• JavaScript: A programming language that allows interactive features on websites (e.g., form
validation, dynamic content updates).
• Web Servers: Software that hosts websites and delivers web pages in response to client
requests (e.g., Apache, Nginx).
• Databases: Store and manage data for dynamic websites (e.g., MySQL, MongoDB).
The WWW has enabled a vast range of services and applications that have revolutionized
communication, commerce, entertainment, and information sharing:
• E-commerce: Websites like Amazon, eBay, and Shopify allow for online shopping,
transactions, and digital goods delivery.
• Social Media: Platforms like Facebook, Twitter, and Instagram allow people to connect, share
content, and engage in real-time communication.
• Cloud Computing: Services like Google Drive, Dropbox, and AWS provide cloud storage, file
sharing, and computing resources.
• Streaming Services: Platforms like YouTube, Netflix, and Spotify allow users to stream videos
and music.
• Online Education: E-learning platforms like Coursera, Khan Academy, and edX offer online
courses and learning materials.
Protocols TCP/IP for data transmission. HTTP/HTTPS for accessing web pages.
For a wide variety of activities Mainly for accessing websites and web-
Usage
(communication, file transfer). based services.
HTTP Protocol: Request and Response, Web Browsers, and Web Servers
The HTTP (Hypertext Transfer Protocol) is a foundational protocol used to transfer data over the web.
It facilitates communication between web clients (browsers) and web servers by defining how
requests and responses should be structured and handled.
HTTP is a stateless, application-layer protocol in the OSI model that defines how messages are
formatted and transmitted, and how web servers and browsers respond to various commands.
• Stateless means that each HTTP request is independent; the server doesn't retain
information from previous requests. However, mechanisms like cookies and sessions can be
used to maintain state across multiple requests.
HTTP Request
When a user requests a web page, the web browser (client) sends an HTTP request to the web
server. An HTTP request consists of the following components:
1. Request Line:
o URL (Uniform Resource Locator): The path to the resource (e.g., /index.html or
/products/123).
o HTTP Version: The version of HTTP being used (e.g., HTTP/1.1, HTTP/2).
Copy code
2. Headers: These provide additional information about the request, such as the browser type,
language preference, and connection settings.
o Accept: Specifies the media types that the client can handle (e.g., text/html,
image/jpeg).
Example headers:
bash
Copy code
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/91.0.4472.124 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Host: www.example.com
3. Body: For methods like POST or PUT, the body of the request may contain data sent to the
server, such as form data or JSON.
makefile
Copy code
username=johndoe&password=12345
HTTP Response
After receiving an HTTP request, the server processes the request and sends an HTTP response back
to the client. The HTTP response consists of:
1. Status Line:
o Status Code: A three-digit number indicating the status of the request (e.g., 200 OK,
404 Not Found, 500 Internal Server Error).
Copy code
HTTP/1.1 200 OK
2. Headers: These contain metadata about the response, such as the content type, length, and
server information.
Example headers:
yaml
Copy code
Content-Length: 1234
3. Body: The body of the response contains the requested data (e.g., the HTML content of a
webpage, an image, or JSON data). This is the actual content that the client (browser) will
render or use.
html
Copy code
<html>
<head><title>Example Page</title></head>
</html>
• 200 OK: The request was successful, and the server responded with the requested data.
• 301 Moved Permanently: The resource has been permanently moved to a new URL.
• 400 Bad Request: The server could not understand the request due to invalid syntax.
• 404 Not Found: The requested resource could not be found on the server.
• 500 Internal Server Error: The server encountered an error while processing the request.
2. Web Browsers
A web browser is a software application that allows users to access, retrieve, and view content from
the World Wide Web. Web browsers send HTTP requests to web servers to fetch resources, then
render and display those resources to the user.
Common Web Browsers:
• Google Chrome
• Mozilla Firefox
• Safari
• Microsoft Edge
• Opera
2. DNS Resolution: The browser resolves the domain name into an IP address using DNS.
3. HTTP Request: The browser sends an HTTP request to the server for the requested resource
(e.g., a webpage).
4. Response Handling: The browser receives the HTTP response from the server.
5. Rendering: The browser renders the content, whether it's HTML, CSS, JavaScript, or
multimedia, and displays it to the user.
Browser Components:
• Rendering Engine: Renders web pages (e.g., Blink for Chrome, Gecko for Firefox).
• UI (User Interface): The elements that users interact with (address bar, back button, etc.).
• Data Storage: For storing cookies, cached data, and local storage.
3. Web Servers
A web server is a software or hardware system that serves content to clients (browsers) over the
internet using HTTP or HTTPS. The web server listens for incoming requests, processes them, and
sends appropriate responses.
1. Incoming Request: The server receives an HTTP request from a client (web browser).
2. Request Processing: The server processes the request, which may involve retrieving files
from the file system or interacting with a database.
3. Response: The server sends an HTTP response with the requested data (e.g., HTML content,
images, or JSON) back to the client.
4. Logging: The web server often logs details about the request, such as the client's IP address,
the request time, and the resource requested.
Common Web Servers:
• Apache HTTP Server: One of the most popular open-source web servers.
• Microsoft IIS (Internet Information Services): A web server developed by Microsoft for
Windows servers.
• LiteSpeed: A web server that offers improved performance and security features.
• Virtual Hosts: Allows a single server to host multiple websites by differentiating requests
based on domain names.
• Server-Side Scripting: Web servers may integrate with scripting languages like PHP, Python,
or Node.js to dynamically generate content.
POST Sends data to the server to be processed. Submitting form data or uploading files.
Similar to GET, but without the body in the Checking metadata or verifying
HEAD
response. resource existence.
PATCH Partially updates a resource on the server. Modifying a specific part of a resource.
Describes the communication options for the Checking available methods for a
OPTIONS
target resource. resource.
Summary
Concept Description
HTTP A message sent by the client to the server, including the method, URL, headers, and
Request possibly a body.
Concept Description
HTTP The server's reply to a client request, including a status line, headers, and body (the
Response requested content).
A software tool that allows users to browse and interact with web pages, sending
Web Browser
HTTP requests and rendering responses.
A system that processes incoming requests from clients and responds with the
Web Server
requested data or content.
Web 2.0 refers to the transition from static web pages (Web 1.0) to dynamic, user-interactive
websites that allow for a richer and more engaging user experience. Web 2.0 emphasizes user-
generated content, usability, and collaboration. Web design principles have evolved to reflect these
ideas, focusing on a balance between aesthetic appeal, functionality, and user engagement.
Effective web design combines visual appeal with functionality, ensuring users can easily navigate
and interact with the website. Here are some core concepts of effective web design:
• User-Centric Approach: Focus on designing websites with the user’s needs and experience in
mind. Ensure easy navigation, intuitive interfaces, and clear messaging.
• Visual Hierarchy: Prioritize elements based on importance and use size, color, and
positioning to guide users’ attention.
• Accessibility: Design with accessibility in mind, ensuring the site is usable for all individuals,
including those with disabilities (e.g., color contrast, alt text for images).
• Consistency: Maintain a consistent layout, color scheme, and font style across pages to
provide a cohesive experience.
• Responsiveness: Ensure the website is adaptable to different screen sizes and devices
(desktop, tablet, mobile), often using responsive web design (RWD).
Several challenges can affect the effectiveness of web design. Some common issues include:
Browser Compatibility
• Websites should be compatible with different web browsers (e.g., Chrome, Firefox, Safari,
Edge). Each browser may render pages slightly differently, so testing and ensuring
compatibility across major browsers is crucial.
• Solution: Use web standards (HTML5, CSS3) and browser prefixes. Tools like
CrossBrowserTesting or BrowserStack can help test across various browsers.
Bandwidth
• Bandwidth refers to the data transfer rate and is crucial for website loading times. High-
resolution images, videos, and complex animations can slow down the website.
• Solution: Optimize images, use efficient coding, and reduce unnecessary elements.
Implement lazy loading to load images only when they are about to appear in the viewport.
Cache
• Caching improves load times by storing previously visited website data locally on a user’s
device. However, improper cache settings can result in outdated content being displayed.
• Solution: Use cache-control headers to manage the storage of web resources and ensure
that users always receive up-to-date content.
Display Resolution
• With different screen resolutions and device sizes, ensuring that websites are readable and
visually appealing across all displays is essential.
• Solution: Design using fluid layouts that adapt to various screen sizes, and ensure all text
and images scale properly.
The look and feel of a website refers to its visual appearance and the overall user experience. This
includes:
• Color Scheme: Choose colors that align with the brand, are easy on the eyes, and provide
good contrast for readability.
• Typography: Use legible fonts and appropriate sizes for headings, body text, and navigation.
Stick to a limited number of fonts.
• Imagery: Use high-quality images that align with the website’s content. Images should be
optimized for web use to balance quality and performance.
• Whitespace: Adequate use of whitespace (or negative space) makes the site look clean and
organized, improving usability by reducing visual clutter.
Page Layout
The layout of a webpage refers to how the elements on the page are organized. Common layout
structures include:
• Grid Layout: Aligns content in rows and columns, making it easier to maintain visual
consistency.
• F-Layout: Users tend to scan pages in an "F" shape, so key content should be placed in the
top left and along the left side.
• Z-Layout: Another common scanning pattern where users read in a "Z" shape.
The goal is to ensure the layout is both user-friendly and aesthetically pleasing.
Linking
Links connect various pages and resources within a website or to external websites. Key design
principles for linking include:
• Clear and Descriptive Links: Link text should clearly describe the destination, and users
should easily recognize it as clickable.
• Internal vs. External Links: Organize internal links logically, and ensure external links open in
new tabs (to avoid disrupting the user’s navigation).
5. User-Centric Design
User-centric design focuses on making websites easy to use, intuitive, and designed around the
users' needs and goals. Key principles include:
• Intuitive Navigation: Ensure that users can easily find what they are looking for without
unnecessary steps. Use familiar terms and simple menus.
• Feedback: Provide users with feedback when they interact with the website (e.g., loading
animations, hover effects, form validation).
• User Testing: Regularly conduct usability testing to ensure the site meets users’ needs and
provides a smooth experience.
6. Sitemap
A sitemap is a visual or written representation of a website's structure, showing how pages are
linked together. It serves as both:
• A Planning Tool: Helps web designers and developers organize content before starting the
design.
• A Navigation Aid: A sitemap helps both users and search engines understand the hierarchy
and navigation paths.
Types of Sitemaps:
• XML Sitemap: Designed for search engines, listing all URLs on the website for better
indexing.
Planning a Website:
Effective planning helps ensure the website meets its goals, user needs, and business objectives. The
steps involved in planning include:
1. Define Purpose and Goals: Understand what the website aims to achieve (e.g.,
informational, e-commerce, community).
2. Identify Target Audience: Tailor design and content to the audience's needs, behaviors, and
technical proficiency.
3. Content Strategy: Decide what content will be included and how it will be organized.
4. Wireframes and Mockups: Create wireframes to outline the layout and design of key pages
before development begins.
5. SEO Planning: Plan for search engine optimization (SEO) by incorporating keywords and
ensuring proper HTML tags are used.
Publishing a Website:
• Hosting: Choose a hosting provider and upload the website files to the server.
• Domain: Register a domain name that aligns with the website’s brand or purpose.
• Launch: Test the website thoroughly (on different browsers, devices, etc.) before going live.
Good navigation design helps users find information quickly and easily. Key elements of effective
navigation design include:
• Clear Menu Structure: Ensure the main navigation menu is easy to find and contains logical
categories.
• Breadcrumbs: Use breadcrumbs to show users their current location within the website
structure and allow easy navigation back to previous pages.
• Search Functionality: Provide a search bar that is easily accessible, allowing users to search
for content directly.
• Sticky Navigation: For long pages, sticky menus (that stay visible when scrolling) can improve
the user experience by keeping key links always accessible.
Summary
Feature Description
User-Centric Focus on creating a website that is intuitive, easy to navigate, and meets user
Design needs.
The visual design elements, such as color, typography, imagery, and layout, that
Look and Feel
affect user experience.
Feature Description
Responsive
Ensure the website works across all screen sizes (desktops, tablets, and mobiles).
Design
Page Layout Organize content in a clear, visually appealing structure (grid, F-layout, Z-layout).
Create a logical, easy-to-use menu and linking system for users to find
Navigation
information.
Planning Outline purpose, goals, and content strategy before beginning the design.
Sitemap A visual representation of the website’s structure, guiding design and navigation.
Effective web design is about combining aesthetics with usability, focusing on the user’s experience
while achieving business goals.
Unit------2
HTML (HyperText Markup Language) is the standard language used to create web pages. It defines
the structure and layout of a web document by using a system of tags. In this unit, we’ll cover the
basics of HTML and its essential components, including formatting, hyperlinks, forms, and advanced
topics like XHTML, HTML5, and browser architecture.
1. Basics of HTML
HTML documents are made up of elements or tags that define the structure of the page. Tags are
enclosed in angle brackets, such as <tagname>. Some commonly used HTML tags include:
• <head>: Contains metadata, links to stylesheets, scripts, and other non-visible elements.
• <body>: Contains the visible content of the page (text, images, links).
• <h1>, <h2>, etc.: Heading tags, with <h1> being the largest and most important.
• <ul>, <ol>, <li>: Tags for creating unordered (bulleted) and ordered (numbered) lists.
• <div>: Defines a section or division of a document (commonly used with CSS for styling).
o Example:
html
Copy code
html
Copy code
<style>
p{
font-size: 14px;
color: #333;
</style>
3. Commenting Code
Comments are used in HTML to annotate code or leave notes for developers. They are not displayed
in the browser.
• Comment Syntax:
html
Copy code
4. Color
HTML supports adding color to text, backgrounds, and elements using color names, hexadecimal
values, or RGB values.
• Text Color:
html
Copy code
• Background Color:
html
Copy code
</body>
5. Hyperlinks
Hyperlinks (or links) are used to navigate between pages or sections of a page.
• Basic Link:
html
Copy code
html
Copy code
Copy code
6. Lists
html
Copy code
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
html
Copy code
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
• Definition List:
html
Copy code
<dl>
<dt>Term</dt>
</dl>
7. Tables
HTML tables are used to display data in a tabular format. Tables consist of rows (<tr>) and columns
(<td>).
html
Copy code
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
• Table Elements:
8. Images
Images are added to HTML using the <img> tag, which is self-closing.
html
Copy code
• Attributes:
• Example:
html
Copy code
9. Forms
HTML forms are used to collect input from users. Forms can include text fields, buttons, checkboxes,
and other interactive elements.
html
Copy code
<label for="name">Name:</label>
</form>
• Form Elements:
o <input>: Accepts user input. Types include text, password, checkbox, radio, etc.
• Key Differences:
• Example:
html
Copy code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XHTML Example</title>
</head>
<body>
<h1>Welcome to XHTML</h1>
</body>
</html>
Meta tags provide metadata about the webpage, such as the character set, author, keywords, and
description.
html
Copy code
<meta name="keywords" content="HTML, web design, tutorial"> <!-- Keywords for SEO -->
Character entities allow you to display special characters that might otherwise conflict with HTML
syntax.
• Frameset Example:
html
Copy code
<frame src="page1.html">
<frame src="page2.html">
</frameset>
• Browser Architecture:
o Client-Server Model: The browser (client) sends requests to a server for resources
(HTML, images, CSS, etc.).
• Website Structure:
HTML5 is the latest version of HTML, designed to support modern web applications, multimedia
content, and better performance.
• New Elements: <header>, <footer>, <article>, <section>, <nav>, <aside>, etc., provide better
structure and semantics.
• Multimedia: Native support for audio and video tags (<audio>, <video>), reducing reliance
on plugins like Flash.
• Form Controls: New input types (email, date, range, etc.) for better data collection.
• Offline Capabilities: Support for offline storage through the localStorage and sessionStorage
APIs.
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a
document written in HTML or XML. It allows developers to control the layout and design of web
pages, making them more attractive and user-friendly.
CSS is necessary for separating the structure (HTML) of a web page from its presentation (design and
layout). The reasons for using CSS are:
• Separation of Concerns: HTML defines the content, and CSS defines the appearance. This
makes maintenance easier.
• Consistency: CSS allows you to apply the same styles across multiple pages or elements
without repeating code.
• Flexibility: CSS offers flexibility in design and layout, providing responsive, adaptive, and
visually appealing websites.
• Faster Load Times: By keeping styling separate from HTML, CSS can be cached by the
browser, speeding up page load times.
2. Introduction to CSS
CSS enables the styling of elements like text, layout, and colors. It can be applied in three ways:
1. Inline CSS: Styles are applied directly to an HTML element using the style attribute.
html
Copy code
2. Internal CSS: Styles are placed inside the <style> tag in the <head> section of the HTML
document.
html
Copy code
<style>
p{
color: blue;
</style>
3. External CSS: Styles are written in an external .css file and linked to the HTML document.
html
Copy code
• Declaration Block: Contains one or more property-value pairs enclosed in curly braces {}.
o Property: Defines the style you want to apply (e.g., color, font-size).
Example:
css
Copy code
selector {
property: value;
html
Copy code
<style>
p{
color: green;
font-size: 14px;
</style>
To use CSS, you can either write the styles directly within the HTML file (internal) or link to an
external CSS file.
• External CSS:
html
Copy code
css
Copy code
body {
background-color: lightblue;
p{
color: darkblue;
font-size: 16px;
CSS allows you to set background colors and images for HTML elements:
• Background Color:
css
Copy code
body {
background-color: lightgray;
• Background Image:
css
Copy code
body {
background-image: url('background.jpg');
• Background Properties:
6. Manipulating Texts
CSS provides various properties to control the appearance of text, such as font, size, color, spacing,
and alignment:
• Font Properties:
css
Copy code
p{
font-size: 16px;
font-weight: bold;
• Text Properties:
7. Using Fonts
• Font Family:
css
Copy code
body {
font-family: 'Times New Roman', Times, serif;
css
Copy code
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
body {
CSS allows you to add borders, padding, and margins around elements:
• Borders:
css
Copy code
div {
• Padding: Adds space inside the element, between its content and border.
css
Copy code
div {
padding: 10px;
• Margin: Adds space outside the element, between it and other elements.
css
Copy code
div {
margin: 20px;
}
• Box Model: The total width and height of an element include its content, padding, border,
and margin. CSS provides control over these elements for precise layout design.
CSS positioning allows you to control the placement of elements on the page:
• Static Positioning (default): Elements are positioned according to the normal document flow.
css
Copy code
div {
position: static;
css
Copy code
div {
position: relative;
• Absolute Positioning: Elements are positioned relative to the nearest positioned ancestor.
css
Copy code
div {
position: absolute;
top: 50px; /* Moves the element 50px from the top of the parent */
left: 100px;
• Fixed Positioning: Elements are fixed relative to the browser window, staying in place even
when scrolling.
css
Copy code
div {
position: fixed;
bottom: 10px;
right: 10px;
• Sticky Positioning: Elements "stick" to the screen when scrolling until a defined threshold.
css
Copy code
div {
position: sticky;
10. CSS2
CSS2 (Cascading Style Sheets Level 2) is a version of CSS that added many new features, including:
• Media Types: Allows the styling of elements based on the media type (screen, print,
handheld devices).
css
Copy code
@media screen {
body {
font-size: 16px;
css
Copy code
div {
position: absolute;
}
• Selectors: More advanced selectors like attribute selectors, pseudo-classes, and pseudo-
elements were introduced.
CSS3 is the latest version of CSS and introduces a range of new features and capabilities, expanding
upon the previous versions of CSS. It provides more powerful tools for styling and visual effects,
helping developers design modern and interactive websites.
1. Selectors:
o New selectors such as nth-child(), nth-of-type(), not(), and last-child() allow more
control over the selection of HTML elements.
css
Copy code
div {
border-radius: 10px;
css
Copy code
div {
css
Copy code
p{
3. Backgrounds:
o Multiple Backgrounds: You can use multiple background images for a single
element.
css
Copy code
body {
css
Copy code
body {
css
Copy code
div {
div:hover {
background-color: red;
css
Copy code
@keyframes slide {
to { left: 100px; }
div {
css
Copy code
.container {
display: flex;
justify-content: center;
o Grid Layout: A 2-dimensional layout system that allows you to create complex web
layouts.
css
Copy code
.grid-container {
display: grid;
6. Media Queries:
o Media queries allow responsive designs by applying styles based on different device
characteristics (e.g., screen size).
css
Copy code
body {
font-size: 14px;
7. Web Fonts:
o @font-face and Web Fonts (such as Google Fonts) enable the use of custom fonts on
web pages.
css
Copy code
@font-face {
font-family: 'CustomFont';
src: url('customfont.woff');
body {
JavaScript is a versatile and powerful programming language used to create interactive effects within
web browsers. It runs on the client side, which means it executes in the user's web browser rather
than on the server.
1. Variables:
javascript
Copy code
2. Functions:
javascript
Copy code
function greet(name) {
greet("Alice");
3. Conditions (if-else):
javascript
Copy code
let age = 18;
} else {
javascript
Copy code
javascript
Copy code
let i = 0;
while (i < 5) {
i++;
javascript
Copy code
numbers.forEach(function(num) {
console.log(num);
});
5. Pop-up Boxes:
o JavaScript provides built-in methods to create pop-up boxes for interaction with the
user.
o Alert Box: Displays a simple message.
javascript
Copy code
o Confirm Box: Displays a message and asks the user to confirm or cancel.
javascript
Copy code
if (result) {
} else {
javascript
Copy code
6. Events:
o JavaScript allows handling of events such as clicks, mouse movements, and keyboard
inputs.
javascript
Copy code
document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});
7. DOM Manipulation:
o JavaScript allows you to interact with the HTML structure of a page (Document
Object Model).
o You can change content, styles, and even add new elements dynamically.
javascript
Copy code
document.getElementById("myDiv").innerHTML = "New content!";
document.getElementById("myDiv").style.backgroundColor = "blue";
These concepts form the foundation of using CSS3 for styling and JavaScript for adding interactivity
to web pages, creating dynamic, responsive, and user-friendly websites
JavaScript is an object-oriented programming language, which means it uses objects to store and
manipulate data. Objects are collections of properties and methods that define behaviors and
attributes.
An object in JavaScript is a collection of key-value pairs. Each pair consists of a key (also called a
property) and a value. The value can be any type of data, including numbers, strings, arrays, or even
other objects.
Creating Objects
javascript
Copy code
let person = {
name: "Alice",
age: 25,
greet: function() {
};
javascript
Copy code
person.name = "Bob";
person.age = 30;
person.greet = function() {
};
• Dot Notation:
javascript
Copy code
• Bracket Notation:
javascript
Copy code
javascript
Copy code
person.age = 35;
person.name = "Charlie";
JavaScript provides several built-in objects, such as String, Array, Date, Math, and others. These
objects have predefined properties and methods.
• String Object:
javascript
Copy code
console.log(str.length); // Output: 11
console.log(str.toUpperCase()); // Output: HELLO WORLD
• Array Object:
javascript
Copy code
console.log(numbers.length); // Output: 5
• Date Object:
javascript
Copy code
• Math Object:
javascript
Copy code
You can create your own custom objects to store and organize data that your program uses.
The DOM (Document Object Model) represents the structure of an HTML document as a tree of
objects. JavaScript interacts with the DOM to manipulate HTML elements and create dynamic,
interactive web pages.
In the web browser environment, JavaScript runs and communicates with the browser's DOM to
modify the content and structure of a web page.
Browser Environment
• Window Object: Represents the entire browser window and provides access to browser
properties like alert, confirm, and prompt.
• Document Object: Represents the HTML or XML document loaded in the browser. It
provides access to elements like paragraphs, divs, forms, etc.
4. Manipulation Using the DOM
JavaScript provides powerful tools for manipulating the DOM, allowing you to interact with and
modify the structure and content of web pages.
• By ID: document.getElementById("id")
javascript
Copy code
javascript
Copy code
javascript
Copy code
javascript
Copy code
Once you have access to an element, you can modify its properties, style, or content.
javascript
Copy code
javascript
Copy code
• Changing Styles:
javascript
Copy code
javascript
Copy code
Forms are essential for collecting user input, and JavaScript allows you to validate that input before
sending it to the server.
JavaScript can be used to validate form fields for required input, correct data formats, and more.
javascript
Copy code
function validateForm() {
if (name == "") {
• Email Validation:
javascript
Copy code
function validateEmail() {
if (!regex.test(email)) {
return false;
html
Copy code
</form>
• Password Confirmation:
javascript
Copy code
function validatePassword() {
return false;
}
You can apply JavaScript validations on form submissions to ensure that data entered by the user is in
the correct format and meets the necessary requirements.
By combining JavaScript, DOM manipulation, and form validation, you can create interactive,
dynamic, and user-friendly web pages that provide real-time feedback to users
DHTML (Dynamic HTML) is not a new language, but a combination of HTML, CSS, and JavaScript that
allows for the creation of interactive, dynamic web pages. Using these three technologies together
enables developers to modify a webpage's content, structure, and style without requiring a page
reload.
In essence, DHTML enhances web pages by adding dynamic features that respond to user actions in
real-time.
3. JavaScript enables interactivity by controlling both HTML elements and CSS properties.
Together, these technologies allow you to create pages where content can be changed dynamically
based on user actions such as clicks, mouse movements, or key presses.
1. HTML (Structure):
o The markup defines the elements of the web page, such as divs, paragraphs,
buttons, etc.
o Example:
html
Copy code
2. CSS (Styling):
o You can dynamically change styles (like color, size, position) using JavaScript.
o Example:
css
Copy code
#content {
font-size: 20px;
color: blue;
#content:hover {
color: red;
3. JavaScript (Behavior):
o JavaScript is used to handle events (like clicks, mouseovers, etc.) and modify HTML
and CSS dynamically.
o Example:
javascript
Copy code
document.getElementById("changeTextButton").onclick = function() {
};
Events are actions or occurrences that happen in the browser window, such as when the user clicks a
button, moves the mouse, or presses a key. JavaScript handles these events and allows you to modify
HTML elements dynamically in response.
You can attach event listeners to HTML elements (like buttons) using JavaScript. When an event
occurs, the corresponding JavaScript code executes.
html
Copy code
<!DOCTYPE html>
<html>
<head>
<style>
#content {
font-size: 20px;
color: blue;
#content:hover {
color: red;
</style>
</head>
<body>
<script>
// When the button is clicked, the text inside the div changes
document.getElementById("changeTextButton").onclick = function() {
};
</script>
</body>
</html>
In this example:
• The JavaScript code listens for the click event on the button. When the button is clicked, it
changes the content of the div and modifies the style (color of the text).
• The style attribute of the div is dynamically changed using JavaScript to update the color of
the text.
• Mouseover and Mouseout Effects: You can dynamically change styles when the user
interacts with elements.
javascript
Copy code
document.getElementById("content").onmouseover = function() {
this.style.color = "orange";
};
document.getElementById("content").onmouseout = function() {
this.style.color = "blue";
};
• Showing and Hiding Elements: You can hide or show elements dynamically using JavaScript.
javascript
Copy code
function toggleVisibility() {
content.style.display = "block";
} else {
content.style.display = "none";
}
}
document.getElementById("changeTextButton").onclick = toggleVisibility;
• Animation Effects: You can animate elements by modifying CSS properties with JavaScript.
For example, changing an element’s position over time:
javascript
Copy code
var pos = 0;
function moveElement() {
pos += 2;
requestAnimationFrame(moveElement);
document.getElementById("changeTextButton").onclick = moveElement;
Conclusion
DHTML brings life to web pages by allowing the combination of HTML, CSS, and JavaScript to create
interactive, dynamic experiences. By handling events such as button clicks, mouseover, or
keypresses, JavaScript can modify the content, structure, and appearance of the page on the fly
without requiring a page reload.
• Dynamic Content Changes: Modifying the content of web pages based on user interactions.
This combination of technologies opens up a wide range of possibilities for building engaging and
interactive web applications.
Unit----4
1. Introduction to XML
XML (Extensible Markup Language) is a flexible, structured language used for storing and
transporting data in a format that is both human-readable and machine-readable. Unlike HTML,
which is used to display data, XML is designed to carry data with a focus on the structure of the data
itself.
• Key Feature: XML allows you to define your own tags, making it extensible. This means it can
be used in different contexts to represent various types of data.
Example:
xml
Copy code
<book>
<title>Learning XML</title>
<author>John Doe</author>
<price>29.99</price>
</book>
2. Uses of XML
XML is used in a wide variety of applications due to its ability to represent structured data:
• Data Interchange: XML is a common format for data exchange between different platforms
and programming languages (e.g., RSS feeds).
xml
Copy code
<bookstore>
<book>
<author>Jane Smith</author>
<price>25.00</price>
</book>
<book>
<price>35.00</price>
</book>
</bookstore>
In this example:
• Each <book> has three child elements: <title>, <author>, and <price>.
• Prolog: The optional first line that defines XML version and encoding.
xml
Copy code
• Elements: The building blocks of XML. An element consists of a start tag, content, and an end
tag.
xml
Copy code
<book>...</book>
xml
Copy code
<book category="fiction">...</book>
• Text Content: The data enclosed between the start and end tags.
xml
Copy code
<title>XML Basics</title>
• DTD (Document Type Definition): Defines the structure, elements, and attributes allowed in
an XML document. DTD can be internal (within the XML document) or external (in a separate
file).
xml
Copy code
<!DOCTYPE book [
]>
• XML Schema: XML Schema is more powerful than DTDs and allows you to define the data
types and constraints for XML elements. XML Schema uses XSD (XML Schema Definition).
xml
Copy code
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="book">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
• Data Exchange: XML is used extensively in web services to exchange data between different
systems and applications.
• APIs: Many APIs return data in XML format, which can then be parsed and manipulated by
the application.
• Database Interaction: XML is used in some databases as a format for data storage (e.g., XML
databases).
• XSL (Extensible Stylesheet Language) is used to define the transformation and presentation
of XML data.
• XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML
documents into different formats like HTML, text, or other XML documents.
xml
Copy code
<xsl:template match="/bookstore">
<html>
<body>
<h2>Bookstore</h2>
<table border="1">
<tr>
<th>Title</th>
<th>Author</th>
<th>Price</th>
</tr>
<xsl:for-each select="book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="price"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
1. Introduction to PHP
PHP (Hypertext Preprocessor) is a server-side scripting language designed for web development, but
also used as a general-purpose programming language. PHP is widely used for creating dynamic
websites and can be embedded directly into HTML.
php
Copy code
<?php
?>
• Variables: PHP variables start with a dollar sign $ and are case-sensitive.
php
Copy code
echo $name;
• Data Types: PHP supports various data types, such as strings, integers, floats, arrays, and
objects.
php
Copy code
php
Copy code
echo $greeting;
Copy code
} else {
php
Copy code
switch ($day) {
case "Monday":
break;
case "Friday":
break;
default:
echo "Midweek.";
php
Copy code
php
Copy code
$i = 0;
while ($i < 5) {
$i++;
php
Copy code
Conclusion
• XML is a powerful tool for storing and exchanging data in a structured, machine-readable
format. It supports custom tags and provides a way to define the rules for data structure
using DTDs and XML schemas.
• PHP is a versatile scripting language used for web development. It supports dynamic content
generation, decision-making structures, and loops for creating interactive and responsive
web pages.
PHP is often embedded directly into HTML to create dynamic web pages. By embedding PHP code
within an HTML document, you can generate dynamic content, handle form data, interact with
databases, and much more.
php
Copy code
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Welcome to My Website</h1>
<?php
?>
</body>
</html>
In this example:
• PHP code is embedded within the HTML to output the current date and time dynamically.
PHP Arrays
Arrays in PHP are used to store multiple values in a single variable. PHP supports both indexed arrays
and associative arrays.
1. Indexed Arrays
php
Copy code
2. Associative Arrays
An associative array stores data in key-value pairs, where each key is associated with a value.
php
Copy code
$person = array(
);
3. Multidimensional Arrays
php
Copy code
$contacts = array(
);
PHP Functions
Functions in PHP are blocks of code that can be reused multiple times. Functions help organize and
manage code efficiently.
1. Defining Functions
Example:
php
Copy code
function greet($name) {
2. Built-in Functions
PHP provides a wide range of built-in functions, such as strlen(), str_replace(), array_push(),
array_merge(), etc.
Example:
php
Copy code
PHP can detect the browser type and perform different actions based on the browser information
sent by the client.
1. User-Agent Detection
You can use the $_SERVER['HTTP_USER_AGENT'] variable to get information about the client's
browser.
Example:
php
Copy code
$userAgent = $_SERVER['HTTP_USER_AGENT'];
} else {
1. String Functions
Example:
php
Copy code
PHP is commonly used to process HTML forms. Form data can be sent to a PHP script via the GET or
POST methods.
When using the POST method, data is sent in the HTTP request body, making it more secure for
sensitive data.
html
Copy code
</form>
php
Copy code
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
?>
PHP Files
PHP can handle file operations such as reading, writing, and uploading files.
Example:
php
Copy code
fclose($file);
2. Writing to a File
Example:
php
Copy code
fclose($file);
1. Cookies in PHP
Cookies are small pieces of data stored on the client side and sent with every HTTP request to the
server. You can set cookies in PHP using the setcookie() function.
Example:
php
Copy code
2. Sessions in PHP
Sessions allow you to store data on the server to maintain user state across multiple pages. Session
data is stored in superglobals like $_SESSION.
Example:
php
Copy code
To destroy a session:
php
Copy code
Object-Oriented Programming (OOP) in PHP is a programming paradigm that uses classes and objects
to model real-world concepts.
You define classes using the class keyword, and then create objects (instances) of the class.
Example:
php
Copy code
class Person {
public $name;
function __construct($name) {
$this->name = $name;
function greet() {
2. Inheritance in PHP
Inheritance allows a class to inherit properties and methods from another class.
Example:
php
Copy code
class Animal {
function speak() {
function speak() {
return "Woof!";
• Encapsulation: Hiding the internal workings of a class from outside access (using private or
protected keywords).
• Polymorphism: Allowing different classes to define the same method and override it.
Conclusion
• Advanced features like cookies, sessions, and object-oriented programming (OOP) concepts
in PHP.
MySQL is a relational database management system (RDBMS) used to store and manage data, while
PHP is often used as a server-side language to interact with MySQL databases. Below are the basic
commands for connecting PHP to a MySQL database and performing CRUD (Create, Read, Update,
Delete) operations.
To interact with MySQL from PHP, you first need to establish a connection using mysqli_connect() or
PDO (PHP Data Objects).
Using mysqli:
php
Copy code
// Create connection
// Check connection
if (!$conn) {
Using PDO:
php
Copy code
try {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
catch(PDOException $e) {
2. Creating a Database
Using mysqli:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
Using PDO:
php
Copy code
try {
$conn->exec($sql);
catch(PDOException $e) {
echo "Error creating database: " . $e->getMessage();
3. Selecting a Database
Using mysqli:
php
Copy code
$dbname = "myDatabase";
if (!mysqli_select_db($conn, $dbname)) {
Using PDO:
php
Copy code
$conn->exec("USE myDatabase");
4. Listing Databases
Using mysqli:
php
Copy code
if (mysqli_num_rows($result) > 0) {
} else {
}
5. Listing Table Names
Using mysqli:
php
Copy code
if (mysqli_num_rows($result) > 0) {
} else {
6. Creating a Table
Using mysqli:
php
Copy code
email VARCHAR(50),
reg_date TIMESTAMP
)";
if (mysqli_query($conn, $sql)) {
} else {
To insert data into a table, use the INSERT INTO SQL statement.
Using mysqli:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
8. Altering Tables
To modify an existing table (e.g., adding a new column), use the ALTER TABLE SQL statement.
Using mysqli:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
9. Executing Queries
You can execute SELECT, UPDATE, DELETE, and other queries using mysqli_query().
Selecting Data:
php
Copy code
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["username"]. " - Email: " . $row["email"]. "<br>";
} else {
Updating Data:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
Deleting Data:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
To delete a database or a table, use the DROP DATABASE and DROP TABLE commands.
Deleting a Database:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
Deleting a Table:
php
Copy code
if (mysqli_query($conn, $sql)) {
} else {
1. PHPMyAdmin
PHPMyAdmin is a popular web-based interface used to manage MySQL databases. It allows you to:
To use PHPMyAdmin:
• Login using the MySQL credentials (default is often root with no password).
• Use the interface to manage your databases and tables easily.
• Connection Issues: Ensure the correct MySQL server credentials (host, username, password)
are being used.
• SQL Injection: Always sanitize user inputs using prepared statements to prevent SQL
injection attacks.
• Database Connection Limits: Avoid creating too many simultaneous database connections,
as it can lead to performance issues. Close unused connections.
• Incorrect Query Syntax: Ensure your SQL queries are properly written and tested, as errors
may occur if there are typos or incorrect commands.
Conclusion
• Use PHPMyAdmin for managing databases more easily and address common database bugs.
• Perform CRUD operations (Create, Read, Update, Delete) using MySQL and PHP.