Skip to content

Responsive Layout Broken

Quick summary

Your page does not adapt correctly to different screen sizes — content overflows, elements are too small, or the layout breaks.

Why this happens

  • Missing viewport meta tag

  • Fixed pixel widths instead of relative units

  • Media query breakpoints are incorrect or missing

  • Images without max-width: 100% overflow their containers

Minimal example

✗ Broken code
<!-- Missing viewport meta tag -->
<head>
  <title>My Page</title>
</head>
<body>
  <div style="width: 1200px;">Fixed width overflows mobile</div>
</body>
✓ Fixed code
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My Page</title>
</head>
<body>
  <div style="max-width: 1200px; width: 100%;">Responsive width</div>
</body>

The viewport meta tag is essential for responsive design on mobile. Fixed widths overflow — use max-width with width: 100% instead.

How to diagnose

  • Check for the viewport meta tag in the <head>

  • Test in DevTools device emulation at different widths

  • Look for fixed-width elements that overflow on small screens

  • Verify media query breakpoints match your design specs

How to fix

  • Add <meta name='viewport' content='width=device-width, initial-scale=1'>

  • Use relative units (%, fr, rem, vw/vh) instead of fixed px

  • Add or adjust media queries for problematic screen sizes

  • Add max-width: 100% and height: auto to images

How to prevent

  • Always include the viewport meta tag

  • Use a mobile-first approach with min-width media queries

  • Test at common breakpoints (320px, 768px, 1024px, 1280px)

Related Resources

Related Glossary

Related Lessons

← Back to language