WD Notes All Units
WD Notes All Units
Communication
• Request Line: Specifies the method (GET), resource, and HTTP version.
• Headers: Provide information about the client and request parameters.
• Body: Included in methods like POST, contains form or JSON data.
HTTP/1.1 200 OK
Content-Type: text/html
<html><body>Welcome</body></html>
• Status Code: Indicates the result of the request (200 OK, 404 Not Found, 500
Internal Server Error).
• Headers: Include metadata (e.g., content type, length).
• Body: Actual response data (HTML, JSON, etc.).
Web Clients
Server
• A server is a powerful computer that listens for requests and sends responses.
• Examples: Apache, Nginx, Node.js servers.
2. Communication Model
• Request/Response model (stateless)
• Uses HTTP or HTTPS
• Typical flow:
1. Client makes an HTTP request (e.g., GET/POST).
2. Server processes the request.
3. Server sends an HTTP response (HTML/JSON).
Protocol Description
IP Internet Protocol - provides IP addresses
TCP Transmission Control Protocol - ensures reliable transmission
UDP User Datagram Protocol - faster but less reliable
HTTP/HTTPS Web data transmission protocols
FTP File Transfer Protocol
SMTP/POP3/IMAP Email communication
<html>
<body>Hello, World!</body>
</html>
Key Parts:
6. Web Clients
• Software that communicates with web servers.
• Examples:
o Web Browsers: Chrome, Firefox
o Mobile apps
o Command-line tools: curl, wget
o API Testing Tools: Postman
HTML Overview
• HTML defines the structure of web content using tags.
• Each tag represents a type of element (e.g., heading, paragraph, image).
• Tags usually come in pairs: opening <tag> and closing </tag>.
Document Publishing
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is a paragraph.</p>
</body>
</html>
Element Description
<html> Root of the HTML document
<head> Metadata, styles, scripts
<title> Title in the browser tab
<body> Main content of the page
<h1> to <h6> Headings
<p> Paragraph
<a> Hyperlink
<img> Image
<div> Generic container
<span> Inline container
XHTML Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XHTML Page</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is valid XHTML.</p>
<br />
</body>
</html>
4. Document Publishing
Document Publishing in Web Development:
5. HTML4 vs HTML5
Feature HTML4 HTML5
Doctype Complex Simple (<!DOCTYPE html>)
Syntax Based on SGML Looser, not SGML
No native
Multimedia <audio>, <video> supported
audio/video
No semantic
New Elements Yes: <section>, <article>, <nav>, etc.
elements
Form Input
Basic only New types: email, date, range, etc.
Types
Rich: Canvas, Geolocation, Drag-n-drop, Web
APIs Limited
Storage
HTML5 Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Demo</title>
</head>
<body>
<header>
<h1>Welcome to HTML5</h1>
</header>
<section>
<article>
<p>This is a modern semantic layout.</p>
</article>
</section>
<footer>
<p>© 2025</p>
</footer>
</body>
</html>
UNIT 3: CSS3
Introduction
CSS Syntax
selector {
property: value;
}
• Example:
h1 {
color: blue;
font-size: 24px;
}
CSS Selectors
• Basic Selectors:
o Element: div, p
o Class: .highlight
o ID: #header
• Combinators:
o Descendant: div p
o Child: ul > li
o Adjacent sibling: h1 + p
• Pseudo-selectors:
o :first-child, :last-child, :hover, :nth-child()
o ::before, ::after, ::first-line
• Attribute Selectors:
o input[type="text"], a[target="_blank"]
• Group Selectors:
o h1, h2, p styles multiple elements at once
1. CSS3 Introduction
What is CSS3?
• CSS = Cascading Style Sheets – used to style HTML elements.
• CSS3 is the latest version of CSS with new features like animations, transitions, and
flexible layouts.
2. Features of CSS3
• Media Queries – for responsive designs.
• Flexbox and Grid – modern layout systems.
• New Selectors – nth-child, attribute, ::before, etc.
• Animations and Transitions
• Multiple Backgrounds
• Custom Fonts with @font-face
• Rounded Corners (border-radius)
• Shadows (box-shadow, text-shadow)
3. CSS Syntax
selector {
property: value;
}
Example:
p{
color: blue;
font-size: 16px;
}
border-collapse: collapse;
table-layout: fixed;
Cursor Property
cursor: pointer; /* or move, text, wait, crosshair */
5. CSS Selectors
Selector Type Syntax Description
Tag h1 {} Selects all <h1> elements
ID #title {} Selects element with id="title"
Class .note {} Selects all elements with class="note"
Group h1, p {} Selects all <h1> and <p>
Selects <p> elements that are direct children of
Child div > p {}
<div>
Descendant div p {} Selects all <p> inside a <div>
Adjacent
h1 + p {} Selects the <p> immediately after <h1>
Sibling
General Sibling h1 ~ p {} Selects all <p> after <h1> in the same parent
Attribute input[type="text"] {} Selects input elements with type="text"
First Line p::first-line {} Styles the first line of text in a paragraph
p::before { content: "*";
Before/After Inserts content before/after an element
}
Sub-class ul li {} Targets <li> inside <ul>
Pseudo-class a:hover {} Selects when user hovers over a link
h1 {
color: navy;
text-align: center;
}
.box {
width: 300px;
height: 200px;
border: 2px solid black;
background-color: lightblue;
margin: 20px auto;
padding: 10px;
}
#special {
color: red;
font-weight: bold;
}
p::first-line {
font-style: italic;
}
a:hover {
color: green;
}
</style>
</head>
<body>
<h1>Welcome</h1>
<div class="box">
<p id="special">This is a styled box with CSS3.</p>
<a href="#">Hover over me</a>
</div>
</body>
</html>
UNIT 4: JavaScript / DOM / AJAX
JavaScript Basics
• Declaration:
o var (legacy), let, const
• Data Types:
o Primitive: string, number, boolean, null, undefined
o Composite: object, array, function
function greet(name) {
return "Hello " + name;
}
JavaScript Objects
let person = {
name: "Alice",
age: 25,
greet: function() { return "Hi " + this.name; }
};
Debugging
Host Objects
document.getElementById("title");
document.querySelector(".menu-item");
• Modifying content:
document.getElementById("submit").addEventListener("click", function() {
alert("Form Submitted!");
});
fetch("data.json")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
1. JavaScript: Introduction
What is JavaScript?
• It runs in the browser and can interact with HTML and CSS.
• Used for form validation, DOM manipulation, animations, AJAX calls, etc.
2. JavaScript Basics
Syntax Example
console.log("Hello, JavaScript!");
// Variable declaration
console.log("Adult");
Literals
• String: "Hello"
3. Functions in JavaScript
Example:
function greet(name) {
console.log(greet("Alice"));
4. JavaScript Objects
let person = {
name: "John",
age: 25,
greet: function() {
};
console.log(person.greet());
Arrays
Built-in Objects
console.log(Math.sqrt(16)); // 4
Debugging
5. Host Objects
Document Tree
<html>
<body>
<div>
<p>Hello</p>
</div>
</body>
</html>
document.getElementById("myId");
document.querySelector("p");
<p id="demo">Hello</p>
<script>
document.getElementById("demo").innerText = "Welcome!";
</script>
Inline Event
JS Event Listener
document.getElementById("btn").addEventListener("click", function() {
alert("Button Clicked");
});
What is AJAX?
fetch("https://api.example.com/data")
Real-World Use: