Mobile Web

From BC$ MobileTV Wiki
Revision as of 19:10, 21 September 2015 by Joe (Talk | contribs)

Jump to: navigation, search

The Mobile Web (also refered to as the Mobile Internet) is currently a minimized version of the current world wide web, however many have claimed that until the functionality and capabilities of the Mobile Web and the devices which access it improve, it may be relegated to a scarcely used version of the full Web.




Automatically set the page width to the device's physically available screen width/resolution:

<meta name="viewport" content="width=device-width" />


Disallow pinch/zoom (not a good move for accessibility reasons, but in the right context to maintain screen to content ratios for a particular experience):

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />



Specify the media type to render mobile-specific styles:

<link type="text/css" rel="stylesheet" href="style/mobile.css" media="handheld" />


media Attribute

The CSS spec actually defines a number of device profiles, however, reliance on these as the only method of deciding device dimensions and presentation can be prone to errors as not all devices and browsers respect or follow the standards in this regard. Some may report the wrong profile or no profile at all.


<link type="text/css" rel="stylesheet" href="css/projector.css" media="projection" />


<link type="text/css" rel="stylesheet" href="css/desktop.css" media="screen" />


<link type="text/css" rel="stylesheet" href="css/tv.css" media="tv" />

Mobile device (i.e. Smartphone, Cellphone, etc):

<link type="text/css" rel="stylesheet" href="css/mobile.css" media="handheld" />


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

Printer and other print devices or software (such as a PDF converter, screenshot saver, etc):

<link type="text/css" rel="stylesheet" href="css/printer.css" media="print" />

@media Queries

You can also use the above technique of Media queries inline within <style> tags, or inside of an externally loaded CSS file itself:

 @media handheld {
   .container {
	padding: 0;
	margin: 0;
        width: 100%; /* use % widths to prevent content overflows/resizes on mobile */
   .left {
	padding: 0;
	margin: 0;
        width: 20%;
   .right {
	padding: 0;
	margin: 0;
        width: 80%;


Another useful trick is to be able to make an image or lengthy or secondary content section (i.e. within an ASIDE, DIV or P tag) appear only on orientation change:

 .sidebar div { background:url(/img/huge.png) }
 @media only screen and (max-device-width: 480px) {
   .sidebar { display:none }
 @media only screen and (max-device-width: 480px) and (orientation: landscape) {
   .sidebar { display:block }
   .sidebar div { background:url(/img/small.png) }


Here's a full list of common queries for different screen resolutions and physical device sizes (organized in order of size, biggest to smallest).

Projectors such as in a home theater system, Work office presentation or board room, or Public Advertisement Display screens (expect HD, inability to read small text and changing dimensions => 2048x1536 and up, even iPad now has these specs with its retina display at 264 pixels per inch (ppi))[22]

TVs such as "Smartscreens", Google TV, Connected TVs, etc... (typically a widescreen with HD and retina display ==> 1920x1080)

Business, Hardcore Gaming or Developer Computers (usually use widescreen and/or dual screen display ==> 1680x1050)

@media only screen and (max-width: 959px) {  } 

Desktops and Laptops (most home PC & Mac users fall into this category ==> 1024x768)[23]

@media only screen and (max-width: 959px) {  } 

Desktops, Laptops or Netbooks with Smaller than standard 960 pixels wide ( ==> 800x600):

@media only screen and (max-width: 959px) {  }

Tablet Portrait size to standard 960 (tablets and browsers ==> 800x1200):[24]

@media only screen and (min-width: 768px) and (max-width: 959px) {  }

All Smartphone Mobile Sizes (typically only high-end smartphones approach this max-width ==> 640x480) and Tablet Landscape (lower-end portable devices and browsers ==> 600x1024):

 @media only screen and (max-width: 767px) {  }

Mobile Landscape Size (horizontal, left-to-right ==> 480x360) to Tablet Portrait (devices and browsers ==> 480x800):

 @media only screen and (min-width: 480px) and (max-width: 767px) {  }

Mobile Portrait Size (vertical, top-to-bottom ==> 1680x1050) to Mobile Landscape Size (devices and browsers ==> 320x240):

 @media only screen and (max-width: 479px) {  }

Legacy Mobile Phones, these old devices were believe it or not "phones" before they were portable entertainment centers or business tools and range widely in physical screen size, but typically only support video at 176x144:

 @media only screen and (max-width: 320px) {  }


User-Agent string matching or checking can be done to determine on the server-side (or client-side) whether the user is accessing your site via a Mobile Device or larger screened Desktop. This method is subject to abuse though as the User-Agent can be spoofed, hidden, missing (i.e. old device or stripped down) or just plain inaccurate, and should be considered unreliable. However, it can still be used for "suggested" redirecting or basic device/capability checking. Important variables include:

  • navigator.userAgent
  • navigator.appName
  • navigator.appVersion

To list out all User-Agent related information, use the following:

 for (i in navigator) {
  document.write('<br />navigator.' + i + ' = ' + navigator[i]);

[25] [26] [27]

 $mobile_browser = '0';
 if (preg_match('/(up.browser||mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
 if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
    'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
    'wapr','webc','winw','winw','xda ','xda-');
 if (in_array($mobile_ua,$mobile_agents)) {
 if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {
 if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) {
    $mobile_browser = 0;
 if ($mobile_browser > 0) {
   // do something
 else {
   // do something else

[28] [29]

Responsive Design

Responsive Design uses a combination of methods (including )




External Links


  1. Mobile Web Application Best Practices:
  2. wikipedia: HTML5 in mobile devices
  3. CSS3:
  4. HTML5 from a Mobile Perspective:
  5. How to Create HTML5 iPhone Applications:
  6. CSS Mobile Profile 2.0:
  7. wikipedia: XHTML Mobile Profile
  8. Mobile Web Best Practices 1.0:
  9. W3C mobileOK Basic Tests 1.0:
  10. Comparison of XHTML Mobile Profile and XHTML Basic:
  11. wikipedia: i-Mode
  12. NTT DoCoMo - iMode official site:
  13. W3C - WAP Binary XML Content Format:
  14. WAP flap zaps spec credibility:
  15. An introduction to meta viewport and @viewport:
  16. Mobile Dimensions via CSS/META:
  17. Viewports:
  18. Table viewport:
  19. Responsive Web Design:
  20. CSS contents and browser compatibility - mobile:
  21. Sirens - CSS for adaptable content that responds to orientation changes:
  22. iPad 3 .vs. iPad 2 specs:
  23. Screen resolution - web usage statistics:
  24. RIM PlayBook vs Apple iPad:
  25. Using the navigator object to detect client's browser:
  26. Auto detect mobile browser (via user-agent?):
  27. Browser detect:
  28. Lightweight Device-Detection in PHP:
  29. Mobile Device Detection and Redirection with PHP:
  30. iPhone Tester:
  31. iPad Simulator:
  32. WebTelephony API and WebSMS API – Part of WebAPI:
  33. Delivering the right experience to the right device:

See Also

Mobile Internet | Mobile | Web | Optimization