Mobile-First

Mobile-First CSS

Write the base styles for small screens first, then add min-width media queries for larger screens. Phones then download and apply the least CSS, and layouts naturally grow instead of being squeezed.

/* base: phones */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* tablets */
@media (min-width: 600px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

/* desktops */
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

Checklist

  1. Add <meta name="viewport" content="width=device-width, initial-scale=1">.
  2. Use relative units and max-width instead of fixed widths.
  3. Images: max-width: 100%; height: auto;.
  4. Make tap targets at least 44×44px.
  5. Test with DevTools device mode and on a real phone.