What is the viewport meta tag and what does width=device-width, initial-scale=1.0 do?

This tests mobile viewport behavior and CSS pixels. The tag instructs browsers how to size the viewport; width=device-width sets width to screen CSS pixels; initial-scale=1.0 sets a 1:1 zoom ratio. A red flag is confusing viewport width with physical pixels.
What's really being asked
This question tests whether you understand how mobile browsers construct the layout viewport and the difference between CSS pixels and physical hardware pixels. Interviewers want to see that you know why a desktop-optimized site shrinks to fit on a phone without this tag, and how the viewport meta tag gives the browser explicit sizing instructions.
The full answer
A strong answer hits four things in order. First, state that the meta viewport tag tells mobile browsers how to size the viewport and scale the page. Second, explain that width=device-width sets the viewport width equal to the device screen width measured in CSS pixels, not physical pixels, which establishes the value of the vw unit. Third, explain that initial-scale=1.0 defines a one-to-one ratio between the device width and the viewport size, meaning the page loads at 100 percent zoom with no initial scaling. Fourth, mention that these two values together prevent the browser from assuming a default desktop-width viewport and zooming the page out to fit.
The mistakes people make
The biggest red flag is confusing device-width with physical screen pixels. Another common mistake is saying the tag is only for responsive design without explaining the scaling relationship. Some candidates also omit initial-scale entirely or claim it controls user zoom permissions, which is actually handled by user-scalable, maximum-scale, and minimum-scale. Finally, avoid stating that the tag is optional on modern sites; without it, mobile browsers default to a desktop-width viewport and scale down.
What usually comes next
An interviewer might ask what happens if you omit the viewport meta tag on a mobile device. They might also ask about the accessibility implications of setting user-scalable to no, or how interactive widgets like virtual keyboards affect the viewport via the interactive-widget property. Another common follow-up is asking for the difference between the visual viewport and the layout viewport.
A concrete example
Consider a smartphone with a 390 CSS pixel wide screen in portrait mode. Without the viewport meta tag, the browser might assume a 980 pixel wide layout viewport and scale the entire page down so it fits on screen, making text unreadable. Adding width=device-width tells the browser to set the layout viewport to 390 CSS pixels wide, so your CSS media queries and percentage widths map directly to the screen. Adding initial-scale=1.0 ensures the page renders at a one-to-one zoom ratio immediately on load, so a 16px font appears at the intended physical size relative to the device.
Interview question
On a smartphone with a 390 CSS pixel wide screen, how does the viewport meta tag with width=device-width and initial-scale=1.0 affect rendering?
- a.The browser assumes a 980px desktop viewport and scales the page down to fit the screen.
- b.The tag makes the page responsive by resizing elements without CSS media queries.
- c.The viewport matches the physical hardware pixel width and disables user zoom.
- d.The layout viewport is set to 390 CSS pixels and the page loads at 100% zoom.Correct
Why? this is the answer
width=device-width sets the layout viewport to the screen width in CSS pixels (390), and initial-scale=1.0 loads the page at 100% zoom. Option A describes what happens without the tag, while Option C confuses CSS pixels with physical pixels and incorrectly attributes zoom locking to initial-scale.
Just read this? Test yourself on what you have been reading.
Read the original → developer.mozilla.org
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles