If you have to develop web pages for mobile phones you'll soon find out that developing mobile web pages is a far cry from what you thought it'd be. Don't believe the promises. Creating web pages for mobile phones is like developing web pages for all versions of Internet Explorer.
The resons mobile page development is so challenging are:
These reasons are pretty self-explanatory. Needless to say that the different browser engines can render the same code differently as well. Welcome to the mobile world.
I have found that mobile page web developers have to go back to 1990s-style web development practices in order to overcome the challenges above. I have tested the techniques below and found they work best across handsets. If you know another one, shoot me an email!
Don't even try to style forms or graphics next to multi-line paragraphs without using tables. To tame mobile phones tables are the most reliable option.
Example: Icon next to multi-line paragraph
<table>
<tr>
<td><img src="path/to/icon" width="x" height="y" alt="Descriptive alt text" /> </td>
<td>
<p><a href="#">Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.
Etiam urna purus, dapibus non, auctor eu.</a></p>
<p><a href="#">More</a></p>
</td>
</tr>
</table>
Note the non-breaking space just after the image: This ensures that there is always at least on space between the image and the text. Some mobile phone handsets ignore all whitespace here which might look ugly.
Some mobile phones (esp. by Motorola) apply a default padding to unordered and ordered lists which is not changeable by CSS. This requires either special treatment in the backend or - to my mind the simpler solution - a manual generation of any lists. So instead of a <ul> or <ol> tag, create the lists in your backend or by hand.
<p>1. First ordered list item</p> <p>2. Second ordered list item</p> <p>3. Third ordered list item</p> <p>4. Fourth ordered list item</p> <p>5. Fifth ordered list item</p>
If you use a drop-down control on a 'real' web page you are done in three clicks: click the control, scroll to the entry, click the entry. Mobile phones offer solutions which vary a lot, sometimes requiring many more clicks: click the control (new window opens), click as many times as you need to scroll, click entry (new window closes).
To make this experience as painless to users as possible I advise you to avoid drop-downs wherever you can.
Forms are the most complicated part of a mobile web page, not because they are so hard to code but because mobile phones render them so differently. I've seen handsets which automatically transform any drop-down list into a super-wide drop-down list of radio-buttons, and there's almost nothing you can do about it (Sony Ericsson).
Here are some tips on how to tame forms for mobile phone pages:
Example:
<form id="sampleForm" action="...">
<table>
<tr>
<th><label for="firstControl">Sample label:</label></th>
<td>
<input id="firstControl" size="4" name="firstControl" type="text" /><br />
<a href="#">This is a link</a>
</td>
</tr>
<tr>
<th><label for="secondControl">Long label name :</label></th>
<td>
<input id="secondControl" size="4" name="secondControl" type="text" />
</td>
</tr>
</table>
</form>
You can spend hours in mobile page testing. And when you come across handest number 25 and you have to tweak some CSS rule, how would you know that the previous 24 handsets still render the same?
So at some point you must compromise, accept wrapping labels or default fonts which are too large. The variety of handsets, browsers and screen sizes is just too big. If your client has ever done some testing themselves they'll understand.
To test mobile web pages nothing beats the test with physical phones. But if you want to do a preliminary test, Opera is a good browser. Click View | Small Screen or hit Shift-F11 to display web pages encoded with the attribute media="handheld" in the style sheet link. Unlinke Firefox, Opera stays in this mode after you hit refresh.
You will have to go through a lot of handsets to test your mobile web pages. Hence it makes sense to upload your pages to a web address which is as short as possible because you'll have to input this address into every handset.
Upload to an address like 'www.mydomain.com/t/i.xhtml' which you would normally create as 'www.mydomain.com/test/index.xhtml'. The first solution saves you a couple of characters and many more clicks.
The file 'i.xhmtl' then contains links to all pages you test. This way you just need to specify this single file and can reach all your pages from there and use the 'back' function of the phone to go back to the list.
Happy? Do you have feedback? Shoot me an email!