USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll BooksFrontend Field Manual
BooksFrontend BookWeb Foundations

Published and updated 31 July 2026 · Web Foundations

PreviousStart Here: Learn the System and Ship Your First PageNext TypeScript Foundations: Model Values, Functions, and Valid States
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

42 sections

Progress0%
1 / 42

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Web Foundations: HTML, CSS, JavaScript, the Browser, and Git

Web Foundations: HTML, CSS, JavaScript, the Browser, and Git connects the essential decisions in this stage of frontend engineering. You will learn each browser or framework model from first principles, apply it to the progressive Learning Atlas product, diagnose a realistic failure from evidence, and direct an AI collaborator with explicit constraints. The goal is independent judgment, not memorized syntax.

What you will build or be able to do

You will advance the semantic and responsive version of Learning Atlas. By the end, you can explain every topic in this chapter, implement one focused slice per topic, adapt those slices under new constraints, and defend the result with browser evidence, strict types, accessibility checks, security boundaries, and a production build.

Before you begin

Bring forward learning-atlas/index.html, styles.css, and app.js and the verification notes from the preceding chapter. Create a narrow Git branch, read the repository rules, and inspect existing changes before editing. When a tool or file is introduced for the first time, its purpose is explained before its syntax.

Use these project-orientation commands:

bash
pwd node --version npm --version git status --short

Before beginning Web Foundations: HTML, CSS, JavaScript, the Browser, and Git, stop if the working tree contains files you do not understand. Do not delete, reset, or rewrite another person's work to make the lesson cleaner.

How the outcomes connect

The browser builds cooperating models rather than painting a screenshot: HTML creates meaning, CSS resolves layout and presentation, and JavaScript responds to events while preserving the document's accessible structure. The topics below are ordered because each creates evidence needed by the next. Experienced readers may jump to a topic, but should still complete its failure investigation and adaptation task.

StepLearning outcomeProof of understanding
01Semantic HTML and Accessible Document StructureReplace a div-heavy article page with landmarks and native controls without changing its visual layout, then compare both accessibility trees.
02CSS Mental Models: Cascade, Specificity, Inheritance, and the Box ModelPredict the winner in five competing declarations, verify it in DevTools, then refactor the cascade so no selector needs an ID or important flag.
03Layout with Flexbox, Grid, Normal Flow, and PositioningImplement the same curriculum layout with flow, flex, and grid; document where each model becomes simpler or more fragile.
04Responsive Design, Mobile-First Thinking, and Container QueriesPlace one topic list in a wide main region and a narrow sidebar; make both adapt correctly without JavaScript width checks.
05JavaScript Essentials: Values, Functions, Objects, Arrays, and ModulesWrite pure functions that sort and group topics without changing the input; prove it with frozen data and two independent callers.
06The Browser Runtime: DOM, Events, Forms, Storage, and Accessibility APIsBuild the same form with native submission first, then enhance it with JavaScript while preserving Enter, validation, focus, and no-script behavior.
07Async JavaScript, Fetch, JSON, HTTP Failures, and Race ConditionsAdd cancellation or request identity to a search, then simulate slow, malformed, 404, 500, and offline responses.
08Git Foundations, Branches, Diffs, Commits, and RecoveryCreate staged, unstaged, committed, and untracked changes in a practice repository, then recover each without using a broad destructive command.

Semantic HTML and Accessible Document Structure

Semantic elements expose relationships before styling: landmarks organize regions, headings label sections, lists express collections, buttons perform actions, and links navigate. Correct native elements provide keyboard and accessibility behavior that generic containers must otherwise recreate.

Apply the model to Learning Atlas

The current artifact for semantic html and accessible document structure is learning-atlas/index.html. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

html
<header> <nav aria-label="Primary"> <a href="/" aria-current="page">Learning Atlas</a> <a href="/progress.html">Progress</a> </nav> </header> <main> <article aria-labelledby="lesson-title"> <h1 id="lesson-title">Semantic HTML</h1> <p>Elements communicate purpose to people and software.</p> </article> </main>

Failure evidence and minimal repair

Scenario: A clickable div opens a topic with a mouse but has no keyboard behavior, role, accessible name, or predictable place in the focus order.

