Now teaching Mobile Web Development at Portland Community College

Register now for Mobile Web Development for Summer 2010. Class meets at 5:30pm - 9:30pm on Wednesday evenings July 14 - August 18, 2010 in Portland, Oregon.

See the Mobile Web Development curriculum or contact me for details.

how to develop standards-compliant and usable mobile web applications

Archive for 'Mobile Web'

No Gravatar

HTML5 is the next major revision of HTML. It’s a really big deal, especially for mobile browsers and on-the-go Web users. If the main features of the latest HTML5 draft specification are present in the final version, HTML5 will standardize many killer use cases for Mobile Web browsing that were previously implemented using proprietary APIs or ad-hoc methodologies.

Killer HTML5 Features for Mobile

HTML5 is great news for the mobile ecosystem. Mobile users get richer Web applications and improved usability. Mobile browsers reclaim the rendering of rich Web content from third-party plug-ins. Mobile developers get testable, cross-platform and standards-based interfaces for content development.

The new features of HTML5 standardize use cases and technologies that are common in smartphone-optimized Mobile Web applications. In today’s Mobile Web of XHTML-MP (pdf) or HTML 4 documents, these killer features are implemented using proprietary device and browser APIs. With HTML5, advanced Web application features are available in all mobile browsers supporting the markup language, using the same standard syntax and displaying the same standard behavior.

Mobile Web applications using HTML5 can natively embed audio and video, incorporate the user’s geographic location and display interactive Flash-like animations on a 2D canvas. Mobile Web applications in HTML5 can also respond to coverage outages by caching external dependencies for offline Web browsing and locally caching data until connectivity is restored.

HTML5’s best features for mobility are location awareness, canvas animation, persistent storage, offline application caching, improvements to the semantic structure of Web documents and native audio and video controls. Let’s look at each of these features in detail.

Location Awareness in HTML5

HTML5’s Geolocation API makes the mobile device’s geographic location available to a Web application. In the past, obtaining device location was only possible using proprietary JavaScript extensions to JavaScript or server-side integration with a mobile operator API. The API allows one-off location queries and repeated location updates by registering callback functions.

Here is an example of the HTML5 geolocation API used to obtain a single update to the user’s position:

function updatePosition(position) {
// Latitude and longitude are available as member variables
var myLatitude = position.coords.latitude;
var myLongitude = position.coords.longitude;
}
// Request the geographic position.
// This method calls back once to the above updatePosition() function.
navigator.geolocation.getCurrentPosition(updatePosition);


Here is an example of the API used for repeated location updates:

function updatePosition(position) {
// Latitude and longitude are available as position.coords.latitude and position.coords.longitude
}
// Request repeated updates.
// This method calls back repeatedly to the updatePosition() function
// until cancelled using clearWatch(), below.
var watchId = navigator.geolocation.watchPosition(updatePosition);
// Cancel the geographic position updates.
function cancelPositionUpdates() {
navigator.geolocation.clearWatch(watchId);
}


2D Canvas Animation API in HTML5

New <canvas> element and JavaScript 2D Canvas API allow two-dimensional drawing, graphics and animations. Cross-platform games become possible in mobile browsers. Reminder: Script execution impacts battery life on mobile devices.

Here is an example of a 400×400 canvas element:

<canvas id="myCanvas" width="400" height="400" />


And here is an example of the 2D Canvas API used to draw inside the canvas:

// Obtain is a reference to a <canvas> element
var canvas = document.getElementById('myCanvas');
// Obtain a context used to draw
var context = canvas.getContext('2d');
// Clear the canvas
canvas.setAttribute('width', '400');
// Draw an image on the canvas, 'myImage' is a reference to an existing image element.
// Image is drawn at position (10, 10) with width of 100 and height of 50.
canvas.drawImage(myImage, 10, 10, 100, 50);
// specify a CSS color used to fill drawn elements
context.fillStyle = 'rgb(255, 0, 0)';
// Draw a red rectangle on the canvas
context.fillRect(0,0,50,50);
// Clear the canvas
canvas.width = canvas.width;


Web Storage API in HTML5

The Web Storage API allows documents to persistently store data in a mobile browser. Mobile browsers can write data in one browsing session and read it in the next session.

Offline Application Caching in HTML5

HTML5 documents use a manifest to list all dependent external resources (i.e. CSS files, JavaScript libraries, etc.). Mobile browsers use the manifest to cache an entire Web application for offline use, allowing mobile users to interact with a Web app while roaming in and out of coverage areas.

Semantic Document Structure in HTML5

New <header>, <footer>, <nav>, <section>, <article>, <figure> and <aside> elements declare the logical structure of a Web document. Structural elements make it easier for mobile browsers to navigate document components and display partial documents.

Native Audio and Video Controls in HTML5

