Web Technologies
Comprehensive exam revision notes for BCA-303N Unit 1 (Web Basics, HTML5, CSS3 & Client-Side JavaScript). Includes Section A (2M), Section B (5M), and Section C (15M) questions, answers, and diagrams.
Web Technologies
Web Basics, HTML5, CSS3 & Client-Side JavaScript
Core Definitions & Key Concepts
What is the primary difference between HTTP and HTTPS
HTTP transmits data as unencrypted plain text across port 80, vulnerable to eavesdropping and MITM attacks. HTTPS encrypts communication using TLS/SSL over port 443, ensuring confidentiality, server authentication via digital certificates, and message integrity.
The difference between HTTP GET and POST methods
| Method | Data Transmission | Caching | Payload Limit | Security |
|---|---|---|---|---|
| GET | Appended to URL query string (?id=1) | Cached by browsers & proxies | URL length limits (~2048 chars) | Insecure for sensitive data |
| POST | Sent in HTTP message request body | Not cached by default | Arbitrary/Large payloads (files) | Safe for credentials/forms |
What are semantic HTML5 elements? Give four examples
Semantic elements clearly describe their meaning to both browser and developer. Examples: <header> (introductory content), <nav> (navigation links), <article> (independent self-contained content), <footer> (page/section footer).
The CSS3 Box Model components
Every HTML element is rendered as a rectangular box comprising four concentric layers:
- Content: The actual text, images, or child elements.
- Padding: Transparent spacing clearing the area around content.
- Border: Outline surrounding the padding.
- Margin: Transparent space clearing the area outside the border.
What is the difference between display: none and visibility: hidden in CSS
display: none: Removes element completely from visual rendering and normal page document flow; it occupies zero space.visibility: hidden: Hides the element visually, but its allocated space in the page layout is preserved.
What is CSS3 Flexbox and what is its main axis vs cross axis
Flexbox is a one-dimensional layout model. The main axis runs in the direction defined by flex-direction (row or column), while the cross axis runs perpendicular to the main axis.
let, const, and var in JavaScript (ES6)
| Keyword | Scope | Hoisting | Reassignment | Re-declaration |
|---|---|---|---|---|
var | Function scope | Hoisted & initialized as undefined | Yes | Yes |
let | Block {} scope | Hoisted in Temporal Dead Zone (TDZ) | Yes | No |
const | Block {} scope | Hoisted in Temporal Dead Zone (TDZ) | No (Immutable binding) | No |
What is the difference between == and === in JavaScript
==(Loose Equality): Performs automatic type coercion before comparing values (e.g.,'5' == 5istrue).===(Strict Equality): Compares both value and data type without type coercion (e.g.,'5' === 5isfalse).
Event Bubbling vs Event Capturing in the JavaScript DOM
- Event Capturing (Trickling): The event travels down from the top
window/documentdown to the target element. - Event Bubbling: The event fires on the target element and bubbles upward through parent ancestors to the root.
What is AJAX and what object powers it natively
AJAX (Asynchronous JavaScript and XML) allows web pages to send and receive data asynchronously from a web server in the background without reloading the entire page. Natively powered by XMLHttpRequest or the modern fetch() API.
Conceptual & Architectural Analysis
Compare CSS Grid Layout vs Flexbox Layout with Use Cases
| Feature | CSS Flexbox | CSS Grid |
|---|---|---|
| Dimensionality | One-dimensional (row OR column at a time) | Two-dimensional (rows AND columns simultaneously) |
| Approach | Content-first (distributes space along an axis) | Layout-first (defines rigid grid tracks/cells) |
| Alignment | justify-content, align-items along flex axis | grid-template-columns, grid-template-rows, gap |
| Best Used For | Navigation bars, button groups, linear card decks | Entire page application layouts, dashboards, photo galleries |
1/* Flexbox Example */2.nav-bar { display: flex; justify-content: space-between; align-items: center; }3
4/* Grid Example */5.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }The JavaScript Event Loop, Microtask Queue, and Callback Queue
JavaScript Asynchronous Concurrency Model
JavaScript is single-threaded with a non-blocking event loop:
+-------------------+ +------------------------+
| CALL STACK | | WEB APIs (Browser) |
| (Synchronous Code)| ------> | DOM, setTimeout, fetch |
+-------------------+ +------------------------+
^ |
| Checks v
+-------------------+ +------------------------+
| EVENT LOOP | | TASK QUEUES |
| | <------ | 1. Microtask (Promises)|
| | | 2. Macrotask (Timers) |
+-------------------+ +------------------------+- Call Stack: Executes synchronous functions immediately.
- Web APIs: Handles asynchronous timers, HTTP requests, DOM events.
- Microtask Queue: Highest priority for resolved Promises (
.then(),async/await). Evaluated before macrotasks. - Macrotask/Callback Queue: Holds callbacks from
setTimeout(),setInterval(), and UI events.
HTML5 Web Storage: LocalStorage vs SessionStorage vs Cookies
| Feature | localStorage | sessionStorage | Cookies (document.cookie) |
|---|---|---|---|
| Storage Capacity | ~5MB to 10MB | ~5MB | ~4KB |
| Lifetime | Persistent until explicitly cleared | Deleted when browser tab is closed | Configurable via Expires/Max-Age |
| Server Transmission | Never sent automatically to server | Never sent to server | Sent with every HTTP request header |
| Accessibility | Any window/tab on same origin | Limited strictly to that browser tab | Same domain / Subdomains |
Detail the DOM Tree and Common DOM Manipulation Methods in JavaScript
The Document Object Model (DOM) is a tree-like object representation of an HTML document created by the browser engine:
- Selection:
document.getElementById('id'),document.querySelector('.class'),document.querySelectorAll('div'). - Content Modification:
element.textContent = 'text',element.innerHTML = '<span>markup</span>'. - Attribute Modification:
element.setAttribute('src', 'logo.png'),element.classList.add('active'). - Node Insertion/Deletion:
parent.appendChild(node),parent.removeChild(node),node.remove().
HTML5 Form Validation and New Input Types
HTML5 introduced native client-side validation attributes and input types without requiring custom JavaScript:
- New Input Types:
email,url,tel,number,date,color,range. - Constraint Attributes:
required,pattern="[A-Za-z]{3}",min="18",max="100",maxlength="50". - Form pseudo-classes:
:valid,:invalid,:requiredenable real-time CSS styling based on validation status.
In-Depth Analysis & Implementation
Develop a Complete Responsive Single-Page Application (SPA) Component in HTML5, CSS3 Flexbox/Grid, and JavaScript with Client-Side Form Validation and AJAX Fetch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MJPRU BCA Student Portal - Web Technologies Demo</title>
<style>
:root {
--primary: #1e3a8a;
--secondary: #0d9488;
--bg-dark: #0f172a;
--surface: #1e293b;
--text: #f8fafc;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; }
body { background-color: var(--bg-dark); color: var(--text); padding: 2rem; }
.container { max-width: 900px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 768px) { .container { grid-template-columns: 1fr; } }
.card {
background: var(--surface);
padding: 1.5rem;
border-radius: 12px;
box-shadow: 0 10px 25px rgba(0,0,0,0.3);
border: 1px solid rgba(255,255,255,0.08);
}
h2 { margin-bottom: 1rem; color: var(--secondary); font-size: 1.3rem; }
.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; }
label { font-size: 0.85rem; margin-bottom: 0.3rem; opacity: 0.9; }
input {
padding: 0.7rem; border-radius: 6px; border: 1px solid #475569;
background: #0f172a; color: white; outline: none; transition: 0.2s;
}
input:focus { border-color: var(--secondary); }
.error-msg { color: #f87171; font-size: 0.8rem; margin-top: 0.3rem; display: none; }
button {
background: var(--secondary); color: white; padding: 0.75rem; border: none;
border-radius: 6px; font-weight: bold; cursor: pointer; width: 100%; transition: 0.2s;
}
button:hover { opacity: 0.9; transform: translateY(-1px); }
#userList { list-style: none; margin-top: 1rem; }
#userList li {
background: #0f172a; padding: 0.75rem; border-radius: 6px; margin-bottom: 0.5rem;
border-left: 4px solid var(--secondary);
}
</style>
</head>
<body>
<div class="container">
<!-- Form Card -->
<div class="card">
<h2>Register BCA Candidate</h2>
<form id="regForm" novalidate>
<div class="form-group">
<label for="uname">Full Name (Minimum 3 chars):</label>
<input type="text" id="uname" required>
<span class="error-msg" id="nameErr">Name must be at least 3 characters.</span>
</div>
<div class="form-group">
<label for="uemail">University Email:</label>
<input type="email" id="uemail" required>
<span class="error-msg" id="emailErr">Valid email required (e.g. user@mjpru.ac.in).</span>
</div>
<button type="submit" id="submitBtn">Submit Registration</button>
</form>
</div>
<!-- Live AJAX Results Card -->
<div class="card">
<h2>Registered Candidates (Live List)</h2>
<ul id="userList"></ul>
</div>
</div>
<script>
const form = document.getElementById('regForm');
const userList = document.getElementById('userList');
// Client-side Validation Logic
form.addEventListener('submit', async (e) => {
e.preventDefault();
let isValid = true;
const name = document.getElementById('uname').value.trim();
const email = document.getElementById('uemail').value.trim();
const nameErr = document.getElementById('nameErr');
const emailErr = document.getElementById('emailErr');
if (name.length < 3) {
nameErr.style.display = 'block';
isValid = false;
} else { nameErr.style.display = 'none'; }
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
emailErr.style.display = 'block';
isValid = false;
} else { emailErr.style.display = 'none'; }
if (!isValid) return;
// Asynchronous DOM Update & LocalStorage Persistence
const candidate = { name, email, timestamp: new Date().toLocaleTimeString() };
appendCandidate(candidate);
// Save in localStorage
const saved = JSON.parse(localStorage.getItem('bca_candidates') || '[]');
saved.push(candidate);
localStorage.setItem('bca_candidates', JSON.stringify(saved));
form.reset();
});
function appendCandidate(item) {
const li = document.createElement('li');
li.innerHTML = `<strong>${item.name}</strong> (${item.email}) - <small>${item.timestamp}</small>`;
userList.prepend(li);
}
// Load on start
window.addEventListener('DOMContentLoaded', () => {
const saved = JSON.parse(localStorage.getItem('bca_candidates') || '[]');
saved.forEach(appendCandidate);
});
</script>
</body>
</html>JavaScript Closures, Lexical Scope, and Prototype-Based Inheritance with Complete Code Examples
Deep Dive: Advanced JavaScript Engine Concepts
1. Lexical Scoping and Closures:
A Closure is the combination of a function bundled together with references to its surrounding lexical environment. A closure gives an inner function access to an outer function's scope even after the outer function has finished executing and returned.
1function createCounter(initialValue = 0) {2 let count = initialValue; // Private variable encapsulated in outer scope3
4 return {5 increment() {6 count++;7 return count;8 },9 decrement() {10 count--;11 return count;12 },13 getValue() {14 return count;15 }16 };17}18
19const counter1 = createCounter(10);20console.log(counter1.increment()); // 1121console.log(counter1.increment()); // 1222console.log(counter1.getValue()); // 1223// Direct access 'counter1.count' is undefined (true data hiding/encapsulation!)2. Prototypal Inheritance vs Class Syntax:
JavaScript does not possess true classical classes; under the hood, all objects inherit properties through a Prototype Chain:
1// Functional Prototype Definition2function Vehicle(make, model) {3 this.make = make;4 this.model = model;5}6
7Vehicle.prototype.getInfo = function() {8 return `${this.make} ${this.model}`;9};10
11function Car(make, model, doors) {12 Vehicle.call(this, make, model); // Call super constructor13 this.doors = doors;14}15
16// Link prototype chain17Car.prototype = Object.create(Vehicle.prototype);18Car.prototype.constructor = Car;19
20Car.prototype.honk = function() {21 return `${this.getInfo()} is honking!`;22};23
24const myCar = new Car('Honda', 'City', 4);25console.log(myCar.honk()); // "Honda City is honking!"26console.log(myCar instanceof Vehicle); // trueAsynchronous JavaScript Evolution: Callbacks, Promises, and async/await with Error Handling
The Evolution of Asynchronous Control Flow in JavaScript
1. Callback Hell (Pyramid of Doom):
Early JavaScript relied on nested callback functions, leading to unmaintainable code and difficult error propagation:
1getUser(userId, (user) => {2 getOrders(user.id, (orders) => {3 getOrderDetails(orders[0].id, (details) => {4 // Deeply nested pyramid of doom!5 }, handleError);6 }, handleError);7}, handleError);2. Promises (ES6):
A Promise is an object representing eventual completion (fulfilled) or failure (rejected) of an asynchronous operation:
1function fetchUserData(userId) {2 return new Promise((resolve, reject) => {3 setTimeout(() => {4 if (userId > 0) resolve({ id: userId, name: 'Akshay' });5 else reject(new Error('Invalid user ID'));6 }, 1000);7 });8}9
10fetchUserData(101)11 .then(user => console.log('User:', user))12 .catch(err => console.error('Error:', err.message))13 .finally(() => console.log('Async operation completed.'));3. Modern async/await (ES2017) with try...catch:
Syntactic sugar over Promises providing synchronous-looking, readable code:
1async function displayCandidateProfile(id) {2 try {3 console.log('Fetching candidate data...');4 const response = await fetch(`https://api.example.com/candidates/${id}`);5 if (!response.ok) {6 throw new Error(`HTTP error! status: ${response.status}`);7 }8 const data = await response.json();9 console.log('Profile retrieved:', data);10 return data;11 } catch (error) {12 console.error('Fetch operation failed:', error.message);13 }14}Important Exam Points & Quick Revision
Examiners heavily test: Responsive CSS Grid vs Flexbox, JavaScript DOM event bubbling, and Async/Await Promise mechanics.
100% left on this page — finishing it closes the gap for Web Basics, HTML5, CSS3 & Client-Side JavaScript.
Web Basics, HTML5, CSS3 & Client-Side JavaScript still counts as a weak topic until you finish this note and answer its questions.
Practise this unitTest Your Understanding
Now that you've read through these notes, practice unit MCQs to identify weak points and solidify your learning before exams.