The world of .NET and Web Programming

Hybrid Mobile Applications with HTML5, JavaScript and CSS3

Way back on October 9, 2011, when I was working on a hybrid mobile application, I had a key post for this category entitled “Viewport Meta Tag and Using HTML5/CSS3/jQuery to Build Mobile Interfaces”. The post had two key concepts vital to developing mobile applications with these technologies:

  1. Viewport Meta Tag
  2. CSS Media Queries

Although I identified these two key enablers, I was just learning at the time and fishing around, so I feel I didn’t give enough context and explanation (I gave an example of Media Queries without defining them or their purpose!). This post is an attempt to fill in the gaps.

I said, “Not only do I believe that it these technologies represent the present and future of Web Development, but also as a way to do cross-browser, cross-platform Mobile device UI development. Yes, you heard me right. These technologies make possible true cross-browser, cross-platform mobile web development for the first time. Some background. “

This is true but most be qualified in terms of what type of application you are building. The whole reason there is such passionate interest in HTML5, CSS3 and their associated JavaScript APIs is that most people don’t want to build “Native” mobile applications, at least not out in the corporate sector. Native mobile applications require you to learn a different programming language and IDE for each platform. Instead, most of us want to re-use skills we already know in building “web applications” and get some code reuse. This falls in the category of “Hybrid” or “Pure” Mobile applications. If you have no need to access native features of the device, you can build a “Pure” mobile web application with HTML5 and CSS3 only. But this is rare. These kind of applications can only go so far in leveraging native sensors and APIs on those devices, While some features – like geolocation – are provided to mobile browsers, many – like the accelerometer or video – are not. The great news, however, is that the popularity of Web programming has enabled HTML5, JavaScript, and CSS to “go native” as it were. Popular frameworks like PhoneGap and Titanium Appcelerator enable you to use HTML5 and JavaScript to build native applications for iOS, Android, and Windows Phone, with device access to boot. Thus, the “hybrid” mobile app.

I talked about the Viewport and Media Queries but the context is what’s called Adaptive or Responsive Web Applications, in that the application can scale up and down with different devices. Several things have happened lately to make these things possible:

  • Media tags to tell a mobile browser not to scale your site down
  • New standards that make building sites that work well in multiple mobile browsers much easier
  • New standards that make building sites that act more like web applications.

These standards include the family of HTML5 standards and CSS3. I covered HTML5 here and here.

I talked about the Viewport meta tag: So what is the Viewport meta tag? The Viewport meta tag was introduced by Apple Mobile Safari to let Web Developers control the viewport’s scale and size. It’s now an universal standard. Unless you tell it otherwise, Safari on the iPhone is going to assume your page is 980px wide. If you are going to do mobile web development for the iPhone and Blackberry devices with the smaller dimensions, you have to let Mobile Safari, you must let Mobile Safari (or Ripple for the Blackberry) know about it by adding a viewport meta tag to the head element of the HTML documents which sets it to the device width:

<meta name="viewport" content="user-scalable=no, width=device-width" />

I showed an example of a media query but didn’t talk about it!

<link rel="stylesheet" type="text/css" href="iphone.css" 
media="only screen and (max-width: 480px)" />

Media Queries (new with CSS3) are very powerful and I encourage you to read Dan Wahlin’s extensive post on them but the general idea is that they are a CSS expression than can evaluate to true or false. If true, the CSS selectors and properties of an expression will be applied. When combined with CSS cascading rules, it enables you to respond to different resolutions, orientations, or changes in resolution or orientation. This rule is basically saying, “for mobile devices with a device max width of 480px, apply the iphone stylesheet.

Again, this post barely scratches the surface of this whole area but hopefully fills in some holes and nails down Viewports and Media Queries as fundamental concepts in building hybrid web applications with HTML5, JavaScript, and CSS3. I plan to build on these posts to go more in depth.

» Similar Posts

  1. Viewport Meta Tag and Using HTML 5/CSS3/jQuery to Build Mobile Interfaces
  2. What is HTML5 Anyway?
  3. My First Experience with ASP.NET Web API 101

» Trackbacks & Pingbacks

    No trackbacks yet.
