I’ve been playing with the iPhone’s implementation of Safari for the last few days, and I’ve come up with a few rules to remember when designing pages for iPhone.
The first rule is don’t design for iPhone.
Well, that’s a kind of misleading rule. One should obviously design in such a way that someone surfing from a crappy EDGE connection doesn’t have to wait five minutes for the page to load. The design of my blog works quite well on iPhone, but I still made a separate template for mobile use by stripping out all the sidebar content and the large graphics that would take too long to load.
Still, the point of iPhone’s Safari is that web pages can be richly designed and not forced to adhere to a small screen size and truncated content. Unless, of course, you develop in Flash, in which case you’re kind of out of luck.
Here are a few things to keep in mind when designing your site.
Page width
If your site doesn’t have the width defined in a meta tag, iPhone will zoom way out when loading the page. Use this meta tag in the HEAD of your page to tell iPhone how wide your page is:
meta name="viewport" content="width=xxx"
(where xxx is the width, in pixels.)
Fonts
iPhone has a very small subset of fonts built in. My research indicates that these are the included fonts. Any other fonts you use will be substituted with Helvetica or Times.
- American Typewriter
- American Typewriter Bold
- American Typewriter Condensed Bold
- Arial
- Arial Rounded MT Bold
- Courier
- Georgia
- Helvetica
- Marker Felt Thin
- Times
- Trebuchet MS
- Verdana
- Zapfino
The inclusion of American Typewriter and Zapfino are surprising; perhaps more surprising is the fact that the usual suspects — Arial Narrow and Lucida Grande — are not included.
Update: there are also these iPhone-specific fonts installed for use in the phone’s interface, but they don’t have glyphs for every character. I assume they contain graphics that are accessed via Unicode.
- LCD
This font is missing some of the letters for some unknown reason. I assume that it only has the letters necessary for its use in the interface — but I have no idea where this font appears in the iPhone system. ABDEFINORTVYZ1234567890 - Lock Clock
This font seems to include only numbers and letters used for the clock, a sort of Helvetica Ultra Light. 0123456789ampm - Phone Pad Two
- HelvLTMM/Helvetica Light Multiple Master?
- Arial Uni?
Double-tap Zoom
In order to facilitate the double-tap zoom, items on the page must have a “width” definition. If you just throw text on a page, the user can’t zoom in, it must be contained within a CSS-defined width (or possibly within a table). Give every element a concrete width so that iPhone knows how much to zoom in. If you’re very clever, you’ll limit columns of text to 480 pixels wide.
Font Size
The iPhone screen is double — or even more — the resolution of most computer screens, so the text is correspondingly smaller on web pages. Take this into account and make the type larger. I like 12 pt or higher.
More as I explore!
[Update, July 3: Apple has posted a webpage on iPhone web development at http://developer.apple.com/iphone/ … this is really directed at developers who wish to create applications via Web 2.0; but it does have some useful information for simple web design.]
Opus got his iPhone…
[url=”http://www.salon.com/comics/opus/2007/07/01/opus/”]
http://www.salon.com/comics/opus/2007/07/01/opus/[/url]
This is fascinating! Thanks for clueing me in…
Sooooo, how long ’till you emerge from your house again?
We’ve been digging deeper into various viewport options in the http://www.iPhoneWebDev.com community, and there are some other variants that result in much nicer iPhone web pages.
Lately I’ve been enamored of the simple “meta name=“viewport” id=“viewport” content = “ maximum-scale = 0.6667; width = 480″ /” tag, and making sure that your page renders ok if the window is 720px wide. Using this viewport works particularly well when switching between portrait and landscape orientation.
You might want check out our email discussion list archives for solutions to a number of other common problems in creating web pages and webapps for the iPhone.
For instance, we’ve figured out the best way to hide the URL bar — see http://groups.google.com/group/iphonewebdev/browse_thread/thread/c064b183c1207a98/dd79332910e4695c
We have figured out how best to detect orientation change and change UI for landscape vs portrait — http://groups.google.com/group/iphonewebdev/browse_thread/thread/e041ae0357dc62dc
A lot of discussion about best practices re: viewport —
http://groups.google.com/group/iphonewebdev/browse_thread/thread/f43493a828dffdb3
Dealing with various problems of scaling — http://groups.google.com/group/iphonewebdev/browse_thread/thread/b09a202d34daab51
We are figuring out how to create objects that drag using two-finger drag — http://groups.google.com/group/iphonewebdev/browse_thread/thread/991a04799ec841f7
Come join us helping iPhone developers help iPhone developers!