Evidence to collect: Inspect the accessibility tree and tab sequence; compare the element's computed role, name, states, and supported keyboard activation with a native button.

Minimal repair rule: For semantic html and accessible document structure, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Replace a div-heavy article page with landmarks and native controls without changing its visual layout, then compare both accessibility trees.

CSS Mental Models: Cascade, Specificity, Inheritance, and the Box Model

CSS resolves competing declarations through origin, layer, importance, specificity, scope, and source order. Some properties inherit; every visible box has content, padding, border, and margin. Debug computed results before adding another selector.

Apply the model to Learning Atlas

The current artifact for css mental models: cascade, specificity, inheritance, and the box model is learning-atlas/styles.css. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

css
:root { color-scheme: light dark; } * { box-sizing: border-box; } body { margin: 0; font: 1rem/1.6 system-ui, sans-serif; } .lesson { padding: 1rem; border: 1px solid currentColor; } .lesson strong { font-weight: 700; }

Failure evidence and minimal repair

Scenario: A new high-specificity selector fixes one card but prevents the shared focus style and dark-theme token from taking effect.

Evidence to collect: Use the Styles and Computed panels to find the winning declaration, inherited value, box dimensions, and overridden token; disable rules one at a time.

Minimal repair rule: For css mental models: cascade, specificity, inheritance, and the box model, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Predict the winner in five competing declarations, verify it in DevTools, then refactor the cascade so no selector needs an ID or important flag.

Layout with Flexbox, Grid, Normal Flow, and Positioning

Normal flow handles most documents. Flexbox distributes items along one main axis; Grid coordinates rows and columns; positioned elements use a containing block and may leave flow. Choose the model from the relationship, not from a memorized property.

Apply the model to Learning Atlas

The current artifact for layout with flexbox, grid, normal flow, and positioning is learning-atlas/styles.css. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

css
.curriculum { display: grid; gap: 1rem; } .curriculum__nav { display: flex; flex-wrap: wrap; gap: 0.75rem; } @media (min-width: 48rem) { .curriculum { grid-template-columns: minmax(12rem, 18rem) 1fr; } .curriculum__nav { align-content: start; flex-direction: column; } }

Failure evidence and minimal repair

Scenario: An absolutely positioned badge looks correct on one card but overlaps long translated titles because the card did not reserve space and the containing block was accidental.

Evidence to collect: Inspect the containing block, overlay flex/grid tracks, disable positioning, add long content, and observe whether the parent size accounts for the child.

Minimal repair rule: For layout with flexbox, grid, normal flow, and positioning, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Implement the same curriculum layout with flow, flex, and grid; document where each model becomes simpler or more fragile.

Responsive Design, Mobile-First Thinking, and Container Queries

Responsive design lets content adapt to available space, input, zoom, and preferences. Start with the smallest robust flow, add enhancements when content needs them, and use container queries when a component depends on its own width rather than the viewport.

Apply the model to Learning Atlas

The current artifact for responsive design, mobile-first thinking, and container queries is learning-atlas/styles.css. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

css
.topic-list { container-type: inline-size; } .topic-grid { display: grid; gap: 1rem; } @container (min-width: 36rem) { .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

Failure evidence and minimal repair

Scenario: A two-column component works at a desktop viewport but overflows in a narrow sidebar because its breakpoint watches the page instead of the component container.

Evidence to collect: Resize the containing panel independently, inspect scroll width and container query conditions, test long content, and zoom to 200%.

Minimal repair rule: For responsive design, mobile-first thinking, and container queries, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Place one topic list in a wide main region and a narrow sidebar; make both adapt correctly without JavaScript width checks.

JavaScript Essentials: Values, Functions, Objects, Arrays, and Modules

JavaScript programs transform values. Functions name transformations, objects group named values, arrays preserve ordered collections, and modules define explicit dependencies. Mutation, identity, scope, coercion, and missing values explain many beginner surprises.

Apply the model to Learning Atlas

The current artifact for javascript essentials: values, functions, objects, arrays, and modules is learning-atlas/topics.js. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

javascript
export const topics = [ { id: "html", title: "Semantic HTML", complete: true }, { id: "css", title: "CSS layout", complete: false }, ]; export function remainingTopics(items) { return items.filter((item) => !item.complete); }

Failure evidence and minimal repair

Scenario: Filtering topics seems to update the UI, but the function mutates the original array and another view silently loses its items.

Evidence to collect: Log references before and after the function, freeze test input, inspect array methods, and verify whether callers receive a new value or shared mutation.

Minimal repair rule: For javascript essentials: values, functions, objects, arrays, and modules, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Write pure functions that sort and group topics without changing the input; prove it with frozen data and two independent callers.

The Browser Runtime: DOM, Events, Forms, Storage, and Accessibility APIs

The DOM is the browser's object model of a document. Events travel through capture and bubble phases; forms already know how to collect and submit named controls; storage persists strings; accessibility APIs expose semantics derived from the DOM.

Apply the model to Learning Atlas

The current artifact for the browser runtime: dom, events, forms, storage, and accessibility apis is learning-atlas/app.js. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

javascript
const form = document.querySelector("[data-progress-form]"); const output = document.querySelector("[data-status]"); form?.addEventListener("submit", (event) => { event.preventDefault(); const data = new FormData(form); const topic = String(data.get("topic") ?? "").trim(); output.textContent = topic ? `Saved ${topic}` : "Choose a topic first."; });

Failure evidence and minimal repair

Scenario: A form handler listens to a button click, so pressing Enter performs a full navigation and loses the user's unsaved status message.

Evidence to collect: Inspect the submit event, default action, event target, FormData names, Network navigation, focus destination, and accessibility announcement.

Minimal repair rule: For the browser runtime: dom, events, forms, storage, and accessibility apis, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Build the same form with native submission first, then enhance it with JavaScript while preserving Enter, validation, focus, and no-script behavior.

Async JavaScript, Fetch, JSON, HTTP Failures, and Race Conditions

A promise represents a future result, not a background thread. Fetch resolves for HTTP error statuses, JSON parsing can fail independently, and concurrent requests can finish out of order. Model cancellation, stale results, retry, and partial failure deliberately.

Apply the model to Learning Atlas

The current artifact for async javascript, fetch, json, http failures, and race conditions is learning-atlas/load-topics.js. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

javascript
export async function loadTopics(signal) { const response = await fetch("/api/topics", { signal }); if (!response.ok) throw new Error(`Request failed: ${response.status}`); const value = await response.json(); if (!Array.isArray(value)) throw new Error("Topics response must be an array"); return value; }

Failure evidence and minimal repair

Scenario: Typing quickly sends two searches; the older slow response arrives last and replaces the correct newer result.

Evidence to collect: Throttle the network, record request start and completion order, inspect AbortSignal state and query identity, and confirm response.ok before JSON use.

Minimal repair rule: For async javascript, fetch, json, http failures, and race conditions, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Add cancellation or request identity to a search, then simulate slow, malformed, 404, 500, and offline responses.

Git Foundations, Branches, Diffs, Commits, and Recovery

Git stores snapshots connected by commits. The working tree, staging area, current commit, branches, and remote references are separate states. Safe recovery begins by identifying which state contains the wanted work before running a command that moves or deletes it.

Apply the model to Learning Atlas

The current artifact for git foundations, branches, diffs, commits, and recovery is terminal. Before editing, predict the visible behavior and name the source of truth. Then implement or study this complete focused slice:

bash
git switch -c feature/progress-filter git status git diff --check git add learning-atlas git commit -m "Add progress filter" git log --oneline -5

Failure evidence and minimal repair

Scenario: A developer tries to discard one generated file and removes several untracked chapters because the cleanup command targeted a directory.

Evidence to collect: Stop writing, inspect status with untracked files, list exact paths, check reflog and stashes, and choose a path-specific recoverable operation.

Minimal repair rule: For git foundations, branches, diffs, commits, and recovery, correct the first boundary that violates the documented model, preserve the rest of the working path, and add a regression check based on the observed evidence.

Adaptation task

Create staged, unstaged, committed, and untracked changes in a practice repository, then recover each without using a broad destructive command.

AI Pairing Pattern for this stage

Goal: Advance the semantic and responsive version of Learning Atlas through one learning outcome at a time while keeping the implementation understandable and reversible.

Context to attach: the current web foundations outcome, the product brief, repository rules, package versions, relevant files and callers, shared types or tokens, the current Git diff, and the latest observed failure or command output.

Constraints: while advancing the semantic and responsive version of Learning Atlas, preserve concurrent work; use semantic HTML and strict TypeScript; keep Server Components as the default in Next.js; validate untrusted data on the server; do not expose secrets; include loading, empty, error, success, disabled, and partial states when relevant; make one bounded change.

Acceptance criteria: the web foundations adaptation works from 320 pixels upward; keyboard and focus behavior are complete; color is not the only signal; authorization and validation are enforced at authoritative boundaries; the relevant type, lint, build, and browser checks pass.

Reusable prompt:

We are implementing one outcome from “Web Foundations: HTML, CSS, JavaScript, the Browser, and Git” in the Learning Atlas. Read the attached repository rules, outcome text, relevant files, current diff, and verification evidence. Restate the user-visible result, source of truth, trust boundary, valid states, and unknowns. Propose the smallest reversible vertical slice. Implement only that slice. Then report the exact diff, criterion-to-evidence mapping, remaining risks, and the next discriminating check. Stop before dependency installation, destructive action, public-contract change, authentication decision, or deployment unless explicitly authorized.

For Web Foundations: HTML, CSS, JavaScript, the Browser, and Git, inspect the response without relying on its summary. Read every changed line, compare it with the actual source of truth, and reproduce the evidence yourself. Reject unexplained assertions, broad client boundaries, missing states, invented APIs, suppressed errors, or tests that merely restate implementation details.

Failure Lab: trace one defect across the whole stage

A responsive form works with a mouse but pressing Enter navigates away while a late search response overwrites newer results. Trace semantic form behavior, events, request order, DOM status, and Git repair. Write exact reproduction steps and expected versus observed behavior. Follow the value across every relevant boundary until you find the first contradiction.

Within the explain stage of Web Foundations: HTML, CSS, JavaScript, the Browser, and Git, change one cause, not several symptoms. Rerun the original reproduction, one adjacent failure case, keyboard navigation, and the focused static checks. The lab is complete only when you can explain why the repair works and which regression check would have failed before it.

Verify It Yourself

Run the scripts that this project actually defines:

bash
npx tsc --noEmit npm run lint npm run build

If your learning project later defines a test script, run it as an additional gate; do not report tests as passing when no test command exists. In the browser, resize from 320 pixels upward, use only the keyboard, inspect computed styles, and test success plus failure paths. Repeat the primary journey at 320, 768, and wide desktop widths, at 200% zoom, in both themes, by keyboard, and with reduced motion. For networked work, simulate slow, malformed, unauthorized, empty, and failed responses.

Review lenses

  • Accessibility: Compare the DOM with the accessibility tree; test native controls, form errors, heading order, keyboard events, and stored preferences.
  • Security: Treat URL, form, storage, and fetched JSON values as untrusted; validate before using them and avoid unsafe DOM sinks.
  • Responsive design: Test intrinsic layout, containing blocks, flex/grid minimums, container queries, long words, orientation, and no horizontal overflow.
  • Performance: Measure request waterfalls, render-blocking resources, event work, repeated DOM changes, and race-driven duplicate requests.

Checkpoint and practice extension

Close Web Foundations: HTML, CSS, JavaScript, the Browser, and Git and draw its models from memory. Pick two outcomes and explain how a decision in the first can cause a failure in the second. Then complete three levels of practice:

  • Guided: repeat one web foundations example with a second realistic data item and compare the evidence.
  • Independent: complete one explain-stage adaptation without the example, keeping a decision log and regression check.
  • Expert: design an alternative architecture for the semantic and responsive version of Learning Atlas; compare correctness, accessibility, security, responsive behavior, performance, operations, and migration cost using measured evidence.

Recap and bridge

You have treated web foundations as a connected engineering system rather than isolated syntax. The durable result is not the example code; it is the ability to predict behavior, expose assumptions, collect evidence, bound AI work, and repair the first broken boundary. Carry the product files and evidence log into the next stage.