Imagine you have two screens:
- they have the same resolution
- they are oriented in the same way
- but they have different physical sizes
For example:
https://i.sstatic.net/OcMnt.png
How can I style for different screen sizes using CSS media queries?
For instance:
- on a 1920px wide display, long lines of text extending edge-to-edge may be difficult to read, prompting the need for padding, margin, or spacing to make it more legible
- however, on another 1920px wide display, having text go edge-to-edge might be preferred
Bonus Talk
Don't try to rely on User-Agent
strings:
- I'm specifically addressing CSS media queries, not User-Agent strings
- the 4" screen could be connected to a PC
- the 18" screen could be connected to a phone.
Also, avoid diverting from the question by discussing orientation, whether the screen supports touch input or not, or using the handheld
attribute
The focus is on utilizing CSS to design a page based on the (physical) size of the screen.
Bonus Reads
- Determining mobile device usage through browsers (iOS/Android) (relies on resolution)
- Targeting desktop, tablet, and mobile with Media Queries (focuses on resolution)
- Constructing a Mobile Website
- Using CSS3 Media Queries to Establish a Mobile Version
- Implementing Responsive Design with Media Queries in 2018
- Determine the ideal media query breakpoints to use (based on resolution) ("breakpoints" refer to "pixels")
- Media Query for Large Desktop Displays
- CSS media queries for handheld and larger browser screens
- Media query focused on screen size rather than resolution