Just because I have a vertical screen, doesn't mean I'm on a phone!


I'm a weirdo - I fully admit that. As part of my home working set up, I use a vertical monitor. I read and write a lot of long documents - and this form factor suits me perfectly.

Vertical Screen showing YouTube.

I've been doing this for a long time. It is a natural part of my workflow. For anything longer than an email, it's the perfect orientation. Most Linux apps work just fine like this - although menu buttons tend to hide behind overflows.

Websites though, ah! That's where the problem begins. Lots of websites think "Vertical Screen == Mobile User"!

This is a minor problem - and one of my own making - but I thought it worth explaining the problems it brings, why it occurs, & how to stop it.

Examples

Here are some typical websites viewed on my 24″ vertical monitor. On the left if how it renders, and on the right how it should render.

The Just Eat website.

Guardian News website.

Popular science website.

Problems

Generally, there are several problems I encounter:

  • Navigation is hidden behind a burger / ☰ menu.
  • Some elements, like carousels, only work with touchscreen controls.
  • Images are served as low resolution, for 6 inch screens and then blown up to 24 inches.
  • Lots of wasted space taken up with "hero images" and finger-friendly buttons.
  • Some content simply not available to mobile users.

Why this occurs

My monitor's native resolution is 1080x1920. But I find the fonts slightly too small at that resolution - given how far I sit from the screen. I use Pop_OS Linux, which lets me scale the fonts rather than the screen resolution.

Gnome Tweaks screenshot showing a font scaling factor.

A scale factor of 1.5 translates to an effective screen resolution of 720x1280.

User Agent "sniffing" is considered an antipattern and is discouraged. So most websites don't bother to check if I'm browsing on an iPhone or Android, instead, they use JavaScript or CSS to get my screen resolution.

They - somewhat reasonably - see a 720p screen in a vertical orientation and assume it is a small screen device.

How to tackle this (user side)

Zoom out! That's the obvious answer. If I hit CTRL+- 3 times, my resolution becomes 1080x1920. But that can leave some sites too small to read properly. I need to zoom out the page, and zoom in the font.

I have tried "Fractional Scaling" - it works OK on Wayland, but leaves all the fonts looking soft and fuzzy.

So I've set my font scaling to 1.36, which gives me a resolution of 864x1536 - which is enough to stop most sites assuming I'm on a tiny mobile phone.

But this shouldn't be my problem to solve.

How to tackle this (website side)

STOP NAÏVELY USING SCREEN RESOLUTION!

OK, there's no way to get the physical size of a user's screen. That functionality just doesn't exist in either JavaScript or CSS.

But you can get the Dots Per Inch (DPI). Well, sort of...

CSS allows you to get the DPI of the screen.

If I go to Lea Verou's https://DPI.lv/ I see that my monitor's resolution is correctly detected as 1080x1920! No matter what zoom level or font scaling I use - it is always the correct resolution.



var dppx = window.devicePixelRatio;
var screenWidth  = screen.width  * dppx;
var screenHeight = screen.height * dppx;

That's how you get the real resolution, unencumbered by whatever the OS is doing to the scaling.

If I go to a different DPI detector, I can see exactly how many pixels there are per inch. My vertical monitor is detected as 120px/inch.

This isn't quite right. And different browser engines calculate this differently. On Linux, I got these results with the three main rendering engines:

Chrome: 5.14px/mm.
Firefox: 4.73px/mm.
Webkit: 3.78px/mm.

When I physically measure the screen, it's about 3.62px/mm!

Obviously that's not incredibly accurate - but it is useful in giving a web developer a rough idea of physical screen size.


Share this post on…

