TechnicalEasy HTML & CSS

How do you make a website responsive?

Asked for Frontend Developer, Full-Stack Developer

Why they ask this: Most users in Nepal browse on mobile phones, so responsive design is a must-have skill.

Answer

  1. Add the viewport meta tag: <meta name="viewport" content="width=device-width, initial-scale=1">.
  2. Design mobile-first: write base styles for small screens, then add min-width media queries for larger ones.
  3. Use flexible layouts (Flexbox, Grid with fr and minmax()) and relative units (%, rem, vw) instead of fixed pixel widths.
  4. Make media fluid: img { max-width: 100%; height: auto; }, and use srcset for different image sizes.
  5. Test on real devices and in the browser DevTools device mode.
css
.grid { display: grid; gap: 1rem; }

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

Can you explain this in your own words?

Back to question bank