Docsity

Web Development Complete Notes: HTML, CSS & JavaScript with Practice Projects, Study notes of Computer science

Toggle sidebar
bg1
Web Development Notes | HTML • CSS • JavaScript Page 1
WEB DEVELOPMENT
Complete Study Notes: HTML, CSS & JavaScript
Beginner to Project-Ready Guide
WHAT YOU WILL LEARN WHAT YOU CAN PRACTISE
HTML structure, semantic tags, forms Build a clean multi-section webpage
CSS selectors, box model, Flexbox, Grid Create responsive layouts
JavaScript variables, functions, DOM, events Add interactions and validation
Accessibility, debugging, deployment basics Complete mini-projects and quiz questions
Prepared as original educational notes for revision, self-study, and beginner practice.
Suggested category: Computer Science / Web Development / Study Notes
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Web Development Complete Notes: HTML, CSS & JavaScript with Practice Projects and more Study notes Computer science in PDF only on Docsity!

WEB DEVELOPMENT

Complete Study Notes: HTML, CSS & JavaScript

Beginner to Project-Ready Guide

WHAT YOU WILL LEARN WHAT YOU CAN PRACTISE

HTML structure, semantic tags, forms Build a clean multi-section webpage

CSS selectors, box model, Flexbox, Grid Create responsive layouts

JavaScript variables, functions, DOM, events Add interactions and validation

Accessibility, debugging, deployment basics Complete mini-projects and quiz questions

Prepared as original educational notes for revision, self-study, and beginner practice.

Suggested category: Computer Science / Web Development / Study Notes

Contents

    1. Introduction to Web Development
    1. HTML Fundamentals
    1. Semantic HTML and Page Structure
    1. Links, Images, Lists and Tables
    1. HTML Forms and Validation
    1. CSS Fundamentals
    1. The CSS Box Model and Layout
    1. Flexbox and CSS Grid
    1. Responsive Design
    1. JavaScript Fundamentals
    1. Conditions, Loops and Functions
    1. Arrays and Objects
    1. DOM Manipulation and Events
    1. Form Validation and Error Handling
    1. Accessibility, Security and Debugging
    1. Mini-Project 1: Personal Profile Page
    1. Mini-Project 2: Responsive Product Cards
    1. Mini-Project 3: Interactive Task List
    1. Practice Questions and MCQs
    1. Viva Questions, Glossary and Revision Checklist

How to use these notes: read each concept, type the code yourself, modify one feature, then answer the review

questions without looking at the notes.

2. HTML Fundamentals

HTML document skeleton

HTML means HyperText Markup Language. Elements are usually represented by an opening tag, content and a

closing tag. Some elements, such as img and br, are void elements and do not wrap content.

Basic document

A valid page should declare the document type, identify the language, include metadata and provide visible content

inside body.

My First Page

Hello, web!

This is my first webpage.

3. Semantic HTML and Page Structure

Semantic elements

Semantic HTML communicates the meaning of content. Common elements include header, nav, main, section, article,

aside and footer. Use them according to the purpose of the content rather than only for their default appearance.

Why semantics matter

Meaningful markup improves accessibility, makes code easier to maintain and helps browsers and other tools interpret

the page. A page should generally have one main element representing its primary content.

Headings

Use headings in a logical hierarchy: h1 for the main page topic, then h2 for major sections and h3 for subsections. Do

not choose heading levels only because of their visual size; style them with CSS.

5. HTML Forms and Validation

Form essentials

Forms collect user input. Labels should be programmatically associated with controls using matching for and id values.

Give inputs useful name attributes so their values can be identified when submitted.

Email address

Send

Input types

Common types include text, email, password, number, date, checkbox, radio and submit. Select the type that matches

the expected data and provides helpful browser behaviour.

Built-in validation

Attributes such as required, minlength, maxlength, min, max and type="email" can provide basic browser validation.

Client-side validation improves usability but should not be treated as a security boundary; servers must validate

received data too.

6. CSS Fundamentals

What CSS does

CSS means Cascading Style Sheets. Rules contain a selector and declarations. Each declaration consists of a property

and a value. CSS can be written in an external file, a style element, or an inline style; external stylesheets are generally

easier to maintain.

Selectors

Element selectors target tags, class selectors begin with a dot, and ID selectors begin with a hash. Attribute selectors

and pseudo-classes such as :hover and :focus provide more precise targeting.

/* styles.css */ body { font-family: Arial, sans-serif; } .card { padding: 1rem; border-radius: 0.75rem; } #page-title { color: #163a5f; } a:hover { text-decoration: underline; }

Cascade and specificity

When rules conflict, the browser considers origin, importance, cascade layers, specificity and source order. Avoid

excessive use of !important; clear class names and manageable selectors are easier to maintain.

Units and colour

Common units include px, rem, em, %, vw and vh. Relative units can help designs adapt. Colours can be written as

named colours, hexadecimal, rgb() or hsl(). Ensure text and backgrounds have sufficient contrast.

8. Flexbox and CSS Grid

Flexbox

Flexbox is suited to one-dimensional layout: arranging items in a row or column. Important properties include

display:flex, flex-direction, justify-content, align-items, gap, flex-wrap and flex-grow.

.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

Grid

CSS Grid is suited to two-dimensional layouts with rows and columns. Define tracks with grid-template-columns and

grid-template-rows. Use gap for spacing and repeat() with minmax() for flexible tracks.

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }

Choosing between them

Use Flexbox for a navigation bar, button row or alignment inside a card. Use Grid for a gallery, dashboard or

product-card matrix. They can be combined in the same page.

9. Responsive Design

Responsive principle

A responsive website adapts to different viewport sizes and input methods. Start with a readable mobile layout, use

