Width vs Viewport

suggest change

When we are using “width” with media queries it is important to set the meta tag correctly. Basic meta tag looks like this and it needs to be put inside the <head> tag.

<meta name="viewport" content="width=device-width,initial-scale=1">

Why this is important?

Based on MDN’s definition “width” is

The width media feature describes the width of the rendering surface of the output device (such as the width of the document window, or the width of the page box on a printer).

What does that mean?

The width media feature uses CSS pixels of the layout viewport, not the screen's physical pixel count. A desktop window can be narrower than the monitor. On a phone, several physical pixels often make up one CSS pixel.

For example, the iPhone 6 Plus has a 1242 × 2208 physical resolution, but its CSS viewport is 414 × 736. Three physical pixels correspond to one CSS pixel.

Without a viewport meta tag, mobile browsers often lay the page out on a wide default viewport (commonly about 980px) and scale it down, which makes text and images look small.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents