Responsive layout is more than fitting boxes into a narrow viewport. The reading order, keyboard order, labels, and primary action must still make sense when columns collapse. Start with semantic HTML in the order a person should read it, then use CSS to place regions side by side when space allows. The DOM order remains the accessibility and keyboard baseline even if CSS paints elements elsewhere. Avoid a mobile menu that contains the only route to a case when its script fails. The snippet uses a simple grid that becomes two columns only when width allows, while the form and case details remain in one continuous document order.
Responsive interaction: preserve content and control order
Case study
An inspector opens case 47 on a phone. The case summary appears before the update form, matching the desktop reading order. At a wide viewport, CSS places the two sections side by side; it does not move the form ahead of the summary in the DOM. The submit button remains visible and usable through touch, keyboard, and script-free form submission. A fixed-width panel would force horizontal scrolling, while using CSS order to visually reverse controls could confuse a keyboard user whose focus still follows document order.
Working contract
<main class="case-layout">
<section aria-labelledby="case-title">
<h1 id="case-title">Case 47</h1>
<p>The service valve needs a second review.</p>
</section>
<form action="/inspections" method="post">
<label for="review-note">Inspection note</label>
<textarea id="review-note" name="note" required></textarea>
<button type="submit">Save note</button>
</form>
</main>
<style>
.case-layout { display: grid; gap: 1.5rem; }
@media (min-width: 52rem) {
.case-layout { grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); }
}
</style>Cost and tradeoffs
CSS grid layout cost grows with the number and complexity of elements being laid out, not just the media query count. This example has two regions, so the layout work is small; a page with hundreds of cards should inspect style and layout timing rather than assume a breakpoint is the bottleneck. A second mobile-only DOM copy doubles content and can create duplicate IDs or inconsistent form state. Keep one semantic source and test narrow, wide, zoomed, and keyboard views. CSS cannot repair a control missing from HTML.
Common Mistakes
- Do not visually reverse controls while leaving a contradictory keyboard order.
- Do not duplicate the whole form for a mobile breakpoint.
- Do not make a script-only menu the sole path to an important page.
- Do not solve overflow by clipping essential text or controls.
Continue through the stack
Responsive CSS: keep reading order and controls usable; HTML forms: choose GET for retrieval and POST for a state change; Accessible forms: connect labels, errors, and focus.
Failure trace
A filter panel fits on a wide monitor but becomes a fixed overlay on a narrow phone. The Apply button falls below the viewport, and keyboard focus moves behind the overlay. Shrinking text does not repair the interaction. Let controls reflow in source order, test touch targets and focus, and ensure the same task can finish at narrow widths without horizontal scrolling.
Verification
- Complete the case filter at a narrow viewport using only keyboard navigation.
- Increase text size and confirm labels and buttons remain visible without clipping.
- Open and close the panel on a touch device and check that focus returns to the trigger.
Decision note
Responsive behavior is a task contract, not a screenshot width. Fewer columns can reduce layout complexity, but hiding essential controls behind several taps adds interaction cost that needs user testing.
Further connections
Reflow, Zoom, and Motion Preferences; Right-to-Left and Mixed-Direction Content.
Further connections
Grid, Flex, and Intrinsic Size Contracts; Container Queries for Reusable Panels.