flexible widths, and add breakpoints when the content needs a layout change.

Viewport metadata

Include a viewport meta tag so mobile browsers use the device width for layout. Without it, a mobile browser may use a

wider virtual layout viewport.

Media queries

Media queries apply CSS when a condition such as a minimum viewport width is met. Choose breakpoints based on

the design rather than copying device-specific numbers without testing.

/* Base layout works on narrow screens */ .container { width: min(100% - 2rem, 70rem); margin-inline: auto; } @media (min-width: 48rem) { .layout { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; } }

Responsive checklist

Avoid fixed widths that cause overflow; allow images to scale; test navigation, forms and cards on narrow screens; use

readable text sizes; and check that controls remain easy to operate by touch.

11. Conditions, Loops and Functions

Conditions

if, else if and else select code paths. switch is useful when comparing one expression against several cases. Use

braces consistently to make blocks easy to read.

Loops

for is useful when the number of iterations is known; while repeats while a condition remains true; for...of iterates over

iterable values such as array items. Make sure loop conditions eventually become false.

Functions

Functions package reusable behaviour. Parameters receive input values and return sends a result back to the caller.

Arrow functions provide a concise syntax and are commonly used for callbacks.

function add(a, b) { return a + b; } const multiply = (a, b) => a * b; console.log(add(2, 3)); // 5 console.log(multiply(2, 3)); // 6

Scope

A variable's scope determines where it can be accessed. let and const are block-scoped. Prefer small functions and

local variables to reduce accidental dependencies.

12. Arrays and Objects

Arrays

Arrays store ordered collections. Common methods include push, pop, slice, includes, map, filter, find and forEach.

map creates a transformed array; filter selects items that meet a condition.

const scores = [72, 88, 91, 64]; const passing = scores.filter(score => score >= 70); const doubled = scores.map(score => score * 2); console.log(passing, doubled);

Objects

Objects group related properties and values. Access properties with dot notation or bracket notation. Use bracket

notation when the property key is stored in a variable or contains characters that dot notation cannot use.

Destructuring and spread

Destructuring extracts values into variables. The spread syntax (...) can copy or combine arrays and objects, though

these copies are shallow: nested objects may still be shared.

Choosing a structure

Use an array for an ordered collection, and an object for a single entity with named properties. A list of records is often

represented as an array of objects.

14. Form Validation and Error Handling

User-friendly validation

Explain what is wrong and how to correct it. Keep the user's entered values where possible. Associate error text with

the relevant input and do not rely on colour alone to communicate errors.

try and catch

Use try...catch when an operation can throw an exception and the program can recover or show a useful message. Do

not silently ignore errors that prevent the user from completing a task.

Defensive programming

Check assumptions, handle missing elements and unexpected input, and give useful feedback. Avoid trusting data

simply because it came from a browser form.

15. Accessibility, Security and Debugging

Accessibility basics

Use semantic HTML, keyboard-operable controls, visible focus styles, labels for form fields, descriptive link text,

suitable alt text and adequate contrast. Test a page using only a keyboard.

Security basics

Do not place passwords, API secrets or private credentials in front-end code. Treat user input as untrusted. Prefer

textContent for text insertion, validate data on the server, and use HTTPS for deployed sites.

Debugging workflow

Reproduce the issue, read the exact console error, inspect the element and its styles, isolate the smallest failing

example, make one change at a time, then retest. Check spelling, file paths and capitalization.

Performance basics

Compress images, avoid unnecessary scripts, remove unused CSS, and load scripts in a way that does not block page

parsing unnecessarily. Measure before optimising.

17. Mini-Project 2: Responsive Product Cards

Goal: display several products in a responsive grid. Practise CSS Grid, card components, consistent spacing and

accessible buttons.

HTML example

Notebook

Ruled pages for everyday notes.

n120

View details

Pen Set

Colourful pens for school projects.

n80

View details

CSS example

.products { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1.25rem; padding: 1.25rem; } .product-card { border: 1px solid #d5dee8; border-radius: 1rem; padding: 1rem; background: white; } .product-card img { width: 100%; height: auto; border-radius: .5rem; } .price { font-weight: bold; } button { padding: .7rem 1rem; cursor: pointer; }

Extension tasks

  • Add a clear focus style to buttons.
  • Add a category label to each card.
  • Use a media query only if the layout needs it.
  • Check that the text remains readable when zoomed in.

18. Mini-Project 3: Interactive Task List

Goal: allow a user to add tasks and mark them complete. This beginner project practises DOM selection, events,

element creation and safe text insertion.

HTML

My Tasks

New task

Add task

JavaScript

const form = document.querySelector("#task-form"); const input = document.querySelector("#task-input"); const list = document.querySelector("#task-list"); const status = document.querySelector("#status");

form.addEventListener("submit", (event) => { event.preventDefault(); const taskText = input.value.trim();

if (!taskText) { status.textContent = "Please enter a task."; input.focus(); return; }

const item = document.createElement("li"); const label = document.createElement("label"); const checkbox = document.createElement("input"); checkbox.type = "checkbox";

label.append(checkbox, document.createTextNode(" " + taskText)); item.append(label); list.append(item);

input.value = ""; status.textContent = "Task added."; input.focus(); });

What this project teaches

The form's submit event is handled without reloading the page. trim() removes extra whitespace. createElement and

createTextNode treat the task as text instead of interpreting it as HTML. The checkbox lets the user mark a task as

complete.

Extension tasks

  • Add a delete button with an accessible name.
  • Use a CSS class to style completed tasks.
  • Show a helpful message when the list is empty.
  • Optional advanced challenge: save tasks between reloads using localStorage, and explain its limitations.