<?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>Webmonkey &#187; Media Queries</title>
    <atom:link href="http://www.webmonkey.com/tag/media-queries/feed/" rel="self" type="application/rss+xml" />
    <link>http://www.webmonkey.com</link>
    <description>The Web Developer&#039;s Resource</description>
    <lastBuildDate>Mon, 06 May 2013 17:29:19 +0000</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>http://wordpress.org/?v=3.4.2</generator>
    
    <item>
        <title>W3C Looks to Improve Responsive Design With New Media Queries</title>
        <link>http://www.webmonkey.com/2012/07/w3c-looking-to-improve-responsive-design-with-new-media-queries/</link>
        <comments>http://www.webmonkey.com/2012/07/w3c-looking-to-improve-responsive-design-with-new-media-queries/#comments</comments>
        <pubDate>Thu, 19 Jul 2012 18:40:44 +0000</pubDate>

                <dc:creator>Scott Gilbertson</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=57985</guid>
        		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[@media]]></category>
		<category><![CDATA[Media Queries]]></category>
		<category><![CDATA[responsive design]]></category>
            <enclosure url="http://www.webmonkey.com/wp-content/uploads/2012/07/tablets-w.jpg" type="image/jpeg" length="48000" />
                    <description><![CDATA[<div class="rss_thumbnail"><img src="http://www.webmonkey.com/wp-content/uploads/2012/07/tablets-w.jpg" alt="W3C Looks to Improve Responsive Design With New Media Queries" /></div>The W3C, the group that helps create web standards, is hard at work on CSS Media Queries level 4, which gives developers several handy new tools for building responsive websites.]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><div id="attachment_53661" class="wp-caption alignleft" style="width: 590px"><a href="http://www.webmonkey.com/wp-content/uploads/2012/01/tablets.jpg"><img src="http://www.webmonkey.com/wp-content/uploads/2012/01/tablets.jpg" alt="" title="tablets" width="580" height="434" class="size-full wp-image-53661" /></a><p class="wp-caption-text">A handful of the many screens your site needs to handle. <em>Photo: Ariel Zambelich/Wired.com</em></p></div>The W3C, the group charged with overseeing the creation of web standards like HTML and CSS, recently <a href="http://www.webmonkey.com/2012/06/its-official-css-media-queries-are-a-web-standard/">gave its official blessing</a> to one of the cornerstones of responsive web design &#8212; CSS Media Queries.</p>
<p>CSS Media Queries are the basic building block of <a href="http://www.webmonkey.com/2011/06/tips-tricks-and-best-practices-for-responsive-design/">responsive design</a>, which, at its simplest, just means building websites that work on any device. That way, when a dozen new tablets suddenly appear on the scene you can relax knowing your site will look and perform as intended, no matter which device your audience is using.</p>
<p>Now that the Media Queries Level 3 spec has been finalized, work has started on CSS 4 Media Queries, or more formally, <a href="http://dev.w3.org/csswg/mediaqueries4/">Media Queries Level 4</a>.</p>
<p>The W3C&#8217;s draft spec of Media Queries Level 4 adds <a href="http://dev.w3.org/csswg/mediaqueries4/#changes-2012">three new features</a> you can query in your stylesheets, including:</p>
<blockquote>
<ul>
<li><b><code>script</code></b> &#8212; Query to check if JavaScript is enabled.</li>
<li><b><code>pointer</code></b> &#8212; Query to see what sort of input device is being used (mouse, finger, stylus etc).</li>
<li><b><code>hover</code></b> &#8212; Query to see if the :hover pseudo-class will work on the current device.</li>
</ul>
</blockquote>
<p>Perhaps the most interesting is the middle option, <code>pointer</code>, for which the user agent (your browser) is expected to return the value &#8220;none,&#8221; &#8220;coarse&#8221; or &#8220;fine.&#8221; According to the current draft of the spec, &#8220;typical examples of a &#8216;fine&#8217; pointing system are a mouse, a track-pad or a stylus-based touch screen. Finger-based touch screens would qualify as &#8216;coarse.&#8217;&#8221; </p>
<p>Using the <code>pointer</code> query would make it possible to enlarge, for example, form controls on screens where a larger radio buttons might make things easier to select, or perhaps to change how paint flow is handled in a drawing app.</p>
<p>Of course, while potentially handy, none of these queries are yet supported in any web browser, so don&#8217;t go using them just yet. That said, the more progressive browsers like Opera, Chrome and Firefox will likely add preliminary support as the spec progresses. It&#8217;s also likely that some enterprising web developer will <a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills">create a polyfill</a> for older browsers before too long.</p>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2012/07/w3c-looking-to-improve-responsive-design-with-new-media-queries/feed/</wfw:commentRss>
        <slash:comments>1</slash:comments>

        
    </item>
    
    <item>
        <title>It&#8217;s Official, CSS Media Queries Are a Web Standard</title>
        <link>http://www.webmonkey.com/2012/06/its-official-css-media-queries-are-a-web-standard/</link>
        <comments>http://www.webmonkey.com/2012/06/its-official-css-media-queries-are-a-web-standard/#comments</comments>
        <pubDate>Wed, 20 Jun 2012 15:35:09 +0000</pubDate>

                <dc:creator>Scott Gilbertson</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=57570</guid>
        		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[Media Queries]]></category>
		<category><![CDATA[responsive design]]></category>
            <enclosure url="http://www.webmonkey.com/wp-content/uploads/2012/06/media-queries-w.jpg" type="image/jpeg" length="48000" />
                    <description><![CDATA[<div class="rss_thumbnail"><img src="http://www.webmonkey.com/wp-content/uploads/2012/06/media-queries-w.jpg" alt="It&#8217;s Official, CSS Media Queries Are a Web Standard" /></div>The W3C, the group that helps create web standards, has finished work on CSS Media Queries, turning the cornerstone of responsive web design into an official standard.]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><div id="attachment_53661" class="wp-caption alignleft" style="width: 590px"><a href="http://www.webmonkey.com/wp-content/uploads/2012/01/tablets.jpg"><img src="http://www.webmonkey.com/wp-content/uploads/2012/01/tablets.jpg" alt="" title="tablets" width="580" height="434" class="size-full wp-image-53661" /></a><p class="wp-caption-text">A handful of the many screens your site needs to handle. <em>Photo: Ariel Zambelich/Wired.com</em></p></div>The W3C, the group charged with overseeing the creation of web standards like HTML and CSS, has given its official blessing to one of the cornerstones of responsive web design &#8212; <a href="http://www.webmonkey.com/2010/09/make-a-big-splash-on-small-screens-with-media-queries/">CSS Media Queries</a>.</p>
<p>Media queries allow web developers to change the layout of a page based on the media that&#8217;s displaying it &#8212; whether that means adapting it to fit a smaller screen or just stripping it down to the essentials before it heads to a printer. </p>
<p>Chances are you&#8217;ve been using at least the print media query on websites for ages, but now media queries have gone legit, becoming an <a href="http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/">official W3C recommendation</a> (and yes, that is as strongly-worded as the W3C ever gets). </p>
<p>That may not mean much for developers who long ago embraced media queries to serve print stylesheets, but making media queries a recommendation means web browsers need to support it. The backing of the W3C is also often a requirement before large corporate or government organizations will even consider &#8220;new&#8221; ideas like responsive web design.</p>
<p>Media queries are the cornerstone of <a href="http://www.webmonkey.com/2011/06/tips-tricks-and-best-practices-for-responsive-design/">responsive design</a>, which, at its simplest, just means building websites that work on any device. That way, when a dozen new tablets suddenly appear on the scene &#8212; <a href="http://www.wired.com/gadgetlab/2012/06/microsoft-dives-head-first-into-mobile-hardware-with-a-pair-of-10-6-inch-tablets/">Microsoft Surface</a> anyone? &#8212; you can relax knowing your site will look and perform as intended, no matter which devices your audience is using.</p>
<p>Indeed while Microsoft&#8217;s new tablet isn&#8217;t yet storming the web, if you&#8217;ve been using media queries and following the best practices of <a href="http://www.webmonkey.com/2012/01/building-a-responsive-future-friendly-web-for-everyone/">future-friendly design</a> then you don&#8217;t need to worry when the Surface finally does start showing up in your server logs.</p>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2012/06/its-official-css-media-queries-are-a-web-standard/feed/</wfw:commentRss>
        <slash:comments>0</slash:comments>

        
    </item>
    
    <item>
        <title>Build Responsive Websites Like Bruce Lee</title>
        <link>http://www.webmonkey.com/2012/04/build-responsive-websites-like-bruce-lee/</link>
        <comments>http://www.webmonkey.com/2012/04/build-responsive-websites-like-bruce-lee/#comments</comments>
        <pubDate>Fri, 06 Apr 2012 16:36:48 +0000</pubDate>

                <dc:creator>Scott Gilbertson</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=55444</guid>
        		<category><![CDATA[CSS]]></category>
		<category><![CDATA[future friendly]]></category>
		<category><![CDATA[Media Queries]]></category>
		<category><![CDATA[responsive design]]></category>
        <description><![CDATA[Responsive design means building fluid websites that work everywhere. So why are you still using pixels in your media queries? There's a better way. To paraphrase Bruce Lee, make your site more like water.]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><div id="attachment_53661" class="wp-caption alignleft" style="width: 590px"><a href="http://www.webmonkey.com/wp-content/uploads/2012/01/tablets.jpg"><img src="http://www.webmonkey.com/wp-content/uploads/2012/01/tablets.jpg" alt="" title="tablets" width="580" height="434" class="size-full wp-image-53661" /></a><p class="wp-caption-text">A handful of the many screens your site needs to handle. <em>Photo: Ariel Zambelich/Wired.com</em></p></div>Responsive design means making your website readable no matter what screen it might be on. In the words of karate master Bruce Lee, &#8220;Don&#8217;t get set into one form, adapt it and build your own, and let it grow, be like water.&#8221; Lee may have been talking about your mind, but his words apply just as well to your website. To paraphrase the rest of <a href="http://en.wikipedia.org/wiki/Bruce_Lee:_A_Warrior%27s_Journey">that quote</a>, you put water into a cup, it becomes the cup; so, you put your content on a tablet, it becomes the tablet; you put it on a TV, it becomes the TV.&#8221;</p>
<p>On a more practical level, achieving a Bruce Lee-like command of the fluid web means ditching the pixels and points for flexible units like ems or percentages. There&#8217;s a lot <a href="http://www.webmonkey.com/2011/06/good-responsive-design-goes-beyond-fluid-grids/">more to responsive design than just fluid layouts</a>, but it&#8217;s definitely a key part of the process.</p>
<p>Curiously, when it comes time to use the other universal element of responsive design &#8212; the @media query that applies the actual responsive design &#8212; most of us revert right back to pixels with something like <code>@media all and (min-width: 500px) {}</code>. It seems logical; after all, you&#8217;re trying to fit your content into a window with specific dimensions, so why not use pixels?</p>
<p>Certainly you can, and most sites we&#8217;ve seen up to this point use pixels for the actual media query breakpoints, but it&#8217;s worth noting that you can use ems here as well. </p>
<p>Lyza Gardner over at Cloud Four recently posted a look at <a href="http://blog.cloudfour.com/the-ems-have-it-proportional-media-queries-ftw/">why Cloud Four&#8217;s new responsive design uses ems in its media queries</a>. Here&#8217;s her reasoning for Cloud Four&#8217;s em-based approach:</p>
<blockquote>
<p>Folks who design for traditional reading media &#8212; where the content really is king &#8212; don&#8217;t center design decisions around the absolute width of content-holding elements so much as around the optimal line lengths for the content they’re flowing. There are some tried-and-true numbers one can shoot for that make for the &#8220;right&#8221; number of letters (and thus words) per line for comfortable human reading.</p>
<p>Thus actual column width is a function of font size and ems-per-line.</p>
</blockquote>
<p>The rest of the post walks through how Cloud Four used em-based media queries to create a <a href="http://www.webmonkey.com/2012/02/building-responsive-websites-how-to-handle-navigation-menus/">better navigation experience</a> on their site. Some of the advantages may not apply to every responsive design, but there is one additional benefit that works nearly everywhere &#8212; em-based media queries mean that your site will handle user zooming much better, applying media queries instead of allowing content to overflow its container.</p>
<p>But perhaps the best part of an em-based approach is that it seems to work in nearly every web browser. Cloud Four&#8217;s post doesn&#8217;t get into the specifics of their browser testing so I fired up a couple of virtual machines and tested their site and my own simplified demo page in every major browser.</p>
<p>According to my testing, em-based media queries work properly in all OS X browsers. (I tested the latest versions of Safari, Firefox, Chrome and Opera.) Only Firefox and Opera apply media queries on zoom, though. (Chrome and Safari need a page refresh before the query is applied.)</p>
<p>On Windows 7 Firefox, Opera and Chrome behave the same way they do on OS X. IE 9 also worked fine and, like Firefox and Opera, applies media queries when zooming without needing a page refresh. Judging by the comments on the Cloud Four blog, Chrome on Linux may have some issues, but in my testing Firefox and Chrome on Fedora worked as expected.</p>
<p>All the mobile browsers I tested on Android worked as well (Firefox, Chrome, Opera Mini and the default Android browser). On iOS Mobile Safari applies em-based queries as you would expect.</p>
<p>In the end you certainly don&#8217;t need to use em-based media queries. As many sites out there demonstrate, pixel-based queries work. At least for now. However, as a wider range of screen sizes begin to access the web switching to em-based queries may put you ahead of the game. Em-based queries mean addressing the content-width rather than just the screen width and that feels like a more <a href="http://www.webmonkey.com/2012/01/building-a-responsive-future-friendly-web-for-everyone/">future-friendly</a> approach.</p>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2012/04/build-responsive-websites-like-bruce-lee/feed/</wfw:commentRss>
        <slash:comments>3</slash:comments>

        
    </item>
    
    <item>
        <title>The Boston Globe Embraces Responsive Design</title>
        <link>http://www.webmonkey.com/2011/09/the-boston-globe-embraces-responsive-design/</link>
        <comments>http://www.webmonkey.com/2011/09/the-boston-globe-embraces-responsive-design/#comments</comments>
        <pubDate>Tue, 13 Sep 2011 16:24:16 +0000</pubDate>

                <dc:creator>Scott Gilbertson</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=51610</guid>
        		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Visual Design]]></category>
		<category><![CDATA[Web Basics]]></category>
		<category><![CDATA[Media Queries]]></category>
		<category><![CDATA[responsive design]]></category>
            <enclosure url="http://www.webmonkey.com/wp-content/uploads/2011/09/bostonglobe.jpg" type="image/jpeg" length="48000" />
                    <description><![CDATA[<div class="rss_thumbnail"><img src="http://www.webmonkey.com/wp-content/uploads/2011/09/bostonglobe.jpg" alt="The Boston Globe Embraces Responsive Design" /></div>Responsive design is no longer something confined to the portfolio websites of the designers and developers who pioneered the idea. Using CSS media queries to adapt a website&#8217;s layout to varying screen sizes is fast becoming a standard part of web development. Today&#8217;s case in point is the newly launched BostonGlobe.com, which uses the adaptive [...]]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><div id="attachment_51612" class="wp-caption aligncenter" style="width: 590px"><a href="http://www.webmonkey.com/wp-content/uploads/2011/09/bostonglobe.jpg"><img src="http://www.webmonkey.com/wp-content/uploads/2011/09/bostonglobe.jpg" alt="" title="bostonglobe" width="580" height="272" class="size-full wp-image-51612" /></a><p class="wp-caption-text">The BostonGlobe.com on mobile, tablet and laptop screens</p></div>Responsive design is no longer something confined to the portfolio websites of the designers and developers who pioneered the idea. Using CSS media queries to <a href="http://www.webmonkey.com/2011/06/tips-tricks-and-best-practices-for-responsive-design/">adapt a website&#8217;s layout to varying screen sizes</a> is fast becoming a standard part of web development.</p>
<p>Today&#8217;s case in point is the newly launched <a href="http://www.bostonglobe.com/">BostonGlobe.com</a>, which uses the adaptive layouts, font resizing and image scaling of responsive design to deliver an elegant, readable website no matter what screen size you&#8217;re using. </p>
<p>The Globe&#8217;s new website is attracting more attention for the fact that it will soon be behind a paywall (it&#8217;s free until the end of September), but for web developers the much bigger news is that one of the larger news sites on the web is embracing responsive design.</p>
<p>It&#8217;s not an iOS app; it&#8217;s not in the Chrome Web Store. No, the new BostonGlobe.com is just a good old fashioned website, but one that looks good no matter what you&#8217;re viewing it on thanks to its use of responsive design. Depending on the size of your screen &#8212; whether you happen to be browsing from a phone, a tablet or a desktop monitor &#8212; BostonGlobe.com will adjust its content to fit the pixels available. It will reflow its text columns according to screen size and also scale its masthead logo, the section menus, images, videos and even the weather graphic in the masthead. </p>
<p>Of course it makes sense that the BostonGlobe.com is a flagship example of what&#8217;s possible with responsive design given that developer Ethan Marcotte, who coined the term responsive design, was one of the architects behind the new Globe website. If you&#8217;d like to know a bit more about how the site was created, including some of the challenges any responsive site faces, head over to Marcotte&#8217;s blog and read his <a href="http://unstoppablerobotninja.com/entry/the-boston-globe/">write up on the new site</a>.</p>
<p>Also part of the team that helped build the site are the <a href="http://upstatement.com/">design firm Upstatement</a> and the Filament Group, which helped pioneer the concept of &#8220;<a href="http://adaptive-images.com/">responsive</a>&#8221; or &#8220;<a href="http://adaptive-images.com/">adaptive</a>&#8221; images. That is, serving smaller images to mobile browsers and then using JavaScript to serve larger images to desktop browsers. Be sure to check out our earlier coverage of <a href="http://www.webmonkey.com/2011/08/speed-up-your-responsive-designs-with-adaptive-images/">adaptive images</a>.</p>
<p>While the Globe may have had the cash and cachet to hire big names in the field, that doesn&#8217;t mean you need an extensive team to create a responsive website. We won&#8217;t lie to you, building a good responsive website is more difficult than just slapping up a fixed width design. But, provided it fits with the goals of your site, it&#8217;s much easier than many of the alternatives, which often require building and maintaining two entirely separate websites.</p>
<p>If you&#8217;d like to know more about how the Globe team built the site there&#8217;s a video on the Globe&#8217;s other website, Boston.com, which gives a behind the scenes look at how the responsive design works. At around 1:22 you&#8217;ll see a shot of the design being tested on multiple devices simultaneously. The tool that makes that possible is <a href="https://github.com/marstall/shim">Shim</a>, a node.js app that enables simultaneous, synced web surfing across devices and browsers. You can <a href="https://github.com/marstall/shim">check it out over at GitHub</a>.</p>
<p><object id="flashObj" width="440" height="356" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0"><param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&#038;isUI=1" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="videoId=1150525821001&#038;playerID=16977198001&#038;playerKey=AQ~~,AAAAAA6piHY~,DqRT40XOAr8wI0s0AlLx8-XNKKxaCNBM&#038;domain=embed&#038;dynamicStreaming=true" /><param name="base" value="http://admin.brightcove.com" /><param name="seamlesstabbing" value="false" /><param name="allowFullScreen" value="true" /><param name="swLiveConnect" value="true" /><param name="allowScriptAccess" value="always" /><embed src="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&#038;isUI=1" bgcolor="#FFFFFF" flashVars="videoId=1150525821001&#038;playerID=16977198001&#038;playerKey=AQ~~,AAAAAA6piHY~,DqRT40XOAr8wI0s0AlLx8-XNKKxaCNBM&#038;domain=embed&#038;dynamicStreaming=true" base="http://admin.brightcove.com" name="flashObj" width="440" height="356" seamlesstabbing="false" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object></p>
<p><strong>See Also:</strong><br/></p>
<ul>
<li><a href="http://www.webmonkey.com/2011/06/tips-tricks-and-best-practices-for-responsive-design/">Tips, Tricks and Best Practices for Responsive Design</a></li>
<li><a href="http://www.webmonkey.com/2011/08/speed-up-your-responsive-designs-with-adaptive-images/">Build Faster Mobile Websites With ‘Adaptive Images’</a></li>
<li><a href="http://www.webmonkey.com/2011/06/good-responsive-design-goes-beyond-fluid-grids/">Take Responsive Design Beyond the (Fluid) Grid</a></li>
<li><a href="http://www.webmonkey.com/2010/09/make-a-big-splash-on-small-screens-with-media-queries/">Make a Big Splash on Tiny Screens With Media Queries</a></li>
</ul>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2011/09/the-boston-globe-embraces-responsive-design/feed/</wfw:commentRss>
        <slash:comments>0</slash:comments>

        
    </item>
    
    <item>
        <title>Make a Big Splash on Tiny Screens With Media Queries</title>
        <link>http://www.webmonkey.com/2010/09/make-a-big-splash-on-small-screens-with-media-queries/</link>
        <comments>http://www.webmonkey.com/2010/09/make-a-big-splash-on-small-screens-with-media-queries/#comments</comments>
        <pubDate>Tue, 28 Sep 2010 23:10:00 +0000</pubDate>

                <dc:creator>Scott Gilbertson</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=48821</guid>
        		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[CSS 3]]></category>
		<category><![CDATA[Media Queries]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Tutorials]]></category>
        <description><![CDATA[Go out for a chai latte with your local technology soothsayer (or just study your Google Analytics reports) and it&#8217;s pretty clear that the mobile web is the future. But let&#8217;s not call it the mobile web, let&#8217;s call it the smaller web. And by smaller, I mean a web with less available screen real [...]]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled -->
<p><img src="http://www.wired.com/images_blogs/gadgetlab/2010/08/droid_2f.jpg" alt="MorotolaDroid2" /></p>
<p>Go out for a chai latte with your local technology soothsayer (or just study your Google Analytics reports) and it&#8217;s pretty clear that the mobile web is the future.</p>
<p>But let&#8217;s not call it the mobile web, let&#8217;s call it the smaller web. And by smaller, I mean a web with less available screen real estate than the desktop.</p>
<p>While the iPhone may have a fully-capable web browser, it still has a relatively small screen. Serving the desktop version of the your website is hardly the best way to deliver your content to iPhone owners.</p>
<p>And don&#8217;t forget that the iPhone people are the lucky ones. The latest devices &#8212; iPhones, iPads, Android phones &#8212; have relatively large screens by mobile standards, but these devices are in the hands of a very slim percentage of worldwide mobile users. There are some 3 billion users out there with older phones, or devices with crappy browsers and very small screens.</p>
<p>The point here is that you need something far better than the desktop-optimized version of your website to offer to mobile visitors.</p>
<h3>Mobile Solutions</h3>
<p>There are three popular ways to approach mobile sites: </p>
<ul>
<li><b>Write good code, but do nothing special for mobile.</b> This works fine if your audience is made up of iPhone, iPad and Android users with nice, high-speed 3G connections. That&#8217;s about 1 percent of the mobile market, but some sites with an abnormally large number of iPhone users (like an iPhone news site) can get away with it.</li>
<li><b>Detect the device in use and serve a separate mobile site.</b> Something like m.flickr.com. While this approach works, it means maintaining a second website, plus constantly updating your device detection scripts as new gadgets come on the scene.</li>
<li><b>Build an adaptive site using CSS 3 media queries</b>. Thanks to CSS 3 and the new media query syntax, you can build a site that automatically adapts its layout to fit the screen size of your visitors.</li>
</ul>
<p>The later approach has received the most attention lately, with many designers moving to fluid grids that reflow content, resize images and nicely smoosh themselves down to fit any screen. Check out <a href="http://colly.com/">Simon Collison&#8217;s personal site</a>, or designer <a href="http://hicksdesign.co.uk/">Jon Hick&#8217;s website</a> for examples of media queries in action.</p>
<p>Be sure to resize your browser window so you can see the content reflow as the browser width shrinks. That&#8217;s the gift of media queries &#8212; by precisely labeling your CSS, the presentation can be altered dynamically depending on the device&#8217;s screen width and height. Your content never changes, and neither does your CSS. The page simply adapts.</p>
<p>However, as nice as media queries are, before we dive into the syntax and how it can help, it&#8217;s important to realize that this approach is not going to magically solve all your mobile design problems.</p>
<p><span id="more-48821"></span></p>
<h3>Problems with CSS 3 media queries</h3>
<p>The media query approach will work fine for many sites, but won&#8217;t help when it come to bandwidth concerns. Just reflowing the visual design of your content to fit smaller screens doesn&#8217;t make your images download any faster, nor does it compress or simplify your HTML. </p>
<p>There are also a host of older mobile browsers that doesn&#8217;t understand media queries and will simply fail to load your mobile site styles.</p>
<p>While media queries are not, in the words of <a href="http://www.cloudfour.com/css-media-query-for-mobile-is-fools-gold/<br />
">web developer Jason Grigsby</a>, &#8220;a silver bullet,&#8221; they can still be quite helpful provided you use them properly. </p>
<p>Ethan Marcotte&#8217;s <a href="http://www.alistapart.com/articles/responsive-web-design/">tutorial on A List Apart</a> helped generate interest in media queries as a solution for mobile devices, and it&#8217;s well worth a read. Marcotte shows how to bolt media queries onto a desktop design so that it gracefully degrades on smaller screens, reflowing content to fit the available space. </p>
<p>It&#8217;s a very well done tutorial, but it essentially approaches the problem backwards.</p>
<p>I&#8217;d argue that the best way to use media queries is not to shrink your site for mobile, but to <a href="http://www.webmonkey.com/2010/09/slide-show-time-rethinking-the-mobile-web/">enhance it for the desktop</a>. That is, start with a style sheet that creates a nice, narrow, simplified, single column layout for mobile visitors and then uses media queries to expand the layout for desktop browsers.</p>
<h3>Progressively enhancing your mobile site</h3>
<p>Using media queries is actually quite simple, <a href="http://www.w3.org/TR/css3-mediaqueries/#syntax">the syntax</a> is very similar to the &#8220;media types&#8221; syntax that arrived in CSS 2.1. Media types allow you to specify a style sheet for screens and another for print. CSS 3&#8242;s media queries are similar, but target specific screen sizes (and orientation, though that syntax is less widely supported).</p>
<p>For example, let&#8217;s say we have two sections in our mobile site &#8212; a main column of content wrapped in an article tag, and a &#8220;sidebar&#8221; wrapped in an aside tag. For our mobile layout we&#8217;ve simply let the sidebar fall below the main content in a single column. But for the desktop we want to floated the sidebar to the right for a two column layout. To do that using a media query, the code would look something like this:</p>
<pre class="brush:js">
article#main, aside#sidebar {
    color: #222;
    ...more mobile styles here...
}
@media screen and (max-width > 800px) {
  #main {
    float: left;
  }
  #sidebar {
    float: right;
  }
}
</pre>
<p>This chunk of code tells any browser with a screen larger than 800px to float our content into two columns. Because all modern web browsers understand media queries, this works almost everywhere. Internet Explorer 8 and below will not do anything with this code, but chances are you&#8217;re already writing IE-specific style sheets so you can simply write the rules there &#8212; minus the @media syntax &#8212; and IE will fall in line.</p>
<p>Mobile browsers will naturally ignore this rule. But of course, they will download the entire style sheet which includes all our @media rules. Given the bandwidth constraints of mobile networks, anything we can do to decrease files size is going to help. Fortunately, there&#8217;s another way to use @media &#8212; include separate style sheets for desktop browsers. </p>
<p>The @media query syntax works in your head tags as well, which means we can simple write a separate style sheet for desktop browser and ensure that only they see it, but using a tag like this:</p>
<pre class="brush:js">
&lt;link rel="stylesheet" type="text/css"
  media="screen and (max-width > 800px)"
  href="/css/desktop.css" />
</pre>
<p>The code above also loads our desktop styles only to devices with larger screen resolutions, but this time it does it without bloating our base style sheet for mobile devices.</p>
<p>Of course nothing awesome in web design is accomplished without some sort of trade off. We&#8217;ve decreased the size of our mobile style sheet, but we&#8217;ve added an extra HTTP request to our desktop site. If you&#8217;ve ever used <a href="http://www.webmonkey.com/2010/09/how-to-speed-up-your-site-with-yslow-and-page-speed/">YSlow or PageSpeed</a> to evaluate your load times, you know that extra HTTP requests make for slower page loads.</p>
<p>Whether or not the tradeoff is worth it is your call. In most cases, one extra HTTP request probably isn&#8217;t going to dramatically slow your page, but it is something to keep in mind, particularly if you start adding another style sheet for the iPad and other tablet-size screens.</p>
<p>While extra requests on your desktop site are a small drawback, there are other, more complicated problems that @media queries won&#8217;t solve.</p>
<h3>Issues with images</h3>
<p>The wrench in the works of any mobile-first web design strategy is the use of images. Large images slow down mobile pages and, unfortunately, media queries don&#8217;t help with that. Obviously, when it comes to optimizing your images for mobile, CSS and @media queries &#8212; cool as they are &#8212; are not going to have the answer.</p>
<p>If we&#8217;re start by designing with mobiles in mind and serve smaller, more compressed images in our markup, the mobile visitors benefit and we&#8217;ve solved a large part of the problem. But then the desktop visitors have to suffer through your crappy, low-res images.</p>
<p>One solution is to use JavaScript to swap out the small images for another set of larger, higher resolution images on the desktop. Mobile platform consultant Peter-Paul Koch has a nice overview of how <a href="http://www.quirksmode.org/blog/archives/2010/08/combining_media.html#more">JavaScript can be combined with media queries</a> to swap out your mobile-size images with larger ones for larger screens. </p>
<p>But in addition to requiring JavaScript for this solution to work, it also means our CMS or other site management tools now need to store and track two (at a minimum) sets of images.</p>
<p>However, that&#8217;s probably better than loading big images and forcing mobile browsers to scale them, which is worst of both worlds &#8212; large image downloads and processor-intensive downscaling.</p>
<p>The truth is there&#8217;s no easy way to solve the image problem. If the site you&#8217;re designing relies heavily on large images, you may be better off with a separate mobile website and a CMS that can automatically resize and keep track of both sets of images.</p>
<h3>Conclusion</h3>
<p>Media queries have been touted as the one-stop solution to all your mobile needs, but in fact they aren&#8217;t going to live up to that hype. Media queries are incredibly useful and work in most browsers, but in the end they are just another tool, not a total solution to everything.</p>
<p>Media queries are not the best approach in every case. The websites from Hicks and Colly are elegant examples of media queries (though both use different approaches) but the same technique just isn&#8217;t going to work for <cite>The New York Times</cite>. The complexity and depth of the NYT website (or Flickr, or Wikipedia for that matter) make a completely separate mobile website a necessity.</p>
<p>At the same time, there are numerous mobile websites out there that could easily have been built with media queries and would probably have spared their development teams quite a bit of extra work.</p>
<p>As with most things in web development, media queries are another tool for your toolbox. When and where to use them is something you can judge on an individual, by-project basis.</p>
<p><em>Photo: Jon Snyder/Wired</em></p>
<p><b>See Also:</b></p>
<ul>
<li><a href="http://www.webmonkey.com/2010/09/slide-show-time-rethinking-the-mobile-web/">Slide Show Time: Rethinking the Mobile Web</a></li>
<li><a href="http://www.webmonkey.com/2010/09/a-guide-to-internet-explorer-9s-html5css-3-support/">A Guide to Internet Explorer 9’s HTML5/CSS 3 Support</a></li>
<li><a href="http://www.webmonkey.com/2010/09/how-to-speed-up-your-site-with-yslow-and-page-speed/">How to Speed Up Your Site With YSlow and Page Speed</a></li>
</ul>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2010/09/make-a-big-splash-on-small-screens-with-media-queries/feed/</wfw:commentRss>
        <slash:comments>7</slash:comments>

        
    </item>
    </channel>
</rss>