10 thoughts on “Just because I have a vertical screen, doesn't mean I'm on a phone!”

  1. This applies to ultrawide monitors too, if you have three windows set up (which is what the default is w/ powertool on Windows), you’ll get the mobile sites for Facebook, YouTube etc. on the left and right windows

    Reply | Reply on twitter.com
  2. Daemon says:

    Nice. I'm trying to decide on the best vert screen to buy. Which one are ya using?

    Reply
  3. That certainly does not work in every case.

    dpi.lv detects my 16" Macbook Pro as 3584x2240. Real resolution unscaled 3072 x 1920 (you can't even use that resolution, max apple allow is 2048x1280 - so it looks sharper/retina). I am using 1536x960, otherwise, the image is too small.

    Also, my external monitor, which is 4K, is being detected as 6K (6016x3384). Perhaps because I scaled the 4K image to 3K (3008x1692) so text is sharper and not too small, so it's detecting twice as that?

    Same thing for the Mac screen. It's detecting double my resolution.

    I've run your formula and I think I found out why. Apple seems to be correcting the screen.width to the correct value. I get 1792 which is my correct width. window.devicePixelRatio is 2, so thus why I get 3584x2240 (twice of what I have)

    I hear your complain, but I think the only way to play with websites is doing what apple is doing. Correcting screen.width and screen.height depending on how you scale your monitor. And the fact that it breaks for all apple hardware, is also a clue that this can't be used and apple seems to be correctly informing proper width, height and devicePixelRatio.

    Reply
  4. Christopher Salisbury says:

    Thanks for sharing! Great information for me to consider in my web app development! This is the first thing I've ever read about looking at DPI for responsive design.

    Reply
  5. I've ranted about "don't use viewport size as a proxy to guess other things, such as 'touch only' (which nowadays is meaningless anyway, as you can have keyboard/mouse paired even with a nominally 'touch only' phone), slow network connection, etc" for aeons. There are now much better/cleaner APIs to determine those aspects.

    However, in terms of layout decisions, I'd say that "it depends". The approach of making a decision of how best to use the available viewport space should be driven by the nature of the content, and what the designer thinks is the best use of the space. I personally have no problem with layout adapting to a more "vertical/portrait aspect" friendly approach, as long as it's well considered.

    On the "getting the actual real screen size", beware also that this doesn't take into account expected/average viewing distance - so yes, it might detect that you're in fact using an enormous 50" screen...but it won't be able to tell you that it's wall mounted and 5 metres away from the user - which is what in an ideal world the CSS reference pixel should all paper over, since it assumes that dpi, scaling, etc have been set so that 1 CSS px is set to a roughly standardised visual angle for the average/expected viewing distance ... something I ranted about aeons ago when "web on tv" was still supposedly a thing https://patrickhlauke.github.io/web-tv/ideal-viewport/index.html

    So once again, taking this with a grain of salt.

    Reply

