iPhone and developing for mobile
Thursday, July 5, 2007 3:51:01 PM
The iPhone has now been released to much fanfare. I'd like to run through a few things on what this means to web developers and those that want to optimise their sites to work on mobile web browsers.
The first point that has to be raised is that Apple also believe in the One Web approach, where they feel that mobile browsers are capable of rendering regular web pages and optimisations can be made by giving an alternative stylesheet customised for the smaller screen. This is a view that Opera supports. Makers of WAP browsers will probably disagree as they don't have the technology to display regular web pages correctly. It isn't a black and white case of course. Sometimes it is nice to have a mobile specific version, such as when the content is very location aware, or the application is complex so it would take a lot of work to optimise the regular site. I would say on average is is best to leave the page as it is, and rely on technology such as Opera Mini's intelligent zoom or iPhone's zoom, or optimise the CSS (more on that later) for web pages (blogs, wikis, news sites etc) and do a custom mobile version for web apps like Flickr or Gmail etc. With a mobile specific site a link should always be given to go to the regular site, as there may be information there that wasn't provided on the mobile version.
If using One Web principles, the issues comes with trying to optimise the CSS for mobile. The W3C spec has a solution for this; the handheld media type. The principle being that computers use Screen media, when printing Print is used, Handheld for mobile phones, PDA and small handheld media devices/tablets and so on. This sounds rosy, except Apple and Nokia in their wisdom have decided not to support Handheld. That may be fine if they didn't want authors to optimise the layout for iPhone/S60 Phones, but Apple clearly do in their developer documentation (click on Optimise for Page Readability and scroll down). They state that iPhone ignores the print and handheld media queries because these types do not supply high-end content.
Where they get this idea from I've no idea. It is obvious they don't need to support print (Opera Mobile and Mini don't either) because you are not likely to hook your mobile up to a printer and print the document, but print media has nothing to do with high or low end content. It is the same for Handheld, and it should be used for doing exactly what the suggest; specifying a stylesheet for mobiles. They get around the lack of handheld support by using Media Queries. This is a solution I've proposed in a previous article. This works well and gives a lot of fine grain control, but it would be much simpler to just support handheld media to get the same effect. That would get around any issues where a desktop based browser could get the mobile stylesheet due to using the screen media type, and where older mobile browsers will not get the mobile stylesheet as, as far as I know, only Opera based and WebKit based browsers support Media Queries. It is also worrying that they seem to suggest that developers should design specifically for the iPhone, and not mobile browsers in general, especially with a CSS filename of iphone.css in their example. This is a case we tried to avoid when the Wii browser was getting popular, by adding TV media support, so that all TV based browsers would benefit from the optimisations. There are of course exceptions where a web site is and should specifically be aimed for one browser and device, such as when Wiicade make use of the Wiimote hardware for example. In the case of the Apple documentation they give the following code suggestion:
<link media="only screen and (max-device-width: 480px)"
href="iPhone.css" type="text/css" rel="stylesheet" />
I'd suggest changing it to the following:
<link media="handheld, only screen and (max-device-width: 480px)"
href="mobile.css" type="text/css" rel="stylesheet" />
That way it will work on any devices that support handheld media (and makes sure Opera Mini 4 doesn't apply its desktop overview mode) and also on mobile devices such as the iPhone and Nokia S60 browsers which only support Media Queries.
Apart from the handheld debate, it is interesting to note that iPhone suffers quite a few of the same limitations as Opera Mini. Notably that it doesn't support file downloads or uploads (although you can upload from the camera in Mini), no plug-in support such as Flash, limited javaScript execution time etc. Although these are draw backs of both browsers, it does mean that it will make the base line that developers can aim for much more consistent. Fixing issues in one browser should fix many issues in the other browser.
One thing of note on the iPhone that is interesting to me was revealed in Daring Fireball's iPhone First Impressions. That is that the UI's interface uses the Helvetica font. This is interesting for a couple of reasons. First of all OS X usually uses Lucida Grande as its default UI font. I wonder if there was any reason for the choice, or if it just looked better on the smaller but high resolution screen? Either way I love the Helvetica font, so I think it is a nice choice. The most interesting thing for web developers though is that it means one important thing — that regular desktop quality fonts are available on the iPhone. This is not really a surprise, as it is based off OS X after all, but it is nice to have confirmation. One of the biggest problems with mobile development in my mind is the inconsistencies between devices caused by font support on phones. many only have one font (which is of quite low quality) and some have very limited text sizes available. It is also common that italic isn't even available. I don't have a iPhone, so I can't confirm if any other fonts are available. I'd expect they'd include the Microsoft core fonts (in the Web folder in FontBook) such as Arial, Times New Roman and everyone's favourite Comic Sans MS. I think it is important for consistency in mobile web design for handset providers to start providing the same fonts across models and brands. Web Fonts could solve the problem but it will be a while before they are supported across multiple mobile browsers, and a user probably doesn't want to download large font files across a slow EDGE network.
<p.look out for our Opera Mini 4 developers guide soon. it is in the final stage of preparations. As Opera Mini 4 is in beta, standards support will likely change for the final release, so look for updates to the document as time progresses.
Unregistered user # Friday, July 20, 2007 8:21:33 AM
Unregistered user # Saturday, July 21, 2007 10:43:36 PM
Unregistered user # Thursday, August 2, 2007 11:22:43 AM
David Storeydstorey # Sunday, September 2, 2007 10:14:37 PM
Unregistered user # Thursday, September 13, 2007 9:45:42 PM
Unregistered user # Thursday, September 13, 2007 9:56:51 PM
David Storeydstorey # Friday, September 14, 2007 7:05:54 PM
Apple themselves suggest to add a new stylesheet for iPhone to reformat the layout to suit the small screen. The problem is they don't support handheld, so have to use screen with a media query, The problem here is that breaks IE on desktop as the regular screen stylesheet (the one that desktop browsers use) will also be applied with the mobile specific one, as the browser has to use both screen stylesheets. To avoid that you have to put a media query on the regular stylesheet for displays bigger than the value specified. This works fine in all desktop browsers that don' support media queries as they see the screen keyword, ignore the media query and use the stylesheet, except it doesn't work in IE as it ignores the entire statement when it sees the a part it doesn't understand (the media query), and thus IE gets unstyled markup. Hardly ideal. If they supported handheld (or even just handheld if a media query is also used) then it would solve this major problem. It will likely never go away that mobiles have small screens and restricted input. The bandwidth issue is probably solvable over time, but is still an issue unless you are running on wifi.
As great as a zoom mode is, it is often much better if the content is correctly adapted to the screen size by the designer, as it solves the issue of trying to find the ocntent you are looking for in overview mode, zooming in then zooming out again to find the rest of the content. As you cant read anything in overview mode, it makes it difficult to navigate on sites that you don't know well. There are very few examples of good handheld stylesheets out there now, but that is because it is early days of designers having interest in the mobile web design. We are also just now getting browsers that support CSS well with different font sizes and supporting background images and such. As the more basic wap browsers die out, I think we'll see a lot better content and optimisations.
Unregistered user # Saturday, September 15, 2007 3:56:00 AM
Unregistered user # Thursday, March 6, 2008 6:41:11 PM
Unregistered user # Wednesday, November 19, 2008 10:52:00 PM
Unregistered user # Sunday, July 26, 2009 10:33:38 AM