liveBook · Manning

Chapter 7: Responsive design

What you will learn in chapter 7 of CSS in Depth, Second Edition

The chapter introduces responsive design as a way to make one website work across devices and identifies its three guiding principles.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces responsive design as a way to make one website work across devices and identifies its three guiding principles.

Key terms: responsive design, viewport size, mobile-first approach, @media at-rule, media queries, fluid layouts

7.1 Mobile first

This section explains why responsive design starts with a mobile layout and shows how content order and shared HTML can support larger-screen designs.

Key terms: mobile first, progressive enhancement, main content, sidebar, screen reader, HTML, nav-menu, main, column, breakpoint

7.1.1 Creating a mobile menu

This section builds a mobile navigation menu and explains its layout, toggle behavior, accessibility, and usability tradeoffs.

Key terms: <nav>, <header>, menu-toggle, containing block, absolute positioning, landmarks, display: none, menu-dropdown, is-open, JavaScript

7.1.2 Adding the viewport meta tag

This section explains why a mobile design needs a viewport meta tag and how its settings affect page width and zoom.

Key terms: viewport meta tag, device-width, initial-scale, width=320, user-scalable=no, zoom

7.2 Media queries

This section explains how media queries conditionally apply responsive styles, how those styles interact with the cascade, and how units and breakpoints affect their behavior.

Key terms: media query, @media, min-width, viewport, cascade, selector specificity, source order, px, em, rem

7.2.1 Understanding types of media queries

This section explains how to combine media-query conditions and use different features, ranges, preferences, and media types to adapt page styles.

Key terms: and, comma, or, media feature, min-width, max-width, orientation, resolution, pointer: coarse, range syntax

7.2.2 Adding breakpoints to the page

This section shows how to add mobile-first breakpoints and use a medium-width breakpoint to adjust spacing and turn a mobile dropdown into a persistent horizontal menu.

Key terms: mobile-first, min-width, breakpoint, media query, selector specificity, override, max-width, dropdown, static positioning, Flexbox

7.2.3 Adding responsive columns

This section shows how to introduce columns at a suitable breakpoint and keep responsive styles manageable.

Key terms: media query, breakpoint, grid container, normal document flow, 650 px, columns, custom properties, media query blocks, grid columns, grid rows

7.3 Fluid layouts

This section explains how fluid containers and columns preserve a page’s ability to fit different viewport widths.

Key terms: fluid layout, liquid layout, fixed layout, viewport, main page container, percentage, flex-grow, flex-shrink, responsive by default, block-level elements

7.3.1 Adding styles for a large viewport

This section adds a large-viewport breakpoint while keeping the page fluid and using the extra space for more generous padding.

Key terms: breakpoint, containers, grid, three-column portion, (min-width: 800px), media query, padding, .page-header, .hero, main

7.3.2 Dealing with tables

This subsection explains why wide tables are difficult on mobile screens and describes a block-layout fallback when the data must remain a table.

Key terms: fluid layouts, tiles, visual graph or chart, display: block, max-width media query, <thead>, display: none, screen reader

7.4 Responsive images

This section explains why responsive images need attention to both screen fit and download size.

Key terms: bandwidth limitations, well compressed, Save for Web, resolution, viewport size, scaled down

7.4.1 Using multiple images for different viewport sizes

This subsection explains why serving different image resolutions at different viewport sizes can reduce downloads without a visible change.

Key terms: resolution, media queries, breakpoint, hero image

7.4.2 Using srcset to serve the correct image

Explains how srcset lets browsers choose an appropriate HTML image and how to keep images within a fluid layout.

Key terms: srcset, src, pixel density, fluid layout, max-inline-size

7.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 6: Positioning and stacking contexts Chapter 8: Cascade layers and nesting →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.