🔗

JS + HTML/CSS Integration

Practice real interactive features: theme toggles, modals, accordions, tab switchers, validators, carousels, and a Sukuma price calculator. JS that mutates HTML and toggles CSS classes.

1

Why JS + HTML + CSS Together

Real interactive features are never JS alone — they are JS that mutates HTML and toggles CSS classes. See why the three languages dance together on every page you actually use.

2

Build a Theme Toggle

The 'flip a class on body, let CSS variables do the rest' pattern. Build a working light/dark toggle and watch the whole page change with one click.

3

Build an Accordion

An accordion is the FAQ pattern: click a heading to expand the answer below it. You will use class toggles, aria-expanded, and a click handler.

4

Build a Tab Switcher

Tabs share the same visual area but show different content. Use event delegation to wire all tabs in a single listener — the technique scales to dozens of tabs without slowing down.

5

Build a Modal Dialog

Combine the modal layout you built in CSS Positioning with JavaScript that opens it and — crucially — closes it. Two listeners, one bug to fix.

6

Build a Live Form Validator

React to typing in real time — show errors as the user types, not after they submit. The pattern: input event → validate → toggle an error class.

7

Build an Image Carousel

Track an index in JavaScript, mutate transform: translateX in CSS. Build a smooth slide carousel with prev/next buttons.

8

Build a Sukuma Price Calculator

The same vegetable, two units. Build a calculator that switches between Per kg and Bunch pricing and recomputes the total whenever the user changes anything.

9

Build a Styled Todo List

Create a todo list where completed items get visually marked — strikethrough and faded. Bridges JS DOM creation to CSS state classes.

10

Capstone: A Mini Market Dashboard

Stitch the price calculator, theme toggle, and a styled cart accordion into a single small dashboard. The pattern of every real frontend.

11

Codelab: A Three-File Tabs App

Step out of the platform and build a real multi-file project: index.html, styles.css, and app.js. Ship a working tabbed settings page with proper file separation.