Wednesday, June 30th, 2010p>The Web used to be so simple. Browser request goes to server, where you do some work, and return some HTML. Then we got Ajax and finally web apps could have some semblance of UI responsiveness. Now we have richer HTML5 technologies to change expectations of our users once again.
The Web is getting some new DPI love, and the new iPhone 4 display personifies this fact. The new display is fantastic for the consumer, and an opportunity for the design enlightened to build truly beautiful web sites. There is a big difference:
However, how do we as developers deal with this new world?
Aral Balkan has a nice post that goes into detail on the new opportunity and shares samples and ideas.
As with so many things on the Web, some of this has been thought of a loooong time ago. Dave Hyatt wrote about this back in 2006.
Walt Dickinson put together a guide to the retina display and using CSS3 media queries:
- <link rel="stylesheet"
- media="only screen and (-webkit-min-device-pixel-ratio: 2)"
Aral explains that “in the Retina-specific CSS, he loads in 32×32 icons as background images and specifies their dimensions in CSS pixels as 16×16 using the background-size CSS property.”
It is interesting to see a device pixel ratio used rather than specifying a DPI itself.
What else can be done to help folks in this new world?
Aral talks about how the browser could natively help via convention:
I’d like to suggest that browsers adopt the same naming convention that Cocoa Touch uses to find and load high-DPI versions of image and video assets. That is, if I embed an image using the following code…HTML4< view plain text >
- <img src="flower.jpg" alt="A beautiful rose"/>
… it should load in flower.jpg when the device-pixel-ratio is 1 but it should attempt to find an image called email@example.com at the same relative path if device-pixel-ratio is 2 (and so on, for higher pixel-ratios), falling back to the original graphic if it can’t find a high-resolution version.
(And the same convention could be used to load video assets.)
Maybe there are server side techniques that could be put in place to automatically serve up the most optimized image for a given DPI. This would stop a bunch of 404s, but requires more work on the part of the server monkey.
This is good news for SVG and libraries like Raphael, who are well suited for scaling. When playing with an iPhone 4 it was amazing how quickly you noticed the bitmaps that were too low res… they stick out like a sore thumb. Expectations have changed.
What else can we do?
Posted by Dion Almaer at 11:17 am