Tutorial Details
- Topic: Responsive Web Design
- Difficulty: Beginner
- Estimated completion time: 8 seconds
I remember my maiden voyage into responsive web design; I’d used a classic grid, wrestled with a flexible layout, and tackled media queries for the first time. Stretching and shrinking the browser window resulted in the satisfying sight of my design responding to its surroundings. Then I tested it on a mobile. It didn’t work – I was looking at a shrunken down version of the full-screen design. The solution, as it turned out, was simple..
The Crux
If you read nothing else within this post, take one bit of advice away: if you’re designing flexibly, use the viewport meta tag in your <head>. In its basic form, it will set you up for cross-device layout peace of mind:
<meta name="viewport" content="width=device-width, initial-scale=1">
The Problem
Let’s take a look at an example layout I’ve whipped together using a stripped down version of the Skeleton boilerplate. Take a look; you’ll see it shrink and grow as you alter the size of your browser. Lovely.
Here’s how iOS Safari iPad sees it when viewed in landscape:
More or less as we would expect. This is the layout as it should be with a viewport (the area available for viewing the webpage) of 980px. Now let’s rotate the iPad 90° and see how it looks in portrait :
Right. We’re looking at a zoomed-out version. This is exactly the same as the first example; 980px of content, but this time squished into the iPad’s portrait width of 768px. The type is now much less readable, unless you zoom in.
Why?
As they say, assumption is the mother of all…something but that’s exactly what mobile browsers have to do if you don’t specifically instruct them. When you visit a website via a mobile browser it will assume that you’re viewing a big desktop experience and that you want to see all of it, not just the top left corner. It will therefore set the viewport width at (in the case of iOS Safari) 980px, shoe-horning everything into its little display.
The Viewport Meta Tag
Enter the viewport meta tag, introduced by Apple, then adopted and developed further by many others.
It looks like this:
<meta name="viewport" content="">
Within the content="" you can enter a load of comma delimited values, but we’re going to to focus on the fundamental ones for now.
For example, if your mobile design is purposely laid out at 320px you can specify the viewport width:
<meta name="viewport" content="width=320">
For flexible layouts it’s more practical to base your viewport width on the device in question, so to match your layout width to the device width you’d enter:
<meta name="viewport" content="width=device-width">
To be extra certain that your layout will be displayed as you intended it you can also set the zoom level. This, for example:
<meta name="viewport" content="initial-scale=1">
..will ensure that upon opening, your layout will be displayed properly at 1:1 scale. No zooming will be applied. You could even go further and prevent any zooming by the user:
<meta name="viewport" content="maximum-scale=1">
Note: Before applying the maximum-scale parameter, consider whether you should really be preventing your users from zooming in. Can they read everything as well as possible?
Put it All Together
These values together give us a great default to work with:
<meta name="viewport" content="width=device-width, initial-scale=1">
Let’s see how it affects our example, here in landscape:
..and here in portrait:
As you can see, everything remains at the correct scale, the layout has altered (smaller column widths) and the text is wrapping instead of shrinking.
Conclusion
Responsive web design isn’t just for people who enjoy watching their browsers grow and shrink, it’s about catering for as many different devices, screens and resolutions as possible! Throw the viewport meta tag into your <head> when you’re building flexible layouts and you’re good to go.
Further Reading
- Apple documentation: Using the Viewport Meta Tag
- Mozilla: Using the viewport meta tag to control layout on mobile browsers
- quirksmode.org: A tale of two viewports
- w3.org Mobile Web Application Best Practices: Use Meta Viewport Element To Identify Desired Screen Size