New <video> and <audio> elements embed multimedia into a Web document without using third-party browser plug-ins. Mobile browsers may natively control multimedia display, codecs and user interfaces.

HTML5 Supplants XHTML

HTML5 supplants the XHTML 1.0 specification. In HTML5, XHTML is re-defined as a set of syntax rules and is no longer an independent markup specification. HTML5 can be expressed using either the strict syntax rules of XML or the looser syntax of HTML, which tolerates unclosed tags. Both formats are accepted as HTML5. This sensible change restores the unity of markup language functionality while allowing the mobile developer or designer the flexibility of choosing precise or lenient syntax. Slackers, you can continue to slack off in HTML5.

Motherhood, Apple Pie and HTML5

Mobile pundits tout HTML5 as the antidote to practically every problem in Mobile Web development. HTML5 is indeed a great leap forward in standardizing the advanced features of Web browsers. Its new elements and APIs unlock consistent implementations of rich Web application behavior. Unfortunately, HTML5 will not lessen or extinguish several sins of Mobile Web development, including:

  • Fragmentation: Too many vendors implement mobile browsers, creating a fragmented marketplace and forcing developers to adapt Web content to play to browser strengths and avoid browser weaknesses.
  • Browsers Bugs: As with any Web standard, HTML5 features may be incompletely or incorrectly implemented in a mobile browser.
  • Rushing to Market: Mobile browsers may support HTML5 too quickly, implementing features or syntax that end up changed or cut from the final standard.
  • Forgetting the Mass Market: Many popular Mobile Web sites use simple markup to quickly provide snackable chunks of relevant information to users. Upgrading these Mobile Web sites to use HTML5 (without implementing content adaptation) could cut off access to millions of users with older, Web-accessible mobile browsers.

HTML5 on Smartphones and Featurephones

Of course, the promise of HTML5 is only realized on mobile devices with modern, updatable Web browsers. As of this writing, iPhone, Android and Palm smartphones all implement portions of the HTML5 specification. Smartphones provide an excellent platform for rolling out HTML5 applications to savvy Mobile Web users. However, the majority of mobile subscribers still use non-smartphone devices with no ability to update the browser or operating system. Developers must use content adaptation principles to include advanced HTML5 elements only the target mobile browser is known to support HTML5. Content adaptation ensures a satisfactory Mobile Web experience for all mobile users.


This post is adapted from a short section on HTML5 and mobility that I contributed to Janine Warner’s upcoming book, Mobile Web Design for Dummies.



Bookmark and Share
VN:F [1.5.2_773]
Rating: 0.0/5 (0 votes cast)
No Gravatar

Learn the Mobile Web is back in action! I’m officially finished with maternity leave. I have planned plenty of shiny new goodness for the blog, including:

  • A backlog of mobile web development articles to post.
  • A Firefox extension that allows you to discover mobile web sites while browsing the desktop web.
  • My occasional series of mobile development articles at FierceDeveloper starts up again.
  • A possible second book on mobile web technologies!
  • Speaking engagements in the US and possibly Europe.
  • Mobile web development classes at PCC, Mt Hood Community College and possibly online.

On the personal side, here are my little cannolis, Vinny and Gemma, at 10 weeks:

Vinny Gemma
Bookmark and Share
VN:F [1.5.2_773]
Rating: 0.0/5 (0 votes cast)
No Gravatar

I am speaking at Portland Code Camp 2010 tomorrow. I’ll be discussing Standards-Based Mobile Web Development with a focus on smartphone browsers and the latest mobile web technologies (i.e. HTML5).

My session is at 4:45 PM – 6:00 PM on Saturday, May 22, 2010, in Shiley Hall, Room 301 at the University of Portland. Hope to see you there!

If you attend, please leave me feedback here or on my SpeakerRate profile. Thanks!

UPDATED: Thanks to all who attended my session. What a lively hour! My slides are below.

Bookmark and Share
VN:F [1.5.2_773]
Rating: 0.0/5 (0 votes cast)
No Gravatar

My Mobile Web Development course returns to Portland Community College. this summer. Students learn how to build web sites for browsers on all kinds of mobile phones. We focus on standards-based mobile web development, exploring mobile standards and industry best practices. This practical course includes in-class coding and experimentation. Register now at PCC.

Mobile Web Development class details:

  • CRN: 34044
  • Fee: $380
  • July 14 – August 18, 2010
  • 5:30pm – 9:30pm on Wednesday evenings
  • Class meets in Room 118, Mt Tabor Hall at PCC SE Center (SE 82nd and SE Division)
  • Class location is a computer lab. Computers are provided. Laptops and personal web space are encouraged. If using the PCC computers, bring a thumb drive to save your work.
  • 2.40 CEU credits from PCC Computer Education Training and Certification program

See you there!

Bookmark and Share
VN:F [1.5.2_773]
Rating: 0.0/5 (0 votes cast)