web · Level 2
CSS: responsive layouts, grids and typography
Style the event page by hand so it reads well on a phone and a laptop, measure each result in a real browser, and learn to check CSS an AI assistant writes.

Start with the essentials
The short answer
Responsive CSS starts with a border-box model, custom properties for your choices, and layouts that adapt by themselves: flexbox for a line of items, grid for columns, and fluid type from clamp(). Add media or container queries only where needed, honour the reader's colour scheme, motion and text size, and keep a visible focus ring. Test at several widths, and check AI-written CSS the same way.
What you will learn
- You will be able to explain the box model and
box-sizing, and measure a box in the browser. - You will be able to predict which rule wins from the cascade order and specificity, and keep colours and spacing in custom properties.
- You will be able to build a flexbox row and a grid that chooses its own column count, and read its tracks in developer tools.
- You will be able to make type and layout adapt with
clamp(), media queries, container queries and logical properties, and say how well each is supported. - You will be able to honour colour scheme, reduced motion, focus visibility and contrast, naming the WCAG 2.2 criteria correctly.
- You will be able to review CSS that an AI assistant wrote and find its common faults by measuring.
Who it is for
People who have built the event page in the HTML workbook and want it to look good on a phone and a laptop, writing CSS by hand without a framework. You should be able to edit files in a plain text editor and open them in a browser.
Before you start
- The HTML workbook (build a meaningful, accessible page), or the finished Marigold Lane event page from it. A plain text editor and a desktop browser with developer tools. The tool names here are those of Microsoft Edge, and other browsers differ in detail. No JavaScript knowledge is needed: the few one-line Console checks are given in full.
Keep learning
The complete workbook
This workbook teaches CSS by hand, with no frameworks. You will extend a small invented event page with a box-model fix, custom properties, a flexbox header, a responsive grid of cards, fluid headings, a container query, a dark theme and reduced-motion and focus styles, measuring every result in a real browser at three widths. You will also learn to debug layout in developer tools and to review CSS written by an AI assistant.
- 01Every element is a boxIn the workbook · 1 exercise
Measure the boxes on the event page, and see why one line of CSS makes widths mean what they say.
- 02The cascade, specificity and custom propertiesIn the workbook · 1 exercise
When rules disagree the browser must pick one. Learn the real order, and keep your choices in custom properties.
- 03Flexbox and gridIn the workbook · 1 exercise
Flexbox lays items along one line, grid along rows and columns. Use each where it fits.
- 04Fluid type, media queries and container queriesIn the workbook · 1 exercise
Adapt the page without piles of breakpoints: text that scales, one media query, and a container query.
- 05Preferences, focus and contrastIn the workbook · 1 exercise
Readers choose a colour scheme and a motion level, and many use only a keyboard. Style for them, then check.
- 06Debugging layout, and reviewing AI-written CSSIn the workbook · 1 exercise
Learn the browser's tools, then use them on a stylesheet you did not write.
Also inside: a 10-point checklist, a glossary of 11 terms and 10 questions and answers to test yourself. 6 hands-on exercises, each with a worked answer at the back where the workbook gives one.
No login, no card, no account. Before the download we ask you to follow Mickai (two quick links). Free to download and use for personal learning, study groups and inside your own team. Please do not resell the workbooks or republish them as your own. Link people to trust-agent.ai instead.
Test yourself
Questions and answers
Why do I need box-sizing: border-box?
By default width sets only the content, and padding and border are added outside it, so a box is wider than the number you wrote. With border-box, width covers content, padding and border. In this workbook's test at 768 and 1280 pixels, the event page's main measured 704 pixels wide by default and 672 with it.
What is the difference between flexbox and grid?
Flexbox is one-dimensional: it arranges items along a row or a column and can wrap them. Grid is two-dimensional: you define columns and rows and place items in them. Use flexbox when the content decides the flow along one line, and grid when you want to decide the columns.
What does repeat(auto-fit, minmax(12rem, 1fr)) do?
It creates as many columns as fit, each at least 12rem wide and sharing any spare space equally. auto-fit collapses empty columns so few items stretch to fill the row, and auto-fill keeps them. Write min(12rem, 100%) for the minimum so a container narrower than 12rem cannot overflow.
Why is my CSS rule being ignored?
Usually another rule wins. Inspect the element: the Styles tab lists every matching rule with overridden ones marked, and hovering a selector shows its specificity. A higher-specificity selector beats a later one, and a later one beats an earlier one of equal score. A misspelt property is rejected by the browser.
Is !important always wrong?
It is a blunt tool. It outranks normal declarations whatever the selector, so overriding it needs another !important that wins on specificity or order, and stylesheets get harder to change. Fix the specificity or the order instead. An AI assistant that scatters it through a stylesheet is showing a warning sign.
Should I use media queries or container queries?
Use a media query when the page as a whole should change with the screen or a reader setting, such as colour scheme. Use a container query when a component should adapt to the space it is given, wherever it is placed. A card in a narrow column and in a wide one can then share one rule.
Can I use container queries yet?
Size container queries are widely supported. On 26 September 2026 caniuse listed them in Edge and Chrome 106 and later, Firefox 110 and later and Safari 16.0 and later, and marked them Baseline widely available. The W3C specification is still a Working Draft. Check the support tables again on the day you use them.
How do I make text scale with the screen and still respect zoom?
Use clamp(min, preferred, max) with a rem part in the preferred value, such as clamp(1.5rem, 1.1rem + 2.5vw, 3rem). A size in vw alone ignores the reader's text size setting, which WCAG's failure technique F94 warns against. MDN advises a maximum at least twice the minimum.
Do I still need vendor prefixes like -webkit-?
Rarely. Caniuse lists box-shadow and border-radius as Baseline widely available, so prefixed copies add nothing, and -moz-border-radius was rejected by Edge 153 in this workbook's test. Check a property's support table before adding any prefix, because a few prefixed forms still matter.
How do I check CSS an AI assistant wrote?
Treat it as a draft from a stranger. Run it through the Nu Html Checker, which caught the invented margin-x in this workbook's test but also reported valid container queries as errors. Then look for what it misses: fixed pixel widths, !important, prefixes, removed focus outlines and low contrast. Test at 360, 768 and 1280 pixels, find any overflow, press Tab, and try dark mode and reduced motion.
When you have finished
Get your certificate of completion
Type your name and download a certificate for this workbook as a PDF, ready to print or to add to LinkedIn. It is made on your own device, so your name is never sent to us. It is a self-declared certificate, not an accredited qualification.
Learn the language
Key terms
- CSS pixel
- The browser's unit of length,
px. It is a CSS unit, not a physical screen dot. - Box model
- How every element becomes a box of content, padding, border and margin, from the inside out.
- Cascade
- The rules by which the browser picks one winning declaration when several apply: origin and importance, then specificity, then order.
- Specificity
- A three-part score for a selector (IDs, then classes and attributes, then element names). Higher parts win first.
- Custom property
- A name starting with two hyphens, such as
--accent, that holds a value you reuse withvar(). - Flexbox
- A one-dimensional layout model that arranges items along a row or a column and can wrap them onto new lines.
6 of the workbook's 11 terms. The complete glossary is in the workbook.
Follow the evidence
Sources and checks
Facts last checked: .
Examples in this workbook were run on: Microsoft Edge 153.0.4234.48 (system install, headless) driven by Playwright 1.59.0 for Python 3.12.10 on Windows 11 Pro, at viewport widths of 320, 360, 768 and 1280 CSS pixels (no classic scrollbar; a classic one made the page area 15 pixels narrower); CSS checked with the W3C Nu Html Checker online service (checker version 26.9.16), through its file upload form and its JSON interface; caniuse support data read through caniuse.com on 2026-09-26 (2026-09-26).
These workbooks use AI assistance. See how the workbooks are made.
- CSS Cascading and Inheritance Level 5W3C
- Selectors Level 4W3C
- CSS Box Sizing Module Level 3W3C
- CSS Flexible Box Layout Module Level 1W3C
- CSS Grid Layout Module Level 2W3C
- CSS Values and Units Module Level 4W3C
- Media Queries Level 4W3C
- CSS Containment Module Level 3W3C
- CSS Custom Properties for Cascading Variables Module Level 1W3C
- Web Content Accessibility Guidelines (WCAG) 2.2W3C
- Understanding Success Criterion 1.4.4: Resize TextW3C Web Accessibility Initiative
- Understanding Success Criterion 1.4.11: Non-text ContrastW3C Web Accessibility Initiative
- Understanding Success Criterion 1.4.12: Text SpacingW3C Web Accessibility Initiative
- Understanding Success Criterion 2.4.7: Focus VisibleW3C Web Accessibility Initiative
- Understanding Success Criterion 2.4.11: Focus Not Obscured (Minimum)W3C Web Accessibility Initiative
- Understanding Success Criterion 2.3.3: Animation from InteractionsW3C Web Accessibility Initiative
- F94: Failure of Success Criterion 1.4.4 due to incorrect use of viewport units to resize textW3C Web Accessibility Initiative
- F78: Failure of Success Criterion 1.4.11, 2.4.7 and 2.4.13 due to styling element outlines and bordersW3C Web Accessibility Initiative
- C39: Using the CSS prefers-reduced-motion query to prevent motionW3C Web Accessibility Initiative
- C43: Using CSS scroll-padding to un-obscure contentW3C Web Accessibility Initiative
- The box modelMDN Web Docs
- box-sizingMDN Web Docs
- Using CSS custom properties (variables)MDN Web Docs
- Basic concepts of flexboxMDN Web Docs
- Basic concepts of grid layoutMDN Web Docs
- repeat()MDN Web Docs
- clamp()MDN Web Docs
- Using media queriesMDN Web Docs
- CSS container queriesMDN Web Docs
- CSS logical properties and valuesMDN Web Docs
- prefers-reduced-motionMDN Web Docs
- prefers-color-schemeMDN Web Docs
- color-schemeMDN Web Docs
- :focus-visibleMDN Web Docs
- Element: getBoundingClientRect() methodMDN Web Docs
- Window: getComputedStyle() methodMDN Web Docs
- <length> CSS type (including the rem unit)MDN Web Docs
- CSS features reference (DevTools)Microsoft Learn, Microsoft Edge developer documentation
- Inspect CSS Grid layoutsMicrosoft Learn, Microsoft Edge developer documentation
- Inspect and debug CSS container queriesMicrosoft Learn, Microsoft Edge developer documentation
- Emulate mobile devices (Device Emulation)Microsoft Learn, Microsoft Edge developer documentation
- Console overviewMicrosoft Learn, Microsoft Edge developer documentation
- Run JavaScript in the Console (Allow pasting into the Console)Microsoft Learn, Microsoft Edge developer documentation
- CSS Container Queries (Size), support table read on 2026-09-26caniuse
- CSS3 Box-shadow, support table read on 2026-09-26caniuse
- CSS3 Border-radius, support table read on 2026-09-26caniuse
- Nu Html Checker (web service)W3C
Created by Mickarle Wagstaff-Irons - Micky Irons with the Mickai team. Published by Mickai LTD. Last updated 26 September 2026.
NextKeep going
Where to go next
Recommended for you
Build and launch a website with AI
Plan a simple site, have AI write the HTML and CSS, understand and check the code, then publish it free with HTTPS and sound search, accessibility and privacy basics.
Recommended for you
Build your first app with an AI coding assistant
Build a small bill-splitting web page with any AI coding assistant while staying in control: brief it, build in steps, review the code, test edge cases and keep safe copies.