Pingback: Quick Tip: Don’t Forget the Viewport Meta Tag | Shadowtek | Hosting and Design Solutions
Pingback: Tweet-Parade (no.7 FEB 2012) | gonzoblog.nl
Pingback: A Simple, Responsive, Mobile First Navigation | Webdesigntuts+
Pingback: A Simple, Responsive, Mobile First Navigation |
Pingback: A Simple, Responsive, Mobile First Navigation | How to Web
Pingback: A Simple, Responsive, Mobile First Navigation | Graphfucker
Pingback: A Simple, Responsive, Mobile First Navigation | SCRiPTMAFiA.cO.IN
Pingback: Building a Responsive Layout With Skeleton: Starting Out | Webdesigntuts+
Pingback: Viewport Meta Tag, você usa? « Karin Watanabe
Pingback: Flexible() « Firebugging
Pingback: Build a Popup Modal Window Using the jQuery Reveal Plugin | Webdesigntuts+
Pingback: Build a Popup Modal Window Using the jQuery Reveal Plugin |
Pingback: My Stream | Build a Popup Modal Window Using the jQuery Reveal Plugin | My Stream
Pingback: Build a Popup Modal Window Using the jQuery Reveal Plugin | Shadowtek | Hosting and Design Solutions
Pingback: Build a Popup Modal Window Using the jQuery Reveal Plugin | How to Web
Pingback: jQuery kullanarak Popup penceresi yapımı
Pingback: | Graphfucker
Pingback: ISMA205 Web Essentials – Responsive Web Design
Pingback: Class Notes HTML/CSS/JavaScript « mcopeman
Pingback: SoftwareDev | Pearltrees
Pingback: My Responsive Design Presentation at the April 2012 GRWebDev | Ben Rousch's Cluster of Bleep
Pingback: Build a Popup Modal Window Using the jQuery Reveal Plugin | kevinleary.net
Pingback: 6 Web Design Trend for 2012 | PMTtricks
Pingback: Put Users in Control With Confirmation Feedback Buttons | Webdesigntuts+
Pingback: Put Users in Control With Confirmation Feedback Buttons |
Pingback: My Stream | Put Users in Control With Confirmation Feedback Buttons | My Stream
Pingback: Put Users in Control With Confirmation Feedback Buttons | Shadowtek Hosting and Design Solutions
Pingback: Put Users in Control With Confirmation Feedback Buttons | How to Web
Pingback: An Awesome CSS3 Animated Dropdown Menu « HTML, HTML5, CSS, CSS3, JQuery, Flash, Photoshop, mobile, iphone & ipad web application
Pingback: Put Users in Control With Confirmation Feedback Buttons « Web Express Way
Pingback: Put Users in Control With Confirmation Feedback Buttons
Pingback: Building a Responsive, Mobile-First Navigation Menu « Cândido Sales Blog
Pingback: How to Create a Responsive Navigation
Pingback: How to Create a Responsive Navigation | Philterest
Pingback: How to Create a Responsive Navigation | DigitalMofo
Pingback: How to Create a Responsive Navigation | Android News
Pingback: How to Create a Responsive Navigation | Best Web Consulting company in Nashik, India with Creative and Professional Website Design, Content Management Systems, Wordpress Experts, Ecommerce SEO, and more..
Pingback: How to Create a Responsive Navigation | pixelpush design
Pingback: » Jquery Responsive site Menu - PYG studio
Pingback: Design Core Studio Fall 2012 – Responsive Web Design
Pingback: Responsive Email/Webpage Design – Basis « Juan Matías de la Cámara Beovide
Pingback: Big Menus, Small Screens: Responsive, Multi-Level Navigation | Webdesigntuts+
Pingback: My Stream | Big Menus, Small Screens: Responsive, Multi-Level Navigation | My Stream
Pingback: Big Menus, Small Screens: Responsive, Multi-Level Navigation
Pingback: Build a Responsive, Filterable Portfolio, with CSS3 Twists | Webdesigntuts+
Pingback: My Stream | Build a Responsive, Filterable Portfolio, with CSS3 Twists | My Stream
Pingback: How to use jquery and css3 make a simple and awesome animated dropdown menu | JqueryHeaven
Pingback: Developing a Mobile Donations Form In Convio Luminate - Part Three
Pingback: Hubspot Grades MSU, Mankato’s Website « stacy and journalism
Pingback: Build a Responsive, Filterable Portfolio, with CSS3 Twists « Web Design
Pingback: Create a Flexible Folded Paper Effect With CSS3 | Webdesigntuts+
Pingback: Build a Responsive, Filterable Portfolio, with CSS3 Twists « Mary Brija
Pingback: Build a Responsive, Filterable Portfolio, with CSS3 Twists « glindemulder
Pingback: Create a Flexible Folded Paper Effect With CSS3 - — Ethiopian Website Design
Pingback: Create a Flexible Folded Paper Effect With CSS3 - Website Design Prices
Pingback: Create a Flexible Folded Paper Effect With CSS3 - Цялостни IT решения,bussines 2 bussines,Оферти,Обяви,Работа, Коли под наем,Rent A Car ,Уеб Дизайн,nternet access, hosting, web design, network monitoring
Pingback: TUTORIAL RESPONSIVE | Web Designer Work - Magazine Online
Pingback: Creating an Adaptive, Filterable Portfolio Using jQuery Isotope by Luke Spoor « Secret Box
Pingback: Bootstrap - Responsive design | | Theo's blog
Pingback: Blog Design from Pixelmator to WordPress – Part 3 | WordPress Tutorials 101
Pingback: Mobiles | Consultores Development
Pingback: Build a Responsive Pricing Table with Neat Hover States | Webdesigntuts+
Pingback: Build a Responsive Pricing Table with Neat Hover States | Directory Net
Pingback: Responsive design with a view full site link | Justin W. Hall
Pingback: Creatifox | Build a Responsive Pricing Table with Neat Hover States