Trackback link for this post:
http://samgentile.com/Web/trackback.ashx?id=1945

» Comments

  1. Chris Hunter avatar

    I high appreciate this post. It’s hard to find the good from the bad sometimes but I think you’ve nailed it! would you mind updating your blog with more information?

    <a href="http://www.athomewellnessgroup.com/">home health care services indianapolis</a>

    Chris Hunter — June 8, 2012 12:38 AM
  2. go here avatar

    Using mobile applications with HTML 5 and JavaScript and CSS 3 increases the credibility of mobile users. The functions that we usually do in the computer can now be done from mobile phones that supports the applications.

    go here — November 6, 2012 1:11 AM
  3. Nicole Lee avatar

    Thanks, <a href="http://www.joyfax.com">This is a good article.I liked

    this article, </a>great!

    Nicole Lee — November 7, 2012 4:26 AM
  4. Aca avatar

    if I want to create mobile web applications, I do only need to learn HTML5, JavaScript and CSS3?

    Thanks

    Aca — November 12, 2012 2:08 PM
  5. Ryan Watson avatar

    Thanks for the great blog, can you explain me a Silverlight application and can it work it in Mobile application?

    Ryan Watson — December 3, 2012 9:39 AM
  6. Ryan Watson avatar

    Thanks for the great blog, can you explain me a Silverlight application and can it work it in Mobile application?

    Ryan Watson — December 3, 2012 9:39 AM
  7. Rock avatar

    A sharp competition is being seen among Native, HTML5 and Hybrid mobile apps. Three of these are trying to prove their best capabilities with their own unique features. Living in the era where screens are getting smaller and applications are turning bigger, people are not left with the selection of mobile applications but its use have become imperative for them. But, the question is what to use what is the best?

    Rock — March 3, 2013 1:09 PM
  8. Ehab Heikal avatar

    Viewports are important but don't you wish that android and IOS would standardize and make HTML5 development and even web design easier for us? :)

    Ehab Heikal — March 26, 2013 8:17 PM
  9. Web designer avatar

    Thank you for this explanation of HTML5. I just wish that more phone and OS functionality can be utilized through HTML5 I know this will be like a serious security flaw but no problem in dreaming.

    Web designer — March 26, 2013 8:20 PM
  10. sohbet avatar

    The Verizon joke was amazing :)

    sohbet — March 27, 2013 8:01 PM
  11. chat avatar

    I am kind of tired of the Dragon of My Dreams inspiration emails, but at the same time, I start remembering that video and completely understand

    chat — March 27, 2013 8:01 PM
  12. mynet avatar

    It said the 21st it would be available for everyone, I thought waiting a few extra days would make it for sure I can watch it, well I'll try again in a few days

    mynet — March 27, 2013 8:02 PM
  13. oyun avatar

    It's always great to how many people James has inspired with his work, especially with his Dragon In My Dreams video.

    oyun — March 27, 2013 8:03 PM
  14. sohbet avatar

    goood very supoer thanks

    sohbet — May 16, 2013 7:34 AM
  15. sohbet siteleri avatar

    hmm good super blogs

    sohbet siteleri — May 16, 2013 7:35 AM
  16. chat sohbet avatar

    kmon site thnaks

    chat sohbet — May 16, 2013 7:35 AM
  17. chat yap avatar

    offfffffffff yok boyle bisey

    chat yap — May 16, 2013 7:35 AM
  18. cinsel sohbet avatar

    hmmm good supers

    cinsel sohbet — May 16, 2013 7:36 AM
  19. cinsel chat avatar

    hello thanks cinsel chat

    cinsel chat — May 16, 2013 7:36 AM
  20. mynet sohbet avatar

    hmm good and yous

    mynet sohbet — May 16, 2013 7:36 AM
  21. reclaimed building materials avatar

    Well, HTML5 can be used as the UI layer for building mobile applications. Not a big deal!

    reclaimed building materials — May 21, 2013 6:46 AM
  22. save planet earth avatar

    Thank you for the post!

    save planet earth — May 21, 2013 6:48 AM

» Leave a Comment