<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Calhoun&#039;s Developer Blog &#187; mobile</title>
	<atom:link href="http://davidbcalhoun.com/tag/mobile/feed" rel="self" type="application/rss+xml" />
	<link>http://davidbcalhoun.com</link>
	<description>Just another blog</description>
	<lastBuildDate>Fri, 03 Feb 2012 01:29:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Does it still make sense to use em rather than px?</title>
		<link>http://davidbcalhoun.com/2010/does-it-still-make-sense-to-use-em-rather-than-px</link>
		<comments>http://davidbcalhoun.com/2010/does-it-still-make-sense-to-use-em-rather-than-px#comments</comments>
		<pubDate>Tue, 05 Oct 2010 18:13:15 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[em]]></category>
		<category><![CDATA[media queries]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[px]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=476</guid>
		<description><![CDATA[Alex Kessinger tweeted asking if there was a reason to still use EMs instead of PX measurements in mobile. This is an interesting question, but 140 characters isn&#8217;t quite enough to explain my thoughts. So here&#8217;s an old-fashioned blog post! Just a quick review: em and percentage (%) units in CSS are relative measurements, whereas [...]]]></description>
			<content:encoded><![CDATA[<p>Alex Kessinger <a href="http://twitter.com/voidfiles/status/26470129747">tweeted</a> asking if there was a reason to still use EMs instead of PX measurements in mobile.  This is an interesting question, but 140 characters isn&#8217;t quite enough to explain my thoughts.  So here&#8217;s an old-fashioned blog post!</p>
<p>Just a quick review: em and percentage (%) units in CSS are relative measurements, whereas px and other measurements are not.  What this means is that the resulting size of relative measurements depends on the size of the parent.</p>
<h3>The original reason to use EMs instead of PX measurements</h3>
<p>As far as I can tell, the original reason why it became a good practice to use EMs was because of page scaling and accessibility reasons.  When developers used PX measurements, they found that when the page was scaled (using Ctrl + Scroll Wheel), the parts of the page with fixed PX measurements didn&#8217;t scale.</p>
<p>Oh no!  So when a user with poor eyesight tried to scale a page to read the text better, it turns out that the text they were interesting in making bigger actually didn&#8217;t change size at all!</p>
<p>So is this still the case today?  By and large, no.  All modern browsers except IE6 will now scale pages correctly, regardless of the type of CSS units used.</p>
<p>From what I&#8217;ve heard, there are still many users with disabilities using IE6, but the reason is because they don&#8217;t want to upgrade their copy of the screen reader JAWS, which is quite expensive.  However, these users obviously aren&#8217;t affected by page scaling issues because they are blind.</p>
<h3>Maintainability concerns</h3>
<p>Even if the original reason to use EMs (above) is no longer valid, I still believe there are good reasons to use them.</p>
<p>One of the main reasons is maintainability.  If a page is designed to have one base font size (applied to the Body) and all other font sizes on the page use relative units (EMs or percentages), changing the font sizes later becomes almost trivial.  If someone wants to later increase the size of the fonts on their entire page, all they need to do is increase the one base font size.</p>
<p>This might be a bit of an edge case, but the elegance of the solution is too enticing!  <img src='http://davidbcalhoun.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Media queries and mobile</h3>
<p>Very closely related to the above point is the subject of media queries.  Recently media queries have been somewhat hailed as a <a href="http://www.quirksmode.org/blog/archives/2010/09/rethinking_the.html">panacea for all mobile development</a>.  I slightly disagree, but that&#8217;s a topic for another post!</p>
<p>The main point here is that people are now using media queries to quickly make mobile-friendly versions of their desktop websites.  That&#8217;s awesome, there&#8217;s no doubt about that.</p>
<p>So what about EMs and PX measurements?  Here&#8217;s the problem: if a developer coded their webpage in such a way that they used fixed pixel measurements, the amount of CSS required in the mobile media query could be obscenely large.  This is because each individual element with pixel measurement was <i>designed with the desktop in mind</i>!  This makes the task of adapting to different content very painful.</p>
<p>On the other hand, think about a page designed with relative units such as EMs or percentages.  This page was designed so that each element was proportional to its parent element, so that ideally changing the size of the entire page occurs in only a few places, at the Body level of the document.  Suddenly the CSS required for the mobile media query is much more manageable, since it&#8217;s now (ideally) only changing a few values on the Body element, not on <i>every</i> element on the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/does-it-still-make-sense-to-use-em-rather-than-px/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Thursday links (July 8)</title>
		<link>http://davidbcalhoun.com/2010/thursday-links-july-8</link>
		<comments>http://davidbcalhoun.com/2010/thursday-links-july-8#comments</comments>
		<pubDate>Fri, 09 Jul 2010 04:00:09 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[links]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=338</guid>
		<description><![CDATA[Mobile YouTube Mobile Gets a Kick Start Battle of Champions: HTC Droid Incredible vs. Palm Pre Plus Designing for the Retina Display (326ppi) AUDIO: John Resig: You Don’t Know Mobile (Webstyle Magazine) &#8211; ~$5,000 minimum to do mobile testing Tapworthy: Designing Great iPhone Apps eMobile: We have the fastest network in Japan! Apple iPad User [...]]]></description>
			<content:encoded><![CDATA[<h3>Mobile</h3>
<p><a href="http://googlemobile.blogspot.com/2010/07/youtube-mobile-gets-kick-start.html">YouTube Mobile Gets a Kick Start</a><br />
<a href="http://blog.laptopmag.com/htc-droid-incredible-vs-palm-pre-plus">Battle of Champions: HTC Droid Incredible vs. Palm Pre Plus</a><br />
<a href="http://www.lukew.com/ff/entry.asp?1142">Designing for the Retina Display (326ppi)</a><br />
<a href="http://webstylemag.com/you-dont-know-mobile" class="audio">AUDIO: John Resig: You Don’t Know Mobile (Webstyle Magazine)</a> &#8211; ~$5,000 minimum to do mobile testing<br />
<a href="http://www.amazon.com/Tapworthy-Designing-Great-iPhone-Apps/dp/1449381650">Tapworthy: Designing Great iPhone Apps</a><br />
<a href="http://www.intomobile.com/2010/07/08/emobile-we-have-the-fastest-network-in-japan/">eMobile: We have the fastest network in Japan!</a><br />
<a href="http://ymobileblog.com/blog/2010/07/08/apple-ipad-user-analysis-%E2%80%94-phase-ii/">Apple iPad User Analysis — Phase II</a><br />
<a href="http://www.youtube.com/watch?v=6_TFHqIHBqM" class="video">VIDEO: Using iPhone with a Braille display (Victor Tsaran)</a><br />
<a href="http://www.pewinternet.org/Reports/2010/Mobile-Access-2010.aspx">Mobile Access 2010 (Pew Research)</a><br />
<a href="http://www.prnewswire.com/news-releases/comscore-reports-may-2010-us-mobile-subscriber-market-share-98031904.html">BlackBerry and iPhone losing ground to Android, overall smartphone growth (comScore data)</a></p>
<h3>JavaScript</h3>
<p><a href="http://blog.mozilla.com/dherman/2010/07/08/javascript-needs-modules/">JavaScript needs modules!</a><br />
<a href="http://www.dustindiaz.com/javascript-cache-provider/">JavaScript Cache Provider (Dustin Diaz)</a><br />
<a href="http://www.adequatelygood.com/2010/7/Writing-Testable-JavaScript">Writing Testable JavaScript</a></p>
<h3>CSS</h3>
<p><a href="http://5by5.tv/bigwebshow/11" class="video">VIDEO: Nicole Sullivan on CSS (The Big Web Show)</a><br />
<a href="http://css-tricks.com/css-media-queries/">CSS Media Queries &#038; Using Available Space</a><br />
<a href="http://www.nczonline.net/blog/2010/07/06/data-uris-make-css-sprites-obsolete/">Data URIs make CSS sprites obsolete (Nicholas Zakas)</a></p>
<h3>Books</h3>
<p><a href="http://books.alistapart.com/product/html5-for-web-designers">HTML5 For Web Designers</a><br />
<a href="http://www.amazon.com/Tapworthy-Designing-Great-iPhone-Apps/dp/1449381650">Tapworthy: Designing Great iPhone Apps</a><br />
<a href="http://www.amazon.com/HTML5-Up-Running-Mark-Pilgrim/dp/0596806027">HTML5: Up and Running</a><br />
<a href="http://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752">JavaScript Patterns</a></p>
<h3>Etc.</h3>
<p><a href="http://web.enavu.com/snippets/web-forms-semantic-mark-up-in-our-forms-part-2/">Web Forms: Semantic Mark Up in our Forms [part 2]</a><br />
<a href="http://trentwalton.com/2010/07/05/non-hover/">Non Hover</a> &#8211; “Elements that rely only on mousemove, mouseover, mouseout or the CSS pseudo-class :hover may not always behave as expected on a touch-screen device such as iPad or iPhone.”<br />
<a href="http://www.xanthir.com/video/">Video to ASCII conversion with Canvas</a><br />
<a href="http://accessibiliteweb.com/stuff/captcha-slider.html">CAPTCHA slider</a><br />
<a href="http://www.google.com/support/webmasters/bin/topic.py?topic=21997">Rich snippets and structured markup (Google Webmaster Central) (SEO)</a><br />
<a href="http://hacks.mozilla.org/2010/07/firefox-4-beta-1-is-here-whats-in-it-for-web-developers/">Firefox 4 beta 1 is here – what’s in it for web developers?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/thursday-links-july-8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using mobile-specific HTML, CSS, and JavaScript (Mobile web part 5)</title>
		<link>http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript</link>
		<comments>http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript#comments</comments>
		<pubDate>Wed, 30 Jun 2010 03:27:11 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[basejs]]></category>
		<category><![CDATA[blackberry.network]]></category>
		<category><![CDATA[blackberry.system]]></category>
		<category><![CDATA[capture api]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gesture events]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[iui]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jqtouch]]></category>
		<category><![CDATA[media queries]]></category>
		<category><![CDATA[mozorientation]]></category>
		<category><![CDATA[orientationchange]]></category>
		<category><![CDATA[pastrykit]]></category>
		<category><![CDATA[touch events]]></category>
		<category><![CDATA[webkit]]></category>
		<category><![CDATA[xui]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=317</guid>
		<description><![CDATA[(updated June 27, 2011) Mobile-specific HTML Viewport tag Use the viewport tag to properly fit the content to the screen: &#60;meta name=&#34;viewport&#34; content=&#34;width=device-width, initial-scale=1.0&#34;/&#62; Tel scheme (to initiate phone calls) &#60;a href=&#34;tel:18005555555&#34;&#62;Call us at 1-800-555-5555&#60;/a&#62; Sms scheme (to initiate text messages) &#60;a href=&#34;sms:18005555555&#34;&#62; &#60;a href=&#34;sms:18005555555,18005555556&#34;&#62; &#60;!-- multiple recipients --&#62; &#60;a href=&#34;sms:18005555555?body=Text%20goes%20here&#34;&#62; &#60;!-- predefined message body [...]]]></description>
			<content:encoded><![CDATA[<p><em>(updated June 27, 2011)</em></p>
<h3>Mobile-specific HTML</h3>
<h4>Viewport tag</h4>
<p>Use the <a href="http://davidbcalhoun.com/2010/viewport-metatag">viewport tag</a> to properly fit the content to the screen:</p>
<pre name="code" class="html">
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt;
</pre>
<h4><a href="http://www.rfc-editor.org/rfc/rfc3966.txt">Tel scheme</a> (to initiate phone calls)</h4>
<pre name="code" class="html">
&lt;a href=&quot;tel:18005555555&quot;&gt;Call us at 1-800-555-5555&lt;/a&gt;
</pre>
<h4><a href="http://www.rfc-editor.org/rfc/rfc5724.txt">Sms scheme</a> (to initiate text messages)</h4>
<pre name="code" class="html">
&lt;a href=&quot;sms:18005555555&quot;&gt;
&lt;a href=&quot;sms:18005555555,18005555556&quot;&gt;              &lt;!-- multiple recipients --&gt;
&lt;a href=&quot;sms:18005555555?body=Text%20goes%20here&quot;&gt;  &lt;!-- predefined message body --&gt;
</pre>
<h4>Disable automatic telephone number linking</h4>
<pre name="code" class="html">
&lt;meta name=&quot;format-detection&quot; content=&quot;telephone=no&quot;&gt;
</pre>
<h4>iOS-specific HTML (some work on Android as well)</h4>
<p>You also have access to several <a href="http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safariwebcontent/configuringwebapplications/configuringwebapplications.html">Apple-specific tags to use in your iOS applications (iPhone, iPad, and don&#8217;t forget the iPod Touch!)</a>.</p>
<pre name="code" class="html">
<!-- iOS 1.1.3+: this is the icon that's used when the user adds your app to the home screen -->
<!-- also works on Android! -->
&lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icon.png&quot;/&gt;

<!-- iOS 2.0+: tell iOS not to apply any glare effects to the icon -->
&lt;link rel=&quot;apple-touch-icon-precomposed&quot; href=&quot;icon.png&quot;/&gt;

<!-- iOS 4.2+ icons for different resolutions -->
&lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72x72&quot; href=&quot;touch-icon-ipad.png&quot; /&gt;
&lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114x114&quot; href=&quot;touch-icon-iphone4.png&quot; /&gt;

<!-- iOS 3+: full-screen startup splash screen image (must be 320x460) -->
&lt;link rel=&quot;apple-touch-startup-image&quot; href=&quot;startup.png&quot;&gt;

<!-- enable full-screen mode (only when launched from home screen) -->
&lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot; /&gt;

<!-- controls the appearance of the status bar in full-screen mode -->
&lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot; /&gt;
</pre>
<h4>Turn off autocorrect, autocomplete, and autocapitalize</h4>
<p>And also some handy attributes to turn off annoying autocorrect features:</p>
<pre name="code" class="html">
&lt;input autocorrect=&quot;off&quot; autocomplete=&quot;off&quot; autocapitalize=&quot;off&quot;&gt;
</pre>
<h3>Mobile-specific CSS</h3>
<h4>position:fixed and overflow:scroll</h4>
<p>Mobile browsers are now starting to support these basic CSS properties better.  Position:fixed will work on Android 2.2+ and iOS 5+.  Overflow:scroll works with one finger on iOS 5+.</p>
<p>Also, iOS 5 has additional CSS to give the native scrollbar and momentum/intertia to elements with overflow:scroll: <code>-webkit-overflow-scrolling: touch;</code></p>
<h4>Media queries</h4>
<p><a href="http://www.w3.org/TR/css3-mediaqueries/">Media queries</a> enable you to target specific features (screen width, orientation, resolution) within CSS itself.  Media queries themselves are actually quite old and are not mobile specific (they used to be popular for making a print-friendly version of webpages).</p>
<p>You can use them two ways: 1) inline in a CSS stylesheet or 2) as the &#8220;media&#8221; attribute in the link tag, which loads an external stylesheet.  The following is an example of inline CSS that&#8217;s applied only when the device is in portrait mode:</p>
<pre name="code" class="css">
@media all and (orientation: portrait) {
	body { }
	div { }
}
</pre>
<p>Here&#8217;s the same media query using the other method, which points to an external stylesheet (not recommended):</p>
<pre name="code" class="html">
&lt;link rel=&quot;stylesheet&quot; media=&quot;all and (orientation: portrait)&quot; href=&quot;portrait.css&quot; /&gt;
</pre>
<p>This is not recommended because it creates an additional HTTP request (bad for performance).  Also, in the case of screen orientation, the separate CSS stylesheet is NOT downloaded when the screen is rotated.</p>
<p>Here&#8217;s a few examples of using inline CSS:</p>
<pre name="code" class="css">
// target small screens (mobile devices or small desktop windows)
@media only screen and (max-width: 480px) {
  /* CSS goes here */
}

/* high resolution screens */
@media (-webkit-min-device-pixel-ratio: 2),
             (min--moz-device-pixel-ratio: 2),
             (min-resolution: 300dpi) {
  header { background-image: url(header-highres.png); }
}

/* low resolution screens */
@media (-webkit-max-device-pixel-ratio: 1.5),
             (max--moz-device-pixel-ratio: 1.5),
             (max-resolution: 299dpi) {
  header { background-image: url(header-lowres.png); }
}
</pre>
<p>Read more: <a href="https://developer.mozilla.org/en/css/media_queries">Media queries (Mozilla Developer Center)</a></p>
<h4>Miscellaneous CSS</h4>
<p>-webkit-tap-highlight-color (iOS): override the semitransparent color overlay when a user clicks a link or clickable element.  To completely disable it, set the value to &#8216;transparent&#8217; or &#8216;rgba(0,0,0,0)&#8217;</p>
<p>-webkit-user-select: none; &#8211; prevent the user from selecting text (also works on desktop WebKit)</p>
<p>-webkit-touch-callout: none; &#8211; prevent the callout toolbar from appearing when a user touches and holds an element such as an anchor tag.</p>
<h3>Mobile-specific JavaScript</h3>
<h4>window.scrollTo(0,0);</h4>
<p>This hides the address bar and takes advantage of the entire device screen.  You&#8217;ll have to set this in a timeout and make sure to get the timing right.  See <a href="http://remysharp.com/2010/08/05/doing-it-right-skipping-the-iphone-url-bar/">Remy Sharp&#8217;s post</a> for more details.</p>
<h4>window.matchMedia()</h4>
<p>(iOS 5+) Again, just as CSS media queries aren&#8217;t specific to mobile, they do come in especially useful for mobile, so it&#8217;s worth mentioning their JavaScript counterpart.  window.matchMedia() is a JavaScript-based version of media queries.  You can use <a href="https://github.com/scottjehl/Respond">respond.js</a> as a polyfill for devices that don&#8217;t support this functionality natively.</p>
<h4>navigator.connection</h4>
<p>(Android 2.2+) Determine if the phone is running on WiFi, 3G, etc.  Example:
<pre name="code" class="JScript">
if (navigator.connection.type==navigator.connection.WIFI) {
  // code for WiFi connections (high-bandwidth)
}
</pre>
<h4>window.devicePixelRatio</h4>
<p>Determine screen resolution (analogue to the CSS media query).  (iPhone 4 has the value 2, while Nexus One has the value 1.5).</p>
<h4>window.navigator.onLine</h4>
<p>Not strictly mobile, but helpful for apps to determine if they&#8217;re being run offline.</p>
<h4>window.navigator.standalone</h4>
<p>(iOS 2.1+): determine if it&#8217;s running in full-screen mode</p>
<h4>Touch and gesture events</h4>
<p><a href="http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/handlingevents/handlingevents.html">touch events (iOS, Android 2.2+)</a>: touchstart, touchmove, touchend, touchcancel</p>
<p><a href="http://developer.apple.com/safari/library/documentation/internetweb/conceptual/safarivisualeffectsprogguide/InteractiveVisualEffects/InteractiveVisualEffects.html">gesture events (Apple only, iOS 2+)</a>: gesturestart, gesturechange, gesturend give access to predefined gestures (rotation, scale, position)</p>
<h4>Screen orientation (every 90 degrees)</h4>
<p><a href="http://ajaxian.com/archives/iphone-windowonorientationchange-code">orientationchange event</a>: triggered every 90 degrees of rotation (portrait and landscape modes).  The current orientation is available through window.orientation</p>
<h4>Device orientation (more fine-grained)</h4>
<p>The <a href="http://frontendstuff.com/javascript/examples/deviceorientation.html">deviceorientation event</a> will fire very frequently, and gives more fine-grained information about the device&#8217;s orientation in three dimensions.<br />
<a href="https://developer.mozilla.org/en/Detecting_device_orientation">MozOrientation</a> (or onmozorientation?) (Fennec/Firefox Mobile, Firefox 3.5+): also not strictly mobile.  Gives access to the device&#8217;s accelerometer (x-y-z orientation data), updated periodically.  Works on Android phones running Mobile Firefox.  On the desktop this works with laptops such as Thinkpads and MacBooks.</p>
<h4>devicemotion (shake gestures, etc.)</h4>
<p><a href="http://frontendstuff.com/javascript/examples/devicemotion.html">devicemotion</a> fires when the user shakes or moves their device.  Devicemotion taps into the accelerometer, which is fires off when the device accelerates.  Contrast this with the deviceorientation event, which taps into the device&#8217;s gyroscope (if it has one), which only measures the 3D angle orientation, even when the device is at rest.</p>
<h4>Media capture API</h4>
<p>While iOS is still lacking basic file inputs, Android is forging ahead, giving developers fine-grained control over content users can upload.</p>
<pre name="code" class="html">
&lt;!-- regular file upload (Android 2.2+, NO iOS) --&gt;
&lt;input type=&quot;file&quot;&gt;&lt;/input&gt;

&lt;!-- opens directly to the camera (Android 3.0+) --&gt;
&lt;input type=&quot;file&quot; accept=&quot;image/*;capture=camera&quot;&gt;&lt;/input&gt;

&lt;!-- opens directly to the camera in video mode (Android 3.0+) --&gt;
&lt;input type=&quot;file&quot; accept=&quot;video/*;capture=camcorder&quot;&gt;&lt;/input&gt;

&lt;!-- opens directly to the audio recorder (Android 3.0+) --&gt;
&lt;input type=&quot;file&quot; accept=&quot;audio/*;capture=microphone&quot;&gt;&lt;/input&gt;
</pre>
<h4>BlackBerry specific</h4>
<p>If you&#8217;re developing for a BlackBerry Widget, you have access to proprietary information through the <a href="http://www.blackberry.com/developers/docs/widgetapi/Summary_system.html">blackberry object</a> (which gives access to useful information such as blackberry.network [returns values such as CDMA and Wi-Fi] and blackberry.system).</p>
<p>You also have the option to use <a href="http://phonegap.com/">PhoneGap</a>, which augments JavaScript and gives you access to more phone features that native apps would have access to.</p>
<h3>Use a mobile-optimized JavaScript library</h3>
<p>I&#8217;ve created <a href="http://davidbcalhoun.com/2010/mobile-javascript-libraries-and-frameworks">a separate entry for the available mobile libraries and frameworks</a>.</p>
<p>Because smartphone browsers are standards-based, the aim of a JavaScript library on mobile is less towards API normalization and more towards providing an actual UI framework, usually to emulate the feel of native apps (and to provide easier workarounds to <a href="http://doctyper.com/archives/200808/fixed-positioning-on-mobile-safari/">lack of access to position:fixed</a>).  We&#8217;ve seen a few libraries released that emulate the iPhone UI, and in the future we might see libraries emulating the Android UI, as well as entirely new UIs.</p>
<p>There&#8217;s also a bit to be said about simply loading full desktop JavaScript libraries into mobile clients.  In my opinion this doesn&#8217;t particularly make sense, especially in a world where latency and bandwidth are so much more of a concern.  It doesn&#8217;t make sense to force the user wait longer and download code that&#8217;s ultimately useless to them (hacks for desktop browsers such as IE 6, etc).</p>
<h3>Take advantage of new stuff!</h3>
<p>While not specific to mobile, there&#8217;s a lot of new stuff in general that you can use.  If you limit yourself to the top smartphones (iPhone, Android, and maybe webOS), compared to the desktop you immediately have access to an even wider array of new stuff, especially many Webkit proprietary features, since most of these top smartphones have browsers based on Webkit.</p>
<p>-HTML: new tags (<a href="http://diveintohtml5.org/">HTML5</a> (I&#8217;m sure you&#8217;ve heard of it by now…))<br />
-CSS: <a href="http://webkit.org/blog/130/css-transforms/">2d transforms</a>, <a href="http://webkit.org/blog/386/3d-transforms/">3d transforms</a>, animation, <a href="http://border-radius.com/">border radius</a>, <a href="https://developer.mozilla.org/en/css/@font-face">custom fonts with @font-face</a>, etc.<br />
-JavaScript: <a href="http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/">strict mode</a>, <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Constants">constants</a>, <a href="http://davidbcalhoun.com/2009/javascript-tidbit-block-scope-with-let">block scope</a>, <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Date">Date.now()</a>, etc.</p>
<h3>Slides</h3>
<div style="width:425px" id="__ss_7424222"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/franksvalli/mobile-html-css-and-javascript" title="Mobile HTML, CSS, and JavaScript">Mobile HTML, CSS, and JavaScript</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/7424222" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/franksvalli">franksvalli</a> </div>
</p></div>
<h3>More from the Mobile Web series:</h3>
<p><a href="http://davidbcalhoun.com/2010/viewport-metatag">Part 1: The viewport metatag</a><br />
<a href="http://davidbcalhoun.com/2010/the-mobile-developers-toolkit-mobile-web-part-2">Part 2: The mobile developer’s toolkit</a><br />
<a href="http://davidbcalhoun.com/2010/designing-buttons-that-dont-suck">Part 3: Designing buttons that don’t suck</a><br />
<a href="http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage">Part 4: On designing a mobile webpage</a><br />
<a href="http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript">Part 5: Using mobile-specific HTML, CSS, and JavaScript</a><br />
<a href="http://davidbcalhoun.com/2010/dealing-with-device-orientation">Part 6: Dealing with device orientation</a><br />
<a href="http://davidbcalhoun.com/2010/mobile-javascript-libraries-and-frameworks">Part 7: Mobile JavaScript libraries and frameworks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript/feed</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>JavaScript SunSpider: HTC Evo versus HTC Incredible versus Nexus One</title>
		<link>http://davidbcalhoun.com/2010/javascript-sunspider-htc-evo-versus-htc-incredible-versus-nexus-one</link>
		<comments>http://davidbcalhoun.com/2010/javascript-sunspider-htc-evo-versus-htc-incredible-versus-nexus-one#comments</comments>
		<pubDate>Fri, 11 Jun 2010 05:07:11 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[performance]]></category>
		<category><![CDATA[htc evo]]></category>
		<category><![CDATA[htc incredible]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[nexus one]]></category>
		<category><![CDATA[sunspider]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=292</guid>
		<description><![CDATA[Result table Test Evo (2.1) Incredible (2.1) Nexus One (2.2) Total 16167ms 15237ms 5452ms 3D 2014ms 1835ms 946ms Access 2126ms 1892ms 463ms Bitops 1519ms 1591ms 360ms Controlflow 243ms 206ms 20ms Crypto 1033ms 1003ms 344ms Date 1849ms 1896ms 639ms Math 1684ms 1419ms 602ms Regexp 1779ms 1673ms 155ms String 3920ms 3722ms 1923ms Thoughts The Incredible is just [...]]]></description>
			<content:encoded><![CDATA[<h3>Result table</h3>
<table>
<thead>
<tr>
<td>Test</td>
<td>Evo (2.1)</td>
<td>Incredible (2.1)</td>
<td>Nexus One (2.2)</td>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr>
<td>Total</td>
<td>16167ms</td>
<td>15237ms</td>
<td class="positive">5452ms</td>
</tr>
<tr>
<td>3D</td>
<td>2014ms</td>
<td>1835ms</td>
<td class="positive">946ms</td>
</tr>
<tr>
<td>Access</td>
<td>2126ms</td>
<td>1892ms</td>
<td class="positive">463ms</td>
</tr>
<tr>
<td>Bitops</td>
<td>1519ms</td>
<td>1591ms</td>
<td class="positive">360ms</td>
</tr>
<tr>
<td>Controlflow</td>
<td>243ms</td>
<td>206ms</td>
<td class="positive">20ms</td>
</tr>
<tr>
<td>Crypto</td>
<td>1033ms</td>
<td>1003ms</td>
<td class="positive">344ms</td>
</tr>
<tr>
<td>Date</td>
<td>1849ms</td>
<td>1896ms</td>
<td class="positive">639ms</td>
</tr>
<tr>
<td>Math</td>
<td>1684ms</td>
<td>1419ms</td>
<td class="positive">602ms</td>
</tr>
<tr>
<td>Regexp</td>
<td>1779ms</td>
<td>1673ms</td>
<td class="positive">155ms</td>
</tr>
<tr>
<td>String</td>
<td>3920ms</td>
<td>3722ms</td>
<td class="positive">1923ms</td>
</tr>
</tbody>
</table>
<h3>Thoughts</h3>
<p>The Incredible is just slightly faster than the Evo, to the point where it&#8217;s probably negligible or within a margin of error.  Both of these phones run on Android 2.1 with HTC&#8217;s Sense UI modifications, and represent the latest and greatest in Android phones available on the market today.  Both run on the same 1GHz Snapdragon processor (QSD8650). The Nexus One is a bit older, and runs with an older version of the Snapdragon processor (QSD8250), however it still runs at 1GHz just like the other two phones.</p>
<p>As you can see the Nexus One blows away all the competition because it&#8217;s running Android 2.2 Froyo.  These results were quite a shock to me and are quite impressive.  These results even blow away Apple&#8217;s new iOS 4 running on my iPhone 3GS, which clocked in at a total time of 13787ms compared to the Nexus One&#8217;s startling 5452ms.</p>
<h3>Testing methodology</h3>
<p>Test: <a href="http://www2.webkit.org/perf/sunspider-0.9.1/sunspider-0.9.1/driver.html">SunSpider 0.9.1</a></p>
<p>Devices: HTC Evo (Android 2.1), HTC Incredible (Android 2.1), HTC Nexus One (Android 2.2)</p>
<p>The SunSpider test was run five times on each phone.  The phone was completely turned off and on before each test.  The most extreme values of the five tests were thrown out, and the resulting four tests were averaged (sometimes from three tests when the values were very close together).</p>
<p>Raw results:</p>
<p><a href="http://davidbcalhoun.com/wp-content/uploads/2010/sunspider-htc-evo.html">SunSpider HTC Evo results (5 tests)</a></p>
<p><a href="http://davidbcalhoun.com/wp-content/uploads/2010/sunspider-htc-incredible.html">SunSpider HTC Incredible results (5 tests)</a></p>
<p><a href="http://davidbcalhoun.com/wp-content/uploads/2010/sunspider-nexus-one.html">SunSpider HTC Nexus One results (5 tests)</a></p>
<h3>Related links</h3>
<p><a href="http://davidbcalhoun.com/2010/sunspider-ios-3-1-3-versus-ios-4-gm">JavaScript SunSpider test: iOS 3.1.3 versus iOS 4 GM</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/javascript-sunspider-htc-evo-versus-htc-incredible-versus-nexus-one/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mobile First: Luke Wroblewski on mobile design</title>
		<link>http://davidbcalhoun.com/2010/mobile-first-luke-wroblewski-on-mobile-design</link>
		<comments>http://davidbcalhoun.com/2010/mobile-first-luke-wroblewski-on-mobile-design#comments</comments>
		<pubDate>Sat, 05 Jun 2010 19:12:26 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=268</guid>
		<description><![CDATA[In episode 6 of The Big Web Show, Luke Wroblewski gives his &#8220;Mobile First&#8221; talk, explaining his philosophy for designing for mobile, the challenges, and a look at the road ahead. Luke explains that because of the limitations on mobile, developers are forced to really optimize the user experience for mobile. Often times this mobile [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://5by5.tv/bigwebshow/6"><img src="http://davidbcalhoun.com/wp-content/uploads/2010/06/luke-wroblewski-mobile-first1.png" alt="Click to play Luke Wroblewski: Mobile First" title="Click to play Luke Wroblewski: Mobile First" width="474" height="285" class="aligncenter size-full wp-image-271" /></a></p>
<p>In <a href="http://5by5.tv/bigwebshow/6">episode 6 of The Big Web Show</a>, <a href="//lukew.com/">Luke Wroblewski</a> gives his &#8220;Mobile First&#8221; talk, explaining his philosophy for designing for mobile, the challenges, and a look at the road ahead.  Luke explains that because of the limitations on mobile, developers are forced to really optimize the user experience for mobile.  Often times this mobile experience turns out much better than on the desktop, where the &#8220;gluttony of resources&#8221; results in distracting and excessive webpages.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/mobile-first-luke-wroblewski-on-mobile-design/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On designing a mobile webpage (Mobile web part 4)</title>
		<link>http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage</link>
		<comments>http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage#comments</comments>
		<pubDate>Thu, 27 May 2010 02:58:17 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=242</guid>
		<description><![CDATA[The frontend engineer lives at the intersection between design and engineering, and this is perhaps nowhere more true than in the world of mobile. In order to make a usable desktop website, an engineer must have at least some sense of design, and fortunately a lot of this has been standardized over the years. But [...]]]></description>
			<content:encoded><![CDATA[<p>The frontend engineer lives at the intersection between design and engineering, and this is perhaps nowhere more true than in the world of mobile.  In order to make a usable desktop website, an engineer must have at least some sense of design, and fortunately a lot of this has been standardized over the years.  But the world of mobile is full of more unknowns, and the field is changing rapidly, especially lately from the shift away from older feature phones to the focus on smartphones.  As such, the mobile engineer has to be on their toes in the sense of both design and engineering.</p>
<p>The focus of this article is on mobile design in general.  I&#8217;m by no means an expert, but these are some things I&#8217;ve found to be essential and basic topics.  Hopefully you will find this useful!</p>
<h3>Only one column?</h3>
<p>Mobile websites should only have one column of main content.  This point is stressed again and again in mobile design, and for good reason: the paradigm of multi-column layouts is fairly well-entrenched in desktop design, but it&#8217;s simply not an option for a well-designed mobile site.</p>
<p>To illustrate this point, the following two images are both 320 pixels wide, which is a common smartphone width in portrait mode.  The image on the left is the Yahoo! front page (<a href="http://yahoo.com">yahoo.com</a>) in its three-column fixed width desktop size, and the image on the right is Yahoo! mobile&#8217;s front page (<a href="http://m.yahoo.com">m.yahoo.com</a>):</p>
<p><img src="http://davidbcalhoun.com/wp-content/uploads/2010/05/yahoo-frontpage.jpg" alt="" title="Yahoo desktop front page" width="320" height="288" class="alignleft size-full wp-image-243 left-margin-large" style="padding: 0 0 6em 0;" /><img src="http://davidbcalhoun.com/wp-content/uploads/2010/05/yahoo-mobile.jpg" alt="" title="Yahoo Mobile front page" width="320" height="482" class="alignleft size-full wp-image-244 left-margin-large" /></p>
<p>This might not be a fair comparison, as the desktop version isn&#8217;t optimized for mobile, so you can&#8217;t even read the text without zooming in.  However, even if the size of the text was increased, it&#8217;s apparent that three columns is just too much, both because of screen width concerns as well as concerns about too much content.  There&#8217;s simply too much information being crammed down the user&#8217;s throat.  Chances are the user only wants to check a few things and then put the phone back in their pocket, and this three-column version of the site is preventing them from doing that.</p>
<h3>Modules, modules, modules</h3>
<p>It&#8217;s helpful to think of a webpage as being composed of modules.  If you&#8217;re converting a desktop website into a mobile site then you must essentially think of the website as bits of rearrangeable components:</p>
<img src="http://davidbcalhoun.com/wp-content/uploads/2010/05/mobile-modules.png" alt="" title="Components of a website, broken into modules" width="774" height="479" class="size-full wp-image-253" />
<p>What you&#8217;re doing is essentially grabbing your most important components and making sure they appear at the top, then stacking each module on top of each other.  And don&#8217;t forget we do have variable screen widths on mobile (even on phones themselves, since they can be either in portrait or landscape mode), so we should be sure that each module is taking up 100% of the available screen space.  In more technical terms, yes, this means we have to make a fluid layout.</p>
<h3>Clarity and concision</h3>
<p>It&#8217;s important to be both clear and concise in presentation.  On the desktop we can get away with a certain amount of screen bloat, but users always appreciate simple sites when they come across them.  This is a huge part of what made Google so successful: users came to the site for one thing, search, and the site was kept simple to facilitate that interaction.</p>
<p>As it turns out, it&#8217;s quite hard to be clear and concise.  I like to compare this to writing papers for school.  Often we were given assignments that needed to be a minimum of X amount of words or pages, and it was sometimes challenging to find information to meet this minimum.  Fortunately (or unfortunately) many students developed a highly refined skill of BSing to fill the word limit.  But were you ever given an assignment where there was a word/page MAXIMUM?  This turns out to be much harder to write for, mostly because you can&#8217;t BS it.  You have to identify the fluff, the nonessential bits, and surgically remove them from your paper.  (As a side note, in the area of computer science, notice how many HUGE tomes there are out there compared to smaller books.  I would venture to guess that engineers have a hard time being concise.)</p>
<p>This is just the problem we now face with mobile.  We know how to fill up webpages with fluff: add an RSS feed here, add a module that ties into Facebook there, add another feed here, stick a relatively unimportant module there, add an excessive amount of social sharing buttons, and presto, we have a website that looks pretty active.  But how does that translate to mobile?  The questions you&#8217;re forced to ask yourself are: &#8220;do I really need this data feed displayed here?&#8221;, &#8220;do I need this huge Facebook module here taking up space?&#8221;.  Or more positive questions like &#8220;what are the things users will come to my site to check, and how do I make it easier for them to find those things?&#8221;.</p>
<p>In the case of the last question, it&#8217;s easy to see from the above screenshots what Yahoo mobile thought was most important: Mail, Search, and News, all of which are visible at the top of the page.  Think about your website&#8217;s main two or three features and try to make those just as visible.</p>
<h3>Useful links</h3>
<p><a href="http://www.w3.org/TR/mobile-bp/">W3C Mobile Web Best Practices 1.0</a><br />
<a href="http://carsonified.com/blog/dev/tips-and-tricks-for-developing-mobile-widgets/">Tips and Tricks for developing Mobile Widgets</a></p>
<h3>More from the Mobile Web series:</h3>
<p><a href="http://davidbcalhoun.com/2010/viewport-metatag">Part 1: The viewport metatag</a><br />
<a href="http://davidbcalhoun.com/2010/the-mobile-developers-toolkit-mobile-web-part-2">Part 2: The mobile developer’s toolkit</a><br />
<a href="http://davidbcalhoun.com/2010/designing-buttons-that-dont-suck">Part 3: Designing buttons that don’t suck</a><br />
<a href="http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage">Part 4: On designing a mobile webpage</a><br />
<a href="http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript">Part 5: Using mobile-specific HTML, CSS, and JavaScript</a><br />
<a href="http://davidbcalhoun.com/2010/dealing-with-device-orientation">Part 6: Dealing with device orientation</a><br />
<a href="http://davidbcalhoun.com/2010/mobile-javascript-libraries-and-frameworks">Part 7: Mobile JavaScript libraries and frameworks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The viewport metatag (Mobile web part 1)</title>
		<link>http://davidbcalhoun.com/2010/viewport-metatag</link>
		<comments>http://davidbcalhoun.com/2010/viewport-metatag#comments</comments>
		<pubDate>Fri, 07 May 2010 05:11:44 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[handheldfriendly]]></category>
		<category><![CDATA[metatag]]></category>
		<category><![CDATA[mobileoptimized]]></category>
		<category><![CDATA[viewport]]></category>

		<guid isPermaLink="false">http://davidbcalhoun.com/?p=198</guid>
		<description><![CDATA[The skinny Use this: &#60;meta name=&#34;viewport&#34; content=&#34;width=device-width, initial-scale=1.0&#34;/&#62; Introduction This series of posts is intended to introduce web developers to basic techniques for designing for the mobile web. It assumes at least a basic knowledge of creating desktop websites. The problem Ok, so you&#8217;ve settled down to learn how to write a website for a [...]]]></description>
			<content:encoded><![CDATA[<h3>The skinny</h3>
<p>Use this:</p>
<pre name="code" class="html">
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt;
</pre>
<h3>Introduction</h3>
<p>This series of posts is intended to introduce web developers to basic techniques for designing for the mobile web.  It assumes at least a basic knowledge of creating desktop websites.</p>
<h3>The problem</h3>
<p>Ok, so you&#8217;ve settled down to learn how to write a website for a mobile device using your current knowledge of building desktop websites.  So you start off with some pretty basic HTML:</p>
<pre name="code" class="html">
&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Hello world!&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;p&gt;Hello world!&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Ok!  You can&#8217;t get much simpler than that.  You check it out and it looks good on all the desktop browsers, since there&#8217;s really no opportunity yet for any cross-browser inconsistencies.  And then you check it out on your mobile device:<br />
<div id="attachment_199" class="wp-caption aligncenter" style="width: 320px"><a href="http://davidbcalhoun.com/wp-content/uploads/2010/05/hello-world-iphone.png"><img src="http://davidbcalhoun.com/wp-content/uploads/2010/05/hello-world-iphone.png" alt="" title="hello-world-iphone" width="320" height="480" class="size-full wp-image-199" /></a><p class="wp-caption-text">Hello World on the iPhone</p></div></p>
<p>Doh!  Where&#8217;d we go wrong?  The text is obviously way too small to read without zooming in.</p>
<p>This is the first lesson in making mobile websites: width is your enemy.  This is the first of many countless problems with device width you will encounter.  Fair warning.</p>
<p>If you think about it logically, it seems to make sense: mobile Safari took a look at the page and assumed it was a document designed for the desktop, which is true of the vast majority of websites.  So it gave the website a width of 980 pixels and presented it zoomed out.  Which is why we can&#8217;t read anything until we zoom into the page.</p>
<h3>Viewport</h3>
<p>But this is no good!  What we need to do is tell the browser that this webpage is optimized for mobile.  And this is where the viewport metatag comes into the picture.</p>
<p>Now we tweak our Hello World just a bit&#8230;</p>
<pre name="code" class="html">
&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Hello world!&lt;/title&gt;

    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;/&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;p&gt;Hello world!&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And we get this&#8230;<br />
<div id="attachment_203" class="wp-caption aligncenter" style="width: 320px"><a href="http://davidbcalhoun.com/wp-content/uploads/2010/05/hello-world-viewport-iphone.png"><img src="http://davidbcalhoun.com/wp-content/uploads/2010/05/hello-world-viewport-iphone.png" alt="" title="hello-world-viewport-iphone" class="aligncenter size-full wp-image-203" width="320" height="480" /></a><p class="wp-caption-text">Hello World with the Viewport tag</p></div></p>
<p>Much better!  By setting the viewport width equal to &#8220;device-width&#8221;, we&#8217;re essentially telling it that the device width is 320px, not the default value of 980px that it guessed.  If we set width=320 it would achieve the same result on the iPhone and a few other smartphones, but not all phones have this exact width, so it&#8217;s best to simply set device-width and let the mobile browser figure it out.</p>
<p>This viewport metatag is supported on many smartphones, from iPhone to Android to webOS (Palm) to even Internet Explorer Mobile, Opera Mini and Opera Mobile.</p>
<p>At the end of the day here&#8217;s what the standard viewport looks like, as grabbed from <a href="http://m.yahoo.com">m.yahoo.com</a>:</p>
<pre name="code" class="html">
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot;/&gt;
</pre>
<p>EDIT: It&#8217;s been discussed a bit, and it seems that preventing the user from scaling the page (pinch zooming) isn&#8217;t necessarily desirable.  So here&#8217;s a version of the tag that allows the user to pinch zoom:</p>
<pre name="code" class="html">
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt;
</pre>
<h3>More fun with the viewport tag</h3>
<p>In addition to solving our biggest concern with the width of the content, the viewport tag has more options to play with:</p>
<table class="datatable-medium">
<thead>
<tr>
<td>Property</td>
<td>Description</td>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr>
<td>width</td>
<td>Width of the viewport in pixels (or device-width).  If width isn&#8217;t set, it defaults to a desktop size (980px on mobile Safari).</td>
</tr>
<tr>
<td>height</td>
<td>Height of the viewport in pixels (or device-height).  Generally you don&#8217;t need to worry about setting this property.</td>
</tr>
<tr>
<td>initial-scale</td>
<td>(0 to 10.0) Multiplier that sets the scale of the page after its initial display.  Safe bet: if you need to set it, set it to 1.0.  Larger values = zoomed in, smaller values = zoomed out</td>
</tr>
<tr>
<td>minimum-scale</td>
<td>(0 to 10.0) The minimum multiplier the user can &#8220;zoom out&#8221; to.  Defaults to 0.25 on mobile Safari.</td>
</tr>
<tr>
<td>maximum-scale</td>
<td>(0 to 10.0) The minimum multiplier the user can &#8220;zoom in&#8221; to.  Defaults to 1.6 on mobile Safari.</td>
</tr>
<tr>
<td>user-scalable</td>
<td>(yes/no) Whether to allow a user from scaling in/out (zooming in/out).  Default to &#8220;yes&#8221; on mobile Safari.</td>
</tr>
</tbody>
</table>
<h3>Feature phones: when viewport isn&#8217;t available&#8230;</h3>
<p>Unfortunately the viewport tag is relatively new and as such isn&#8217;t universally supported, especially if you&#8217;re working on older feature phones.  But there are some older methods at your disposal for identifying your website as optimized for mobile:</p>
<pre name="code" class="html">
&lt;meta name=&quot;HandheldFriendly&quot; content=&quot;true&quot;/&gt;
</pre>
<p>This tag was originally used to identify mobile content in AvantGo browsers, but has now been made the general standard for identifying mobile websites.  However, it&#8217;s unknown what range of browsers support this meta tag.</p>
<p>Another tag at your disposal is a Windows-proprietary meta tag that also took root and eventually became used as another means of identifying mobile content.  The drawback with this tag is that a specific width must be given, which doesn&#8217;t make it as flexible as the viewport tag (see above).  Again, it&#8217;s unknown what the support for this tag is:</p>
<pre name="code" class="html">
&lt;meta name=&quot;MobileOptimized&quot; content=&quot;320&quot;/&gt;
</pre>
<p>Lastly, your website will be identified as a mobile optimized site if your doctype is either XHTML-MP or WML.  However, this is becoming less and less the case these days, as browsers begin to support good old HTML4.01 and HTML5+.</p>
<p>(info for this section comes from <a href="http://www.amazon.com/gp/product/B003U890OQ/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=486539851&#038;pf_rd_s=lpo-top-stripe-1&#038;pf_rd_t=201&#038;pf_rd_i=143022620X&#038;pf_rd_m=ATVPDKIKX0DER&#038;pf_rd_r=017307F07YKBPJX46DXB">Beginning Smartphone Web Development</a>)</p>
<h3>Custom Android properties</h3>
<p><a href="http://developer.android.com/reference/android/webkit/WebView.html">The official Android documentation</a> lists a special property they&#8217;ve added to the meta tag: target-densitydpi.  This property essentially allows developers to specify which screen resolution the page has been developed for, or more specifically how to handle the scaling of media such as images.</p>
<p>Here&#8217;s an example of the tag in action:</p>
<pre name="code" class="HTML">
&lt;meta name=&quot;viewport&quot; content=&quot;target-densitydpi=device-dpi&quot; /&gt;
</pre>
<h3>References</h3>
<p><a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html">Safari HTML Reference: Supported Meta Tags</a><br />
<a href="http://learnthemobileweb.com/tag/mobile-web-development/page/3/">Mobile META Tags</a></p>
<h3>More from the Mobile Web series:</h3>
<p><a href="http://davidbcalhoun.com/2010/viewport-metatag">Part 1: The viewport metatag</a><br />
<a href="http://davidbcalhoun.com/2010/the-mobile-developers-toolkit-mobile-web-part-2">Part 2: The mobile developer’s toolkit</a><br />
<a href="http://davidbcalhoun.com/2010/designing-buttons-that-dont-suck">Part 3: Designing buttons that don’t suck</a><br />
<a href="http://davidbcalhoun.com/2010/on-designing-a-mobile-webpage">Part 4: On designing a mobile webpage</a><br />
<a href="http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript">Part 5: Using mobile-specific HTML, CSS, and JavaScript</a><br />
<a href="http://davidbcalhoun.com/2010/dealing-with-device-orientation">Part 6: Dealing with device orientation</a><br />
<a href="http://davidbcalhoun.com/2010/mobile-javascript-libraries-and-frameworks">Part 7: Mobile JavaScript libraries and frameworks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidbcalhoun.com/2010/viewport-metatag/feed</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

