Tuesday, 5 April 2011

Mobile web design viewport size vs screen resolution - viewport META tag

In a previous post I mentioned the various screen resolutions of popular mobile phones. Today I'll mention how the screen size and viewport may be different!
So, what is a viewport?
The viewport for web design is defined as the rectangular area (measured in pixels) that is viewable on the screen and determines how the content is laid out and where text wraps or windows need to be scrolled to see the full webpage.

Isn't the viewport the same as the screen resolution?
For most devices the screen resolution/display size is equal to the viewport. This is true of desktop and laptop computers, however for mobile devices this may not be true!!

Many phone browsers scale web pages down to a wider viewport width to fit them onto the screen. This is sometimes called overview mode. These browsers allow the user to zoom in and scale the pages up to view the bit they want to see. For example, although a device screen might have a width of 320px the viewport can have a width of 980px. In this case a web page designed at 980px or less will fit completely on the screen.

The difficulty comes with different mobile devices and mobile browsers as they have different viewport sizes. Here is a short list of some popular mobile browser viewport sizes:

  • Opera Mobile browser viewport 850px
  • iPhone safari browser viewport 980px
  • iPad (landscape & portrait mode) viewport 980px
  • Android browser viewport 800px
  • IE mobile browser viewport 320px

This graphic shows the implication of various viewports on three different devices for the Web Devil blog (click to enlarge):


How to change the default viewport?
So now we know that the new breed of mobile devices and browsers each have their own viewport, how do we change it?  The answer is by using the viewport meta tag.
The viewport meta tag sits in the document head and is valid for these new devices.
It is possible to specify a fixed viewport (like the standard view of this blog):
<meta name="viewport"content="width=1100"/>

However for many webpages it's probably best to avoid hard coding a width.  This is because you don't know what devices are being used to view the web page.  Instead it's possible to define the default viewport width of the device:
<meta name="viewport" content="width=device-width"/>

It is also possible to change the scaling behaviour of the screen and whether the user is allowed to scale the page.  Syntax for the viewport content includes:

  • height = [pixel_value | device-height] ,
  • width = [pixel_value | device-width ] ,
  • initial-scale = float_value ,
  • minimum-scale = float_value ,
  • maximum-scale = float_value ,
  • user-scalable = [yes | no] ,
  • target-densitydpi = [dpi_value | device-dpi |high-dpi | medium-dpi | low-dpi]

Many phones have a different pixel density or dpi than the desktop 72dpi, so setting target-densitydpi=device-dpi is a good idea to prevent blurry images due to scaling effects.
The viewport meta tag for the touch sensitive sidebar version of this blog is:
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" />

What about older mobile phones?
As previously mentioned, all of this only works for new mobile devices. The older blackberry doesn't support it - it needs:
<meta name="HandheldFriendly" content="true"/>  

And the older Internet Explorer mobile needs:
<meta name="MobileOptimized" content="width" />

If you place all three meta tags (HandheldFriendly / MobileOptimized / viewport) then the mobile will pick the most current one that it understands.

For more details about targeting to the viewport of a device then the android developers guide has some good information at  developer.android.com/guide/webapps/targeting.html

If you've read this far then hopefully you now know that in mobile web design a pixel used for design isn't necessarily a pixel on the device!  To find out more about the size of various mobile device screens check out the following Web Devil post about mobile screen sizes.

Share/Bookmark

