SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Welcome to CSS
Responsive LayoutsMedia QueriesContainer QueriesResponsive Content and TestingResponsive ImagesUser PreferencesResponsive Testing Adapting a layout to the space available
Responsive Design

Responsive Layouts

Choose whether wrapping, flexible tracks, or a conditional rule should respond to a change in available space.

A layout can look comfortable on a wide screen and crowd its labels when the same page is narrower. Responsive design starts by locating the first piece of content that runs out of room.

Let the layout respond first

A paragraph can wrap as its containing block narrows. Flexbox can move a control onto another line, and Grid can fit fewer columns when the minimum track widths and gaps no longer fit. These behaviors follow from the layout rules you already know. They also work when a narrow sidebar shares a wide screen with the main article.

Watch a row of controls as you narrow its container. If a whole control can move onto the next line and remain easy to read, wrapping can solve the problem by itself. If the controls must change from a row to a full-width stack, decide where that arrangement becomes necessary.

Decide what to measure

The width at which a conditional layout changes is a breakpoint. Pick it by looking at the content. A longer label or larger text can expose a problem between two familiar device widths.

A width media query tests the viewport, the area available for the page. It fits a decision about the whole page, such as making room for a second main column. A size container query tests an eligible ancestor. It fits a card that needs a compact arrangement in a sidebar even when the viewport stays wide.

Key Takeaways

  • Resize the actual content to discover where its layout becomes difficult to use.
  • Match the measurement to the decision. The page and an individual component can have different amounts of room.

Try it yourself

Try it yourself

Wrap a row of controls

Preview width

HTML + CSS

Loading code editor…

Live preview

Updating…

Final output

No comparison yetChecks after 3s without edits
Loading your draft…

How is this lesson?

Previous lesson Placing items on a gridNext lessonMedia Queries
Edit on GitHubReport on GitHub
On this page
%

On this page

Let the layout respond firstDecide what to measureKey TakeawaysTry it yourself