Skip to article content
FrontendXLesson 26 / 30

Intrinsic and responsive layout patterns

Build semantic, accessible and responsive interfaces from a blank page, and explain why each layout and styling decision works.

advanced · about 40 minutes · 2 exercises

  • Explain
  • Implement

What you will be able to do

#
  • Build layouts that adapt without explicit breakpoints.
  • Choose between auto-fit, minmax and flexible content sizing.

Overview

#

Intrinsic layout uses the content and the available space to decide the arrangement, so fewer breakpoints are needed. The most useful primitive is a grid that fits as many columns as it can:

snippet.css
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 1rem;
}

The min(240px, 100%) guard prevents overflow on very narrow screens where 240px is wider than the viewport. auto-fit collapses empty tracks so items stretch to fill the row, while auto-fill keeps empty tracks and leaves gaps. Choose auto-fit when you want items to grow, and auto-fill when you want a stable column count.

A second primitive is the sidebar pattern, where a fixed-ish sidebar and a flexible main area share a row until space runs out. Flexbox with wrapping and a flexible basis does this without a media query:

snippet.css
.with-sidebar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.with-sidebar > .sidebar { flex: 1 1 16rem; }
.with-sidebar > .main { flex: 999 1 32rem; }

The large flex-grow on main makes it absorb the remaining space, and the flex-basis values set the wrap threshold. When the combined basis exceeds the container, the items wrap into a column. This is sometimes called the Every Layout sidebar pattern.

Intrinsic patterns complement breakpoints rather than replacing them. Use intrinsic sizing for the parts that should always adapt, and reserve explicit media queries for structural changes that content alone cannot express, such as moving a navigation bar from the top to a side rail.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Implement

    Write a sidebar layout that sits side by side when there is room and stacks when there is not, with a flexible main area.

    starter.css
    .layout { /* add flex layout */ }

    Reveal the reference answer
    reference.css
    .layout {
      display: flex;
      flex-wrap: wrap;
      gap: 1.5rem;
    }
    .layout > .sidebar { flex: 1 1 16rem; }
    .layout > .main { flex: 999 1 32rem; }

    Authored expected output: A sidebar and main area that share a row when space allows and wrap to a column when it does not.

    Wrapping plus a large flex-grow on main produces the sidebar pattern without a media query.

  2. Exercise 2Explain

    Explain the difference between auto-fit and auto-fill in a responsive grid.

    Reveal the reference answer
    reference.text
    Both create as many tracks as fit. auto-fill keeps the empty tracks, so items do not stretch to fill the row. auto-fit collapses empty tracks, so the remaining items stretch to fill the available space.

    Authored expected output: An explanation that names track collapsing as the difference.

    The choice changes whether a partially filled row stretches its items.

Common misconceptions

#
  • auto-fit and auto-fill behave identically.
  • Intrinsic layouts remove the need for any media queries.

Follow-up practice

#
  • html-css-27-cascade-layers

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.