118 comments:

  1. Here is an interesting little tid-bit. Android (2.2) at least on my LG Optimus V phone will not allow scrolling it you use <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> as your viewport tag. Anyone else observe this. I guess that might be the point of the no-scale part. So what do we use for no-scaling but want scrolling? My pages work fine, you just can't scroll with the Android browser. Opera Mobile (on same phone) has no problem.

    ReplyDelete
  2. Update: found the holy grail for Android:
    http://developer.android.com/guide/webapps/targeting.html

    Still working on this, but the answer seems to lie with using just:
    <meta name="viewport" content="width=device-width" /> ...with or without initial scaling

    -or-

    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width" />

    ...which lets the page fill the viewport (as set to the device's physical screen width) at a browser defined screen density.

    Since I size my pages before the browser gets them, I just want them to display at 1:1 scale. Seems like such a simple thing, doesn't it. But no....

    ReplyDelete
  3. Update No. 2

    My bad. I found the problem. I had an errant "overflow-x:hidden;" in my reset.css file. With some more Googling, I found that this is a known issue with Android browser (others?) that overflow:auto or overflow hidden don't work like they do in desktop browsing. Sorry for all the erroneous posting.

    ReplyDelete
  4. Thanks for the informative tips shared here! Got only positive emotions and dozens of ideas that could be useful for my blog.
    mobile website development

    ReplyDelete
  5. This is good information. I am glad to read such a nice content. Keep sharing more. Good luck.
    mobile web development

    ReplyDelete
  6. Thanks for the guidance.The coding lines are very important.Making the site specially for the mobiles is not an easy task.We need to minimize the size of the page and accordingly we need arrange all the components.
    Website Design Bahrain

    ReplyDelete
  7. Really meaningful information about these applications and you are a great reviewer, I will definitely try these applications. Thanks a lot for spreading this information here.small business web design

    ReplyDelete
  8. Truly, this blog is very informative for Web design and about its creation...

    ReplyDelete
  9. I was looking a post like this before and I am very thankful that I found your blog. I will refer this to my friend. Thank you.



    web design Philippines

    ReplyDelete
  10. interesting blog. It would be great if you can provide more details about it. Thanks you

    Mobile Website Development

    ReplyDelete
  11. Hello, I love reading through your blog, I wanted to leave a little comment to support you and wish you a good continuation. Wish you best of luck for all your best efforts. Professional Web Designers In South Delhi, Best Web Designers In South Delhi.

    ReplyDelete
  12. Good design i like that and thank you for sharing the codes now it is so easy to use them ...
    Vertical Jump Bible

    ReplyDelete
  13. Thanks to provides a wide information about the mobile web design...

    ReplyDelete
  14. Thanks for this informative post! I really appreciated it :) cafe24 extension installation

    ReplyDelete
  15. The guidelines provided is awesome and must be followed to develop good applications. Thnaks for this. Iphone Development

    ReplyDelete
  16. Great post! It is very informative and very useful, Thanks for sharing this interesting information.web banner design

    ReplyDelete
  17. I am happy to found your blogs.It is really great.I learnt new things from your website.I like your thoughts.Thanks for making such a cool post.

    Hire a magento developer

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Great resource for mobile designers, thank you for the information. Being cyber Monday, it will be interesting to see how mobile devices are used today.

    Web Services DFW

    Paul -

    ReplyDelete
  20. Some people are confused with those two techie terms: viewport size and screen resolution. At least you helped them understand what each means.


    Joana Leighmoore

    ReplyDelete
  21. Thanks for sharing your ideas and thoughts, i like your blog and bookmark this blog for further use thanks again… Website Development Melbourne

    ReplyDelete
  22. I just want to ask one question. If I will use a site builder in creating my site. Does it automatically fit on a resolution of a mobile phone? Thanks!

    ReplyDelete
  23. y informative article you have got here. I love reading this kind of stuff. This is truly a great read for me. I hope to see more articles from you. web hosting companies

    ReplyDelete
  24. I would like to thank you for the efforts you have made in writing this article.
    Create an Online Store

    ReplyDelete
  25. Hi All,

    i am developing website for mobile with 320px width technology is Asp.Net,C# So i uploaded all my files on the sever when i am open my website on mobile "It is appearing too small every time i have to Zoom to see content and below horizontal bar is coming i dont want this horizontal bar And one more thing when i entered on mobile like www.example.com it should shift to m.example.com" if any one had faced these problems help me in this issues Thank you.

    ReplyDelete
  26. Thank you, for the great article....!

    I was searching for the issue since last two days ...!

    and finally i you , your article hepls me to get out of this viewport issue..


    thanx a lot again

    ReplyDelete
  27. Thanks. Ill actually try and use a couple of these tips

    Waiver forms

    ReplyDelete
  28. I liked this post very much as it has helped me a lot in my research and is quite interesting as well. Thank you for sharing this information with us.
    jewelry website design

    ReplyDelete
  29. Thanks for having this in your blog. This is very useful for the beginners.

    Web development

    ReplyDelete
  30. Attractive Website Design Services is the need of this technical era, every one is familiar with Online shopping and don't want to waste his/her time to go to store, all want to buy online, so Website structure and design play an important role in this manner. we offer Best Website Design Services for better business choice.

    ReplyDelete
  31. Having knowledge about screen resolutions especially on mobile devices can really make mobile web development easy because it won't provide any hassles to the task at hand...

    WordPress Designers

    ReplyDelete
  32. I read your article and give very good informative...

    Ottawa website development

    ReplyDelete
  33. Hi friends for download latest movie click on : http://enttonight.blogspot.in/

    ReplyDelete
  34. Very good read. This is so important. Thanks for sharing those information! :)

    wordpress developer

    ReplyDelete
  35. Viewport web design in mobile phone is important especially in businessman who is on the go. Very easy and accesible they can monitor their business as early as possible.



    Small Business Web Design

    ReplyDelete
  36. I read your block it has to the point data and also it's show your effects.
    online sweepstakes
    church software
    blackjack software

    ReplyDelete
  37. I read your block it has to the point data and also it's show your effects.
    online sweepstakes
    church software
    blackjack software

    ReplyDelete
  38. I have read this post. collection of post is a nice one ..that am doing website designing company chennai india and website development company chennai india. That I will inform about your post to my friends and all the best for your future posts..

    ReplyDelete
  39. Thank you for this post.I have read this post. collection of post is a nice one.
    http://www.propertygarh.com

    ReplyDelete
  40. If you've study this far then hopefully you now know that in cellular web style a pixel used for style isn't actually a pixel on the device.

    microsoft project 2010 training

    ReplyDelete
  41. Appealing information you have provided. It gained me more knowledge and idea. Please keep up the good because i like the way you are writing. Thanks!

    web design florida

    ReplyDelete
  42. he stuff here is really good and keep up sharing. i would like to thank you for the efforts which you have made in fabricated this article..Your blog is pretty good and impressed me a lot.
    web development

    ReplyDelete
  43. fantastic post and Thanks for sharing this info. It's very helpful.
    web agency brussels

    ReplyDelete
  44. Hello, I love reading through your blog, I wanted to leave a little comment to support you and wish you a good continuation. Wish you best of luck for all your best efforts.
    Unitel Direct
    Unitel Direct on Facebook

    ReplyDelete
  45. hi i wolud like to appriciate your above post that was such a awosome one thanks Web Development India Web Development Company

    ReplyDelete
  46. You guys out there are performing a great job.
    web design tulsa

    ReplyDelete
  47. It was a great opportunity to read your article, very informative. I learned new things here.

    Website Design Company Philippines

    ReplyDelete
  48. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!


    Web Design Chennai

    ReplyDelete
  49. Online Marketing Dubai Email marketing is one of the most successful methods for websites to attract targeted leads to their website, not only building brand awareness, but also generating sales. The keys to a successful Email Marketing campaign are targeting the right audience and presenting a professional looking email. Coupled with an ongoing campaign the results can be extremely rewarding.

    ReplyDelete
  50. just linked this article on my facebook account. it’s a very interesting article for all...



    Web Designing

    ReplyDelete
  51. Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it, hopefully I can add you and follow...


    Web Development Company

    ReplyDelete
  52. This comment has been removed by the author.

    ReplyDelete
  53. web agency roma è lo studio web del gruppo WdR Società che opera su internet a 360°.web design roma La web agency ha una sede a Roma ed una sede a trevignano romano , programmatore php roma

    ReplyDelete
  54. A mobile web design viewport on the screen can makes the whole application look attractive,even reflects on the content also. Magento Design India

    ReplyDelete
  55. Thanks for introducing viewport! I think viewport provide good design to the site. Enterprise Mobile Apps and Beyond

    ReplyDelete

  56. Thank you for posting such a useful, impressive.your blog is so beautiful. you have give me great news


    website development company in gurgaon

    ReplyDelete
  57. Great website...and cool article man...thanx for the great post...keep on posting such articles..

    SmallBusinessWebDesign

    ReplyDelete
  58. The topic is remarkable. I actually never think I could have an excellent read by this time until I find out this website. I am thankful for the information. Thank you for being so kind enough to have shared your information with us.
    atlanta seo

    ReplyDelete
  59. Hi,
    I will very thank to you that you shared more informative and very knowledgeable blog.Its great for me.My best wishes with you.
    Keep it up.
    Thanks.
    Literature Review Example

    ReplyDelete
  60. Great post Dude. Thanks for sharing such an useful information.

    ReplyDelete
  61. The viewport for web design is defined as the rectangular area (measured in pixels) that is viewable on the screen and determines how the content is laid out and where text wraps or windows need to be scrolled to see the full webpage. κατασκευή ιστοσελίδας

    ReplyDelete
  62. Viewport is really an important factor when comes to mobile designing. Your post has really solved all the queries about it.

    Regards,
    Ekta - Hire Magneto Developer

    ReplyDelete
  63. Thanks ! for sharing this wonderful news with us.I really like your post as it is informative as well as interesting.I am also quite interested to see your upcoming post for Web Development so please keep writing.

    ReplyDelete
  64. Thanks for sharing such an useful information.Certainly it will be a good post.

    by
    Personal Fashion Stylist Sydney

    ReplyDelete
  65. Hi, I went through your this post and found really interesting. I landed this page through internet search and found
    this page very good.I am a web designer and works in a web design company
    as a designer I liked the color of your blog also.

    Thanks,
    (Ronita Biswas)

    ReplyDelete
  66. Hi
    Having such website makes good business through impressing customers.
    Web Design Company

    ReplyDelete
  67. I like your informative and knowledgeable website

    good idea in a stressful situation

    Web Designer From India.

    ReplyDelete
  68. It’s a pleasure to visit this blog because it has a detailed structure. Simply Excellent.
    Media buying houses | Media buying houses in Pakistan

    ReplyDelete
  69. thanks, the blog good information and knowledgeable website.

    ReplyDelete
  70. Hi, I went through your this post and found

    really interesting. I landed this page through

    internet search and found
    this page very good.I am a web designer and

    works in a web design

    company

    as a designer I liked the color of your blog

    also.

    Thanks,
    JIsha

    ReplyDelete
  71. I have just found the Press Releases and news about Green Coffee Bean Max, Zeta Clear, Provillus, Garcinia Cambogia Select, Raspberry Ketone Max, Breast Actives, Phen375, Triactol, Venapro, Wartrol and African Mango Plus on top Social media sites and Newspaper, so i thought to share it with you guys!

    ReplyDelete
  72. Ben Bylett Landscapes is a highly qualified and accredited, professional, landscape design and construction maintenance business servicing across Mosman and North shore.

    decking northern beaches

    ReplyDelete
  73. Ben Bylett Landscapes is a highly qualified and accredited, professional, landscape design and construction maintenance business servicing across Mosman and North shore.

    decking northern beaches

    ReplyDelete
  74. Dr. OZ has recently endorsed 4 products on his Show as best Fat Burner Supplement for quick and Safe Weight Loss! Garcinia Cambogia Select, Green Coffee Bean Max, Raspberry Ketone Plus and African Mango Plus are Those Top 4 Dr OZ Weight Loss Pills!

    ReplyDelete
  75. Here the post discussed many issues of the mobile site and has better understanding with such technical factors. So in the same order the people go for mobile website development services to capture more visitors from the online market.

    ReplyDelete
  76. Garcinia Cambogia Select is a breakthrough medical discovery in natural health and wellness and in sustainable fat loss and weight loss. Garcinia Cambogia is a weight loss and eating disorder remedy. It is a safe and effective non-stimulant that is made from all-natural fruit extracts that are being used at a low or high dosage depending upon the desired result. Garcinia Cambogia Select leads in melting off the awful inches from your waist. It makes you attain the desired shape and a gorgeous flat belly that you have always dreamt of! The Garcinia Cambogia Extract could be the most recent fat loss solution which comes highly recommended by non other that Dr Oz in fact he calls the Garcinia Cambogia Extract the Holy Grail Of Weight-loss. For more review about Dr OZ Garcinia Cambogia Select, Visit www.garciniacambogiaselects.com or find complete Garcinia Cambogia Select Review at http://www.prweb.com/releases/garciniacambogiaselect/reviews/prweb10331994.htm

    ReplyDelete
  77. This blog gives the light in which I can observe the reality. This is very nice one and gives useful information. Thanks for this nice blog.
    Web Design Company

    ReplyDelete
  78. It really shows me where to expand my blog. I think that sometime in the future I might try to write a book to go along with my blog, but we will see. mobile website design

    ReplyDelete
  79. Provillus is rated hair loss product of the year for men and women hair loss! Provillus is FDA approved solution to stop hair loss and regrow hair back! Read Provillus review before order at www.managehairloss.com

    ReplyDelete
  80. All posts have something to learn. Your work is very good and I appreciate you and hopping for some more informative posts.
    Thank you…….. Great blog.
    airport pickup w2 |heathrow to w2 | southend to w2

    ReplyDelete
  81. This post have great information to grab the knowledge ... Thanks for sharing dude
    commmercial cleaning morayfield

    ReplyDelete
  82. I wanted to thank you for this great blog! I really enjoy every little bit of it and I have you bookmarked to check out new stuff you post.airport pickup w2 | southend to w2

    ReplyDelete
  83. Boost your web site to the top results of the largest search engines. We provide organic traffic based on specific keywords that you choose. Limited offer promotion, get $25 worth or organic visits using the coupon code KiWI-25-Organics

    ReplyDelete
  84. Boost your web site to the top results of the largest search engines. We provide organic traffic based on specific keywords that you choose. Limited offer promotion, get $25 worth or organic visits using the coupon code KiWI-25-Organics

    ReplyDelete
  85. Good information..Thanks for sharing the article dude.
    pest control brisbane

    ReplyDelete
  86. Thank you for sharing. Mobile Website Design is critical for your business!

    ReplyDelete
  87. such a nice aritcle, please keep sharing the information about Mobile application development and Website Building Services

    ReplyDelete
  88. As mobile application development and mobile website development is powerful tools for a business, you are guiding developers about how to design or develop websites according different devices. Really very nice work. Thanks

    ReplyDelete
  89. Thanks for sharing such a vital information on viewport META tag. This article and its content was really helpful for me in upgrading my knowledge. 
    Web Design Company India

    ReplyDelete
  90. Web Design Delhi The organizations which are doing web design and web development services in India are playing a great role in Indian business and economy

    ReplyDelete
  91. Hey my friends I tell you some tips. A simple website design shouldn’t be a daunting all-or-nothing ordeal – you can simplify your design by taking small steps. Simple tasks like putting the focus only on the essential elements of your website, getting rid of the unnecessary, reducing the number of pages your site has, getting more content above the fold, and limiting the number of colors you use. You can always fine-tune and improve your simple design, but the important thing here is to get started.
    Newcastle web designer

    ReplyDelete
  92. Thanks for sharing this post.

    ReplyDelete