Trackbacks and Pingbacks

  1. من یک فرد عجیب و غریب هستم – که کاملاً اعتراف می کنم. به عنوان بخشی از کار من در خانه ، من از یک مانیتور عمودی استفاده می کنم. من بسیاری از اسناد طولانی را می خوانم و می نویسم – و این فاکتور کاملاً مناسب من است.

    من این کار را انجام داده ام برای مدت طولانی. این یک قسمت طبیعی از روند کار من است. برای هر چیزی بیشتر از یک ایمیل ، این یک جهت عالی است. اکثر برنامه های لینوکس دقیقاً مانند این کار می کنند – اگرچه دکمه های منو در پشت سرریز پنهان می شوند.
    وب سایت‌ها هر چند ، آه! از آنجاست که مشکل آغاز می شود. بسیاری از وب سایت‌ها فکر می کنند “صفحه عمودی == کاربر موبایل”!
    این یک مشکل جزئی است – و یکی از ساخته های خودم است – اما فکر کردم ارزش توضیح دادن مشکلاتی را که ایجاد می کند ، دلیل بروز آن و چگونگی متوقف کردن آن است.
    مثال‌ها
    در اینجا برخی از وب سایت های معمولی مشاهده شده در مانیتور عمودی 24 my من وجود دارد. در سمت چپ اگر نحوه ارائه آن است ، و در سمت راست چگونه آن را ارائه می دهد باید ارائه دادن.

    چالش ها و مسائل
    به طور کلی ، چندین مشکل وجود دارد:
    پیمایش در پشت منوی burger / is پنهان است.
    برخی از عناصر مانند چرخ فلک فقط با کنترل های صفحه لمسی کار می کنند.
    تصاویر به عنوان وضوح پایین برای صفحه نمایش های 6 اینچی ارائه می شوند و سپس تا 24 اینچ دمیده می شوند.
    فضای زیادی که با “تصاویر قهرمان” و دکمه های انگشت دوستانه اشغال شده است.
    برخی از مطالب به راحتی در دسترس کاربران تلفن همراه نیست.
    چرا این اتفاق می افتد
    وضوح تصویر مانیتور من 1080 × 1920 است. اما فونت ها را در این رزولوشن کمی کوچک می دانم – با توجه به فاصله من از صفحه. من از Linux_Pop_OS استفاده می کنم که به من امکان می دهد تا قلم ها را به جای وضوح صفحه مقیاس بندی کنم.

    ضریب مقیاس 1.5 به وضوح صفحه نمایش موثر 720 × 1280 تبدیل می شود.
    نماینده کاربر “استشمام” یک الگوی ضد الگویی در نظر گرفته می شود و دلسرد می شود. بنابراین اکثر وب سایت ها به خود زحمت نمی دهند که آیا من در iPhone یا Android مرور می کنم یا نه ، در عوض ، آنها از JavaScript یا CSS برای دریافت وضوح صفحه من استفاده می کنند.
    آنها – تا حدی منطقی – یک صفحه 720p را با جهت عمودی مشاهده می کنند و تصور می کنند که این یک صفحه نمایش کوچک است.
    نحوه مقابله با این (سمت کاربر)
    کوچک نمایی! این پاسخ واضح است. اگه بزنم CTRL+- 3 بار ، رزولوشن من 1080 × 1920 می شود. اما این امر می تواند برخی سایت ها را برای خواندن صحیح بسیار کوچک کند. من باید صفحه را کوچک کرده و فونت را بزرگنمایی کنم.
    من “مقیاس کسری” را امتحان کرده ام – روی Wayland بسیار خوب عمل می کند ، اما تمام قلم ها را نرم و مبهم نشان می دهد.
    بنابراین مقیاس بندی قلم خود را روی 1.36 تنظیم کرده ام ، که به من رزولوشن 864 × 1536 می دهد – این کافی است تا تصور کنم که تلفن همراه کوچکی دارم بیشتر سایت ها را متوقف کند.
    اما این نباید مشکل من برای حل باشد.
    نحوه مقابله با این (سمت وب سایت)
    با استفاده از وضوح صفحه نمایش به راحتی عمل کنید!
    خوب ، راهی برای دریافت آن وجود ندارد فیزیکی اندازه صفحه کاربر این قابلیت فقط در JavaScript یا CSS وجود ندارد.
    اما می توانید نقاط در هر اینچ (DPI) را دریافت کنید. خوب ، نوعی …
    CSS به شما امکان می دهد DPI صفحه را بگیرید.
    اگر من به Lea Verou’s بروم https://DPI.lv/ می بینم که وضوح مانیتور من به درستی 1080 × 1920 تشخیص داده شده است! مهم نیست که از چه سطح بزرگنمایی یا مقیاس قلم استفاده می کنم – این همان است همیشه وضوح صحیح
    var dppx = window.devicePixelRatio;
    var screenWidth = screen.width * dppx;
    var screenHeight = screen.height * dppx;

    اینگونه است که واقعی وضوح ، بدون هرگونه کاری که سیستم عامل برای مقیاس گذاری انجام می دهد ، بدون بار است.
    اگه برم یک ردیاب DPI متفاوت، دقیقاً می بینم که هر پیکسل چند پیکسل دارد. مانیتور عمودی من به اندازه 120 پیکسل در اینچ تشخیص داده می شود.
    این نیست کاملا درست. و موتورهای مختلف مرورگر این را متفاوت محاسبه می کنند. در لینوکس ، این نتایج را با سه موتور اصلی ارائه دادم:
    کروم: 5.14 پیکسل در میلی متر
    Firefox: 4.73px / mm.
    وب کیت: 3.78 پیکسل در میلی متر
    وقتی صفحه را از نظر جسمی اندازه می گیرم ، تقریباً 3.62 پیکسل در میلی متر است!
    بدیهی است که این فوق العاده دقیق نیست – اما در دادن یک توسعه دهنده وب مفید است خشن ایده اندازه صفحه فیزیکی.

    Just because I have a vertical screen, doesn’t mean I’m on a phone!

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre> <p> <br> <img src="" alt="" title="" srcset="">