It constantly amazes me that so many mobile web sites fail validation. And it’s not just new sites, even some of the biggest names in the industry have mobile pages that have been failing for years when validated by the W3C’s online validator. Probably a third of all the sites I look at don’t validate. The most common problems are:
- “Naked” ampersands in text and URLs (XML based markup requires that all ampersands be represented by the appropriate html entity). If you host ads on your site watch out for unencoded ampersands in both the inter text and link url of the ads. I found that about half the ads I was being served had that problem. My solution, in PHP, was to use urlencode() on both the ad text and url.
- Improper tag nesting – <div><strong>This is so wrong!<div/><strong/>
- unclosed tags – <img…> instead of <img…/>.
I’m sure a lot of you who are web developers are saying, “Yeah, but validation is an academic thing, what really matters is that my site works in the real world”. Of course you are right, users don’t care about validation they just want stuff to work. Furthermore, when building PC web pages validation really isn’t very helpful. Desktop browsers silently ignore almost all markup problems -the real trick is getting the pages to look good in the various browsers. Six PC browsers have something like 99% of the market so you can test a page in a few minutes with at most three PCs.
Mobile is different world, browser designers are faced with severe memory and processor constraints as well as the need to obtimize performance on an already slow system. For the browser to work around invalid markup is just a waste of resources. There are literally hundreds of different mobile browser versions. Testing on real devices is great but it’s impractical to actually test on more than a small fraction of the various mobile browsers out there. Most mobile development shops are probably testing with just a few devices, maybe a recent Nokia, a Palm Treo or something with Openwave 6. The trouble is that those are among the most forgiving of browsers when it comes to bad markup. Pages that work fine on an N70 will fall over on Opera Mobile or Mini or the Teleca browser used on many Samsungs, LG’s and Sony Ericsson’s. The good news is that if your markup is valid and page size is under 20 KB (including images) your site will load and display without errors on 99% of WAP2 browsers.
It’s easy to validate a single mobile page. The W3C validator I mentioned above is a no brainer – just paste in the page’s URL and press Validate. For proper results the page should be on a public server and sent with the correct mime type (application/xhtml+xml for WAP2 or text/vnd.wap.wml for WAP1 – the validator doesn’t support application/vnd.wap.xhtml+xml but then neither do many mobile browsers.) Also note that while the site can validate an html page uploaded from a local disk file that feature doesn’t work properly for XML based markup like wml or xhtml-mp.
It’s even easier is to use Firefox to validate mobile pages. You do need to install a few Firefox extensions first:
- Web Developer – adds dozens of development tools to Firefox’s menu and/or toolbar. I mainly use Tools|Web Developer|Tools|Validate HTML which opens the W3C validator in a new tab validating against the current page. In spite of it’s name the validator handles wml, xhtml basic and xhtml-mp in addition to html.
- HTML validator – validates every page you visit and puts an icon in the browser status bar indicating the validity of the current page. It runs locally so it’s fast and works with local pages. When you View Source it lists the errors and goes to the offending line when you click on an error. HTML validator also describes the error in detail and even shows how to fix most errors. But, I find it misses some xhtml errors and doesn’t validate wml or even xhtml if the application/vnd.wap.xhtml+xml mime type is used. I use HTML Validator as a quick sanity check while developing pages and then do final checks with the W3C validator, mobile browser emulators and real handsets.
- XHTML Mobile Profile – Allows Firefox to render pages with mime type application/vnd.wap.xhtml+xml.
Validating an entire large mobile site one page at a time is a painful process. Fortunately the Web Design Group has a validator that will validate a site recursively. It doesn’t give as detailed reports as the W3C validator and it displays the message “Level of HTML: Unknown (XML)” when validating xhtml-mp pages. But I spot checked it’s results against the W3C validator and it found the same errors; unescaped ampersands, improperly nested tags, unclosed tags and even tags like strike and center that are valid in html but not in xhtml. Unfortunately, it’s limited to only validating 100 pages per site. Anyone know of a recursive validator with a higher or no limit?
If you don’t validate your xhtml mobile sites you risk losing at least 10% of your potential audience. That’s the approximate combined market share of the Opera Mobile, Opera Mini and Teleca browsers. Ten percent of US mobile web users is 3.5 million users. The W3C claims that there are 1.1 billion web capable handsets worldwide. Do you want to give up reaching 100 million sets of eyeballs because of trivial errors in your site’s markup? I don’t think so – validate! Incidentally, if you are still maintaining wml sites validation is even more important , very few browsers can handle ANY errors in wml markup.
Related:
and fyi, there is ready dot mobi for mobileOK checker
thanks for the tip on the HTML validator extension!
Pingback: tarek speaks mobile… » Blog Archive » Carnival Of The Mobilists #51