How the web works
Client, server, and HTTP request
Before writing a line of code, understand what happens between the browser and the server.
Client and server
The client (your browser : Chrome, Firefox...) sends a request to a server (a remote computer hosting the site). The server responds by sending back the requested files (HTML, CSS, JS, images...) that the
What happens when you type a URL ?
- The browser sends an HTTP request (GET) to the server matching the URL.
- The server processes the request and sends back a response (status + files).
- The browser parses the HTML, applies the CSS, then executes the JS.
- The page displays on screen, ready to be interactive.
The three pillars of the front end
- HTML (HyperText Markup Language) : the structure and the content (the skeleton).
- CSS (Cascading Style Sheets) : the presentation (colors, layout, typography).
- JavaScript : the behavior (interactivity, reacting to clicks, dynamic updates).
A useful analogy : HTML is the skeleton of a house, CSS the paint and decoration, JavaScript the electricity that makes it
Essential tools
A code editor (VS Code, for example) to write the files, and the browser's developer tools (F12 key) to inspect HTML/CSS live and see JavaScript errors in the console.
HTML — Structuring a page
Anatomy of an HTML document
The minimal skeleton every web page must contain.
HTML
The HTML describes the content of a page using tags (most often as an opening/closing pair) : <p>text</p>. A tag can carry attributes that refine its behavior, e.g. : <a href="...">.
Minimal structure of a page
<!DOCTYPE html>: tells the browser this is HTML5.<head>: invisible metadata (tab title, encoding, links to CSS...).<body>: everything visible on screen.
The meta viewport tag
<meta name="viewport" content="width=device-width, initial-scale=1"> tells the mobile browser to display the page at its actual width rather than shrinking it — essential for any responsive site.
Text, lists, links, and images
The most common content building blocks.
Headings and paragraphs
There are 6 heading levels (h1 to h6) — only one <h1> per page, then work down the hierarchy without skipping a level.
Lists
ul (unordered list, bulleted) vs ol (ordered list, numbered) — each item is an <li>.
Links and images
The alt attribute of an image is not optional : it's read by screen readers and shown if the image fails to load — essential for accessi
Attribute vs content
A attribute goes inside the opening tag (href, src, class, id...), always as name="value". The content goes between the opening and closing tag.
Semantic tags
Describing the role of each area of the page, not just its appearance.
Semantic tag
A semantic tag clearly states the role of its content (e.g. : <nav> = navigation), unlike <div> which carries no particular meaning. They help browsers, search engines, and screen readers understand the page.
Typical semantic structure of a page
<header>: header (logo, title, nav) — can appear multiple times (page or section).<nav>: only for the large navigation link blocks.<main>: the main content — only one per page.<article>: self-contained content, independently distributable (article, post, product card).<aside>: related but secondary content (related links, sidebar).<footer>: page or section footer.
Forms and tables
Collecting user data, and presenting tabular data.
A simple form
<label for="..."> must match theid of the field : clicking the label then activates the field — important for accessibility.input types : text, email, password, number, checkbox, radio, date.
A table
<th> = column/row header, <td> = data cell, <tr> = row.
A table is not a layout tool
Before CSS, tables were used to position elements on a page — this should be avoided today. Reserve <table> for genuinely tabular data (financial data, comparisons...) and use CSS (Flexbox/Grid) for layout.
CSS — Styling
Selectors and syntax
Targeting elements to style, and understanding rule priority order.
CSS rule
A CSS rule pairs a selector (which elements to target) with declarations (property : value), inside braces :
Types of selectors
| Selector | Targets | Example |
|---|---|---|
| Type | All tags of this type | p { color: navy; } |
| Class | Elements with class="..." | .card { padding: 16px; } |
| ID | The unique element with this id | #header { height: 60px; } |
| Pseudo-class | A particular state | a:hover { color: red; } |
| Descendant | An element inside another | nav a { text-decoration: none; } |
Priority order (specificity)
When several rules target the same element, the most specific wins : an ID (#id) beats a class (.class), which beats a type selector (p). At equal specificity, the rule declared last wins (hence the "C" in Cascading).
The box model, colors, and units
Every HTML element is actually a rectangular box.
The box model
Every box is made up, from center outward, of : content (the content) → padding (inner spacing) → border (border) → margin (outer spacing, outside the box).
box-sizing : the classic trap
By default, width only counts the content : adding padding/border enlarges the box beyond the set width. The near-universal fix :
With border-box, width now includes padding and border : the box keeps its intended size.
Common units
px: pixels, fixed size.%: relative to the parent.em: relative to the parent element's font size.rem: relative to the root (html) font size — more predictable, often preferred overem.vh/vw: % of the visible window (viewport) height/width.
Colors and typography
Colors are written in hexadecimal (#RRGGBB), rgb()/rgba() (with transparency), or by keyword (navy, tomato...).
Positioning, Flexbox, and Grid
The two modern tools for organizing a layout.
The display property
block: takes up all available width, breaks the line (e.g. :div,p).inline: takes only the width of its content, stays on the line (e.g. :span,a).flex/grid: turns the element into a flexible/grid container for its children.none: completely hides the element (it takes up no space).
position
static (default, in the normal flow) · relative (offset from its original position, with top/left...) · absolute (positioned relative to the nearest positioned ancestor) · fixed (fixed relative to the window, doesn't move on scroll).
Flexbox — aligning on one axis
Flexbox aligns a container's children along a single axis (row or column) : ideal for a navigation bar, centering an element, or spreading cards across a row.
CSS Grid — aligning on two axes
Grid organizes children on rows and columns simultaneously : ideal for an image gallery, a dashboard, or any two-dimensional layout. The fr unit (fraction) distributes available space proportionally.
Flexbox or Grid ?
A single direction (row or column) → Flexbox. A two-dimensional grid (rows and columns) → Grid. In practice, the two are often combined on the same site.
Responsive design
A page must adapt to every screen size, from mobile to large displays.
Media query
A media query applies CSS rules only if a condition about the screen is true (width, orientation...). It's the heart of responsive design.
Mobile-first approach
In mobile-first, you write the style for small screens first, then add rules with min-width for larger screens — simpler to maintain than the reverse.
JavaScript — Making a page interactive
Variables, types, and control structures
The fundamentals of the language that runs in the browser.
let, const, var
| Keyword | Scope | Reassignable? |
|---|---|---|
const | Block { } | No |
let | Block { } | Yes |
var | Function (legacy, to avoid) | Yes |
Common rule : use const by default, and let only if the variable needs to change value. Avoid var in modern code.
Basic types
Conditions and loops
Syntax very close to the Python seen last semester, except for braces { } to delimit blocks (no mandatory indentation, though it remains good practice) and the semicolon at the end of a statement.
Functions
Grouping reusable code — in classic or arrow form.
Classic declaration
Arrow function
Introduced in ES6 (2015), arrow functions are widely used for short functions and as callbacks (e.g. : in addEventListener).
The DOM and events
Reading and modifying the page live, and reacting to user actions.
The DOM
The DOM (Document Object Model) is the representation of the HTML page as objects that JavaScript can manipulate. Modifying the DOM
Selecting an element
querySelector accepts any CSS selector (class, id, type...) and returns the first element found; querySelectorAll returns all matching elements.
Modifying content and style
Listening for an event
addEventListener(type, function) is the recommended way to listen for an event — it lets you attach multiple handlers to the same element. Common types : click, submit, input, keydown, mouseover.
The script must run after the HTML
If the <script> loads before the elements exist in the DOM, querySelector will return null. Solution : place the <script> just before </body>, or use the defer attribute on the <script> tag in the <head>.
The basics : fetching data (fetch)
An overview — enough to understand the principle, without going into advanced details.
fetch() — calling an API
fetch() sends an HTTP request from the browser's JavaScript and returns a Promise (a value available later). .then() processes the response once received; .catch() handles any network error.
Going further
The async/await syntax lets you write this same code in a more linear way, and modern frameworks (React, Vue...) build on these same foundations
Practice with mini-projects
Each exercise comes with an expandable correction — try it first, check afterward.
HTML
Structuring content with semantic tags.
Profile card
Create a page with a <header> tag (name + title), a profile picture, a short bio in <p>, a list of 3 skills in <ul>, and a <footer> with a contact link.
The roles are clearly separated : header for identity, main for the content, footer for contact — a clear semantic structure, even without a single line of CSS.
Contact form
A form with a name field, an email field, a message field, and a submit button. The name and email fields are required.
The required triggers native browser validation : submission is impossible without filling in these fields (no JavaScript needed for this
Grade table
A 3-column table (Subject, Grade, Coefficient) with 3 rows of data and one header row.
CSS
Styling and laying out elements with Flexbox and Grid.
Styling the profile card
Take the profile card from the HTML lab : light background, rounded corners, subtle shadow, 100px round image, max width
border-radius: 50% on a square image (equal width/height) produces a circle. object-fit: cover prevents the image from being distorted if its ratio doesn't match exactly.
Navigation bar with Flexbox
A horizontal bar : logo on the left, 3 menu links on the right, vertically centered.
justify-content: space-between pushes the first element to the left and the last to the right, with space distributed between them — the classic pattern for a
Responsive card grid
Display 6 cards in a grid : 3 columns on large screens, 1 single column on mobile (under 600px).
An even more flexible variant, without a media query : grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); — the grid automatically adjusts the number of columns based on available space.
JavaScript
Making the page interactive with the DOM and events.
Click counter
A button and a text showing "0". Each click increments the displayed counter.
count lives in the JavaScript (not in the HTML) : on each click, the variable is updated and the display is synced with textContent.
Simple form validation
Prevent a form from submitting if the email field is empty, and show an error message in that case.
event.preventDefault() prevents the form's default behavior (reload/navigate) to leave control to JavaScript. .trim() removes whitespace before checking whether the field is truly empty.
To-do list
An input field and an "Add" button : each added task appears in a list, and clicking a task strikes it through (done/not done
A new <li> element is dynamically created with document.createElement(), its own click listener is attached, then it's inserted into the list with appendChild() — the basic pattern for any content generated in JavaScript.
What to absolutely remember
box-sizing: border-box.min-width.const by default, querySelector to target, addEventListener to react.