<?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>zomigi.com &#187; work process</title>
	<atom:link href="http://zomigi.com/tags/work-process/feed/" rel="self" type="application/rss+xml" />
	<link>http://zomigi.com</link>
	<description>The professional blog of Zoe Mickley Gillenwater</description>
	<lastBuildDate>Thu, 10 May 2012 16:30:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Essential considerations for crafting quality media queries</title>
		<link>http://zomigi.com/blog/essential-considerations-for-crafting-quality-media-queries/</link>
		<comments>http://zomigi.com/blog/essential-considerations-for-crafting-quality-media-queries/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 15:00:40 +0000</pubDate>
		<dc:creator>Zoe Gillenwater</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[media queries]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[responsive web design]]></category>
		<category><![CDATA[work process]]></category>

		<guid isPermaLink="false">http://zomigi.com/?p=569</guid>
		<description><![CDATA[Learn what you need to know to set up media queries that maximize efficiency and robustness for your particular project. There are pros and cons to making your media queries embedded versus external, overlapping versus stacking your media queries, starting with mobile versus desktop styles, and using conditional comments versus JavaScript to add support for IE 8 and earlier versions.]]></description>
			<content:encoded><![CDATA[<p>CSS3 media queries are dead simple, in terms of their syntax. You&#8217;ve got an <code>@media</code> directive, a media type (which you already know from good ol&#8217; CSS 2, like <code>screen</code>, <code>print</code>, <code>all</code>, etc.) and one or more media features (the characteristics we&#8217;re testing against). That&#8217;s it:</p>
<pre><code>@media screen and (max-width:500px) {
}</code></pre>
<p>There are some additional little syntax details, but this is basically all you need to know to actually make a media query work. Once you memorize this short, simple syntax and the various media features that are available, you could technically say that you know how to use media queries. But knowing how to use media queries <em>effectively</em> requires a whole lot more considerations than just where to put an @ or {.</p>
<p>Designing web layouts with media queries is a <em>process</em>. You need to keep them in mind from the very beginning and make decisions at several points about how to integrate them in ways that will make the most sense for your site. There are very few always-right or always-wrong answers. What type of media query set-up would work best will depend on your site, your users, and your own capabilities and experience. But I wanted to cover the pros and cons of some of the essential considerations that go into crafting robust media query-driven layouts. These considerations include whether to:</p>
<ul>
<li><a href="#mq-embed-external">Make the media queries embedded or external</a></li>
<li><a href="#mq-overlap-stack">Overlap or stack your media queries</a></li>
<li><a href="#mq-default-styles">Make mobile or desktop styles the default</a></li>
<li><a href="#mq-internet-explorer">Use conditional comments or JavaScript to add support for IE 8 and earlier versions</a></li>
</ul>
<p>This article is just as much for me as it is for you—it can be hard to keep track of all the different configuration variations you can use! Hopefully I&#8217;ll be able to make the pros and cons of the various approaches clearer so you can use this article to guide your decisions when you start a project involving media queries.</p>
<h3 id="mq-embed-external">How to include your media queries: embedded vs. external</h3>
<p>There are two ways to include media queries in your site: embed them within a style sheet or include them in a call to a separate, external sheet.</p>
<p><span id="more-569"></span>Here&#8217;s what an embedded media query looks like (pretend that we&#8217;re inside a style sheet):</p>
<pre><code>body {
    background: gray;
}
@media all and (max-width:500px) {
    body {
        background: blue;
    }
}</code></pre>
<p>For an external media query, simply extend the existing media part of the <code>link</code> element or <code>@import</code> rule:</p>
<pre><code>&lt;link href="narrow.css" rel="stylesheet" media="only screen and (max-width:500px)"&gt;</code></pre>
<pre><code>@import url(narrow.css) only screen and (max-width:500px);</code></pre>
<p>Browsers that don&#8217;t support media queries won&#8217;t download these sheets, but browsers that do will download them all, regardless of whether they&#8217;re needed or not for the current viewing scenario. (The background images inside the currently-not-needed sheets won&#8217;t download, however.) On the one hand, this makes sense—the user could change his or her orientation or window size, and those alternate styles would suddenly need to be called into action.  On the other hand, <a href="http://blog.assortedgarbage.com/2010/12/css3-media-queries-download-answers/">Greg Rewis found</a> that even if you create a sheet that it seems like a device could never possibly use, such as a sheet for a <code>max-width</code> of 700 pixels never being needed by an iPad with its 768 x 1024 resolution, the device will download it anyway. But <a href="http://css-tricks.com/">Chris Coyier</a> pointed out to me that you could have an <code>iframe</code> in a page, for instance, that might need to use that smaller style sheet—so on the <em>third</em> hand, I guess this behavior is logical and unavoidable, if not perfect.</p>
<h4>The pros and cons</h4>
<table class="pros-cons">
<caption> Embedded vs external media queries<br />
</caption>
<tbody>
<tr>
<th class="pro" scope="col">Embedded pros</th>
<th class="con" scope="col">External cons</th>
</tr>
<tr>
<td class="pro">No extra HTTP request(s)</td>
<td class="con">Extra HTTP request(s)</td>
</tr>
<tr>
<td class="pro">Not out of sight, so harder to forget</td>
<td class="con">Out of sight, so could be forgotten when updating</td>
</tr>
</tbody>
</table>
<table class="pros-cons">
<caption> Embedded vs external media queries<br />
</caption>
<tbody>
<tr>
<th class="con" scope="col">Embedded cons</th>
<th class="pro" scope="col">External pros</th>
</tr>
<tr>
<td class="con">Extra kb in file size for everyone to download whether query used or not</td>
<td class="pro">Smaller file size for default sheet used by browsers that don&#8217;t support media queries</td>
</tr>
<tr>
<td class="con">Have to use JavaScript to make it work in IE 8 and earlier<span>*</span></td>
<td class="pro">Can feed one of the queries to IE using conditional comments<span>*</span></td>
</tr>
<tr>
<td class="con">Harder to keep organized if CSS extensive</td>
<td class="pro">Easier to keep organized if CSS extensive</td>
</tr>
</tbody>
</table>
<p id="note-ie">* I&#8217;ll go into the details of both of these approaches to <a href="#mq-internet-explorer">dealing with old versions of IE later on in this article</a>, so sit tight if this IE stuff doesn&#8217;t make sense just yet.</p>
<h4>The bottom line</h4>
<p>In most situations, I think that embedded is the better way to go. I&#8217;ve never been a fan of separating out styles into separate sheets because I find it harder to keep things organized and easier to forget those extra sheets when debugging or updating. Plus, it adds extra HTTP requests, which are more expensive in terms of performance than having a single sheet that&#8217;s larger in file size. Because media-query-supporting browsers will download those extra sheets even they don&#8217;t currently need them, the smaller file size that you gain by separating the media queries into their own sheets is really only a benefit to browsers that don&#8217;t support media queries, as they won&#8217;t download those extra media query sheets.</p>
<p>But again—and this is the last time I&#8217;m saying this, but it applies to everything in this article—the best approach <a href="http://adactio.com/journal/4437/">depends</a> on your project.</p>
<h3 id="mq-overlap-stack">How to use the cascade: overlapping vs. stacked</h3>
<p>Regardless of whether you make your media queries embedded or external, you also need to decide whether you want them to overlap, bringing the cascade and specificity into play, or whether you want to &#8220;stack&#8221; them so only one media query applies at once.</p>
<p>Here&#8217;s what overlapping media queries look like (this example is embedded, but the same could be done with external sheets):</p>
<pre><code>body {
    background: gray;
    font-family: sans-serif;
}
@media all and (min-width:500px) {
    body {
        background: blue;
        font-family: serif;
    }
}
@media all and (min-width:700px) {
    body {
        background: red;
        color: white;
    }
}</code></pre>
<p>Do you see how these media queries are not mutually exclusive? Both apply to windows greater than 700 pixels wide. If my viewport was 800 pixels wide, for instance, it would meet both the minimum width of 500 pixels and the minimum width of 700 pixels and apply the styles from both media queries. I&#8217;d have a red background with white text in a serif font.</p>
<p>When you overlap your media queries, the cascade and specificity come into play when determining which rules to use. For instance, if I used the same exact media queries containing the same exact CSS, but changed their order so that the <code>min-width:700px</code> one was first, I&#8217;d get different results:</p>
<pre><code>body {
    background: gray;
    font-family: sans-serif;
}
@media all and (min-width:700px) {
    body {
        background: red;
        color: white;
    }
}
@media all and (min-width:500px) {
    body {
        background: blue;
        font-family: serif;
    }
}</code></pre>
<p>Now my 800-pixel-wide viewport would have a blue background instead of red—the rule that comes later with the same specificity wins.</p>
<p>Instead of overlapping your media queries, you can stack or isolate them so that each is mutually exclusive:</p>
<pre><code>body {
    background: gray;
    font-family: sans-serif;
}
@media all and (min-width:500px) and (max-width:699px) {
    body {
        background: blue;
        font-family: serif;
    }
}
@media all and (min-width:700px) {
    body {
        background: red;
        color: white;
        font-family: serif;
    }
}</code></pre>
<p>Now only one of these media queries can apply at a time: the first applies in viewports between 500 and 699 pixels, and the second applies at 700 pixels and up. This means you don&#8217;t have to worry about cascade or specificity any more, but you do have to repeat any styles that you want to apply in both situations, such as <code>font-family:serif</code> in this example. On the other hand, you don&#8217;t have to override styles from earlier media queries that you don&#8217;t want to apply in the later media queries. So neither setup <em>always</em> leads to more or fewer lines of CSS.</p>
<p>Whether you overlap or stack also has an impact on which assets get downloaded in WebKit browsers. If you have multiple media queries that apply to the same situation (such as the 500px and 700px media queries both applying to the 800px viewport example above), WebKit-based browsers will download all the images in all of them, regardless of whether a later media query overrides one of the images in an earlier one. (This also happens with the styles <em>outside</em> any media queries, by the way.) This doesn&#8217;t happen if the media queries are stacked; in this case, WebKit will only download the images called for in the single, currently applicable one. (But again, it will download any images outside the media queries too, even if later overridden.) This handy information is from Greg&#8217;s &#8220;<a href="http://blog.assortedgarbage.com/2010/12/css3-media-queries-download-answers/">CSS3 Media Queries? Download Answers</a>&#8221; and Cloud Four&#8217;s &#8220;<a href="http://www.cloudfour.com/examples/mediaqueries/image-test/">Media Query Image Download Test</a>.&#8221;</p>
<h4>The pros and cons</h4>
<table class="pros-cons">
<caption> Overlapping vs stacked media queries<br />
</caption>
<tbody>
<tr>
<th class="pro" scope="col">Overlapping pros</th>
<th class="con" scope="col">Stacked cons</th>
</tr>
<tr>
<td class="pro">Smaller file size due to cascade not requiring you to repeat shared rules</td>
<td class="con">Bigger file size due to having to repeat rules you want to apply in multiple scenarios</td>
</tr>
<tr>
<td class="pro">Easy to update shared rule in one place</td>
<td class="con">Possible to forget to change all instance of repeated rule when updating</td>
</tr>
</tbody>
</table>
<table class="pros-cons">
<caption> Overlapping vs stacked media queries<br />
</caption>
<tbody>
<tr>
<th class="con" scope="col">Overlapping cons</th>
<th class="pro" scope="col">Stacked pros</th>
</tr>
<tr>
<td class="con">Bigger file size due to overriding rules from earlier queries in later queries</td>
<td class="pro">Smaller file size due to starting with clean slate with no earlier rules to override</td>
</tr>
<tr>
<td class="con">Images that get overridden/hidden later are still downloaded in WebKit-based browsers</td>
<td class="pro">Browsers only download  images inside currently-applicable media query</td>
</tr>
</tbody>
</table>
<h4>The bottom line</h4>
<p>I think overlapping media queries is more often than not the most efficient way to go. Most sites don&#8217;t have radically different looks between media queries—sure, the layout might appear very different, but things like the typography, colors, and various visual effects are usually the same. Because of this, I&#8217;ve found that in most cases you&#8217;ll end up writing a lot more lines of CSS if you stack your media queries and don&#8217;t get to take advantage of the cascade. (Hooray for the cascade!)</p>
<p>However, if you <em>do</em> happen to have a site that has <em>very</em> different styles in each media query, stacking may be more efficient than overlapping. Also, because of WebKit&#8217;s downloading behavior, if you&#8217;re switching a lot of images between media queries, it may be wise to stack those queries instead of overlapping them, even if that means more lines of CSS and more chance of forgetting to update a rule inside multiple queries.</p>
<h3 id="mq-default-styles">Which styles to make the &#8220;default&#8221;: mobile vs. desktop</h3>
<p>While it&#8217;s possible to put all of your styles inside media queries, you&#8217;ll almost never see this, as browsers that don&#8217;t support media queries will get no styles whatsoever. What usually happens is that a chunk of styles sit outside media queries, either inside your single style sheet or in their own style sheet using a standard <code>@import</code> call or <code>link</code>, and these essentially become your &#8220;default&#8221; or starting styles. You then layer on one or more media queries to form alternate styles for different scenarios.</p>
<p>Media queries aren&#8217;t just for creating different layouts for different screen sizes, but let&#8217;s face it, that&#8217;s their primary use right now—and a dang good one. So that&#8217;s what I&#8217;m focusing on here: whether to make the small-screen styles the default or whether to make wider-screen styles the default. A few caveats, however:</p>
<ul>
<li>For ease of writing, I&#8217;m just going to refer to the smaller-screen styles as &#8220;mobile&#8221; and the wider-screen styles as &#8220;desktop,&#8221; even though mobile styles might be viewed on desktop devices and vice versa, and even though not all mobile devices support media queries.</li>
<li>Also keep in mind that even though I&#8217;m simplifying it to two options for ease of discussion, you can have multiple media queries for each of these scenarios (such as 320px, 480px, and 600px &#8220;mobile&#8221; styles and 760px, 960px, and 1200px &#8220;desktop&#8221; styles), and any of these could be your default. You don&#8217;t have to make one extreme or the other the default.</li>
<li>Finally, I&#8217;m specifically talking about which styles you make the default in the CSS itself, not about which version of the layout you first design for when coming up with wireframes, comps, and what-have-you. In a certain project, it may make the most sense to plan for the desktop design first, but when it comes time to build the media queries, make the mobile styles first. Nathan C. Ford talks about this in &#8220;<a href="http://artequalswork.com/posts/target-first.php">Design for a Target Experience First</a>.&#8221;</li>
</ul>
<p>OK, are we all good? Good. Moving on.</p>
<p>Once again, WebKit&#8217;s downloading behavior is a big factor here. If you make the desktop styles the default and then override some of its assets in a mobile media query, either by setting new background images or setting elements that contain background or foreground images to <code>display:none</code>, Safari on iOS will still download the overridden or hidden desktop assets. The reverse is true: when mobile styles are the default, desktop Safari and Chrome will download all the mobile assets, even if overridden or hidden by the desktop styles.</p>
<p>This behavior isn&#8217;t &#8220;wrong,&#8221; by the way. It&#8217;s common for browsers to download assets that are set to <code>display:none</code>, as it allows the content to be preloaded and ready-to-go if later revealed by a script, such as a hover effect over text that reveals a thumbnail image. WebKit doesn&#8217;t discriminate between situations where the currently hidden image might be needed later, such as if the user can and does resizes her viewport, or if it will never, ever be called into play.</p>
<p>If the downloading of the unneeded image is problematic in your case, there are a few ways to work around it:</p>
<ul>
<li><a href="http://www.cloudfour.com/examples/mediaqueries/image-test/#t3">Cloud Four&#8217;s test page</a> shows that if you set an image as a background on a <code>div</code>, and then instead of hiding the <code>div</code> you hide the <code>div</code>&#8217;s <em>parent</em> element, WebKit won&#8217;t download the image.</li>
<li>You could simply choose to make your default styles neither mobile or desktop—just restrict them to basic text formatting, colors, and the like. Introduce layout and images only inside media queries.</li>
<li>There are a variety of ways to use scripting to control what gets downloaded when. Read &#8220;<a href="http://www.quirksmode.org/blog/archives/2010/08/combining_media.html">Combining media queries and JavaScript</a>&#8221; by Peter-Paul Koch for the general idea behind this, as well as &#8220;<a  rel="bookmark" href="http://www.cloudfour.com/responsive-imgs-part-2/">Responsive IMGs Part 2 — In-depth Look at Techniques</a>&#8221; by Jason Grigsby for a discussion of a whole bunch of scripting techniques to load images on an as-needed basis.</li>
</ul>
<p>These solutions won&#8217;t work with all sites, but they are options in some cases.</p>
<h4>The pros and cons</h4>
<table class="pros-cons">
<caption> Mobile-default vs desktop-default media queries<br />
</caption>
<tbody>
<tr>
<th class="pro" scope="col">Mobile-default pros</th>
<th class="con" scope="col">Desktop-default cons</th>
</tr>
<tr>
<td class="pro">Prevents mobile devices from downloading unneeded desktop assets</td>
<td class="con">Mobile devices may have to download unneeded desktop assets</td>
</tr>
<tr>
<td class="pro">Older, non-media-query-supporting mobile browsers still get the mobile styles without any extra work</td>
<td class="con">Requires separate style sheets or JavaScript to make mobile design appear in IE Mobile and older mobile browsers</td>
</tr>
</tbody>
</table>
<table class="pros-cons">
<caption> Mobile-default vs desktop-default media queries<br />
</caption>
<tbody>
<tr>
<th class="con" scope="col">Mobile-default cons</th>
<th class="pro" scope="col">Desktop-default pros</th>
</tr>
<tr>
<td class="con">Requires separate style sheets or JavaScript to make majority desktop design appear in IE 8 and earlier</td>
<td class="pro">No extra work to make majority-width appear correctly on IE 8 and earlier</td>
</tr>
<tr>
<td class="con">Desktop devices may have to download unneeded mobile assets</td>
<td class="pro">Prevents desktop devices from downloading unneeded mobile assets</td>
</tr>
<tr>
<td class="con">Requires complete overhaul of existing CSS when retrofitting existing site</td>
<td class="pro">Easiest way to retrofit existing site</td>
</tr>
</tbody>
</table>
<h4>The bottom line</h4>
<p>In most cases, I would advocate making the mobile styles the default, as it allows old mobile browsers to see the correct mobile styles. Yes, desktop IE 8 and earlier will also see those mobile styles, but this is an easy to fix with some JavaScript—a much more quick and straightforward process than getting your mobile styles to apply to non-media-query-supporting mobile browsers when you make desktop the default. Also, the fact that mobile devices won&#8217;t have to download any of the assets you call in the media-query-desktop styles is a big plus, as mobile devices are more likely (but definitely not guaranteed) to have slower connections and more limited bandwidth than desktop devices. I&#8217;ve made mobile styles the default in the last two sites I worked on, and I anticipate this being my go-to method going forward.</p>
<p>While<a href="http://www.lukew.com/ff/entry.asp?933"> mobile-first design</a>, as it&#8217;s been dubbed by Luke Wroblewski, has become quite popular, and  I too will sing its praises,  I don&#8217;t agree with those who say it&#8217;s the <em>only</em> viable way to craft media queries. Desktop-default has a fair share of merit too, as you can see in its pros list above. It&#8217;s a great way to <a href="http://simplebits.com/notebook/2011/08/19/adapted/">retrofit an existing site</a>, since you can add on a chunk of mobile styles instead of having to rewrite all the CSS from scratch. It&#8217;s also a great way to get your feet wet with media queries. Designing mobile-first is a big shift in both your mindset and design process, so sticking to desktop-first might be best on your first foray into creating a site utilizing media queries. In <a href="http://stunningcss3.com/samples/index.html">Chapter 6</a> of my book <em><a href="http://stunningcss3.com/">Stunning CSS3</a></em>, I take a desktop-default approach, as I think this is an easier way to first learn  media queries. The default styles are targeted towards a size that most desktop users will see, with styles for both wider and narrower versions layered on. This means that even if I didn&#8217;t use JavaScript to fix IE 8 and earlier, or if the JavaScript doesn&#8217;t load, users will still see a layout that will work well for the majority of desktop viewport sizes—just the same as they would before we had media queries as an option. Media queries are used as progressive enhancement, not a requirement.</p>
<h3 id="mq-internet-explorer">How to deal with IE 8 and earlier versions: conditional comments vs. JavaScript</h3>
<p>Speaking of IE, you probably know that Internet Explorer 8 and earlier versions don&#8217;t support media queries. Since these browsers are likely a big chunk of your audience, I suspect you&#8217;ll want to figure out a way to get your media queries to work in IE 8 and earlier. You have a couple options: use conditional comments to feed separate media query sheets to different versions of IE or use a pre-fab script to make media queries magically work in IE.</p>
<p>To use conditional comments, you&#8217;ll vary your approach based on which set of styles, mobile or desktop, are your default. In either case, you&#8217;ll need to have your media queries separated into external sheets, not embedded in a single sheet along with your default styles.</p>
<p>If desktop styles are the default and you want to use conditional comments, you don&#8217;t need to really worry about desktop versions of IE 8 and earlier—they&#8217;ll get the desktop styles automatically. Sure, they won&#8217;t get any variations on those desktop styles that you might have included to better fit every particular viewport size, but if you&#8217;re using media queries as progressive enhancement, this isn&#8217;t likely to be a problem. Sure, it&#8217;s not <em>ideal</em> if an IE user with an 1100-pixel viewport sees the default 700-960-pixel styles instead of the 960-and-up media query, but it shouldn&#8217;t be a deal-breaker—the layout they see isn&#8217;t likely to look broken or be unusable. They shouldn&#8217;t know anything is &#8220;wrong.&#8221; So there&#8217;s nothing extra that has to be done for desktop IE 8 and earlier in this desktop-default scenario.</p>
<p>But the default desktop styles have a much bigger impact in the mobile version of IE used on Windows Phone 7. Luckily you can <a href="http://blogs.msdn.com/b/iemobile/archive/2010/12/08/targeting-mobile-optimized-css-at-windows-phone-7.aspx">target it using a conditional comment</a> and feed it your mobile-specific sheet:</p>
<pre><code>&lt;link rel="stylesheet" href="global.css" media="all"&gt;
&lt;link rel="stylesheet" href="mobile.css" media="all and (max-width: 700px)"&gt;
&lt;!--[if IEMobile 7]&gt;
&lt;link rel="stylesheet" href="mobile.css" media="all"&gt;
&lt;![endif]--&gt;</code></pre>
<p>If mobile styles are your default, the situation is basically reversed: mobile-IE is fine without any extra work, but you have to feed desktop-IE the desktop styles using conditional comments. Again, we&#8217;re in luck when it comes to conditional comment syntax: it&#8217;s possible to craft a conditonal comment that targets IE 8 and earlier—which includes the version of IE on Windows Phone 7—but then also explicitly excludes mobile-IE:</p>
<pre><code>&lt;link rel="stylesheet" href="global.css" media="all"&gt;
&lt;link rel="stylesheet" href="desktop.css" media="all and (min-width: 700px)"&gt;
&lt;!--[if (lt IE 9)&amp;(!IEMobile 7)]&gt;
&lt;link rel="stylesheet" href="desktop.css" media="all"&gt;
&lt;![endif]--&gt;</code></pre>
<p>I learned about this handy conditional comment trick from Jeremy Keith&#8217;s article &#8220;<a href="http://adactio.com/journal/4494/">Windows mobile media queries</a>.&#8221; That Jeremy is one clever guy.</p>
<p>Both of these conditional comment variations don&#8217;t actually make media queries work in IE—they basically feed an alternate, static layout to IE, not based on viewport size or anything other than IE version number and platform, without any ability to switch dynamically between states. If you need more robust media queries support in IE 8 and earlier, or if you  want to be able to embed your media queries in a single sheet, you can instead simply link to a ready-to-use script that detects your media queries and makes them work in non-supporting browsers. There are currently two such scripts:</p>
<ul>
<li><a href="https://github.com/scottjehl/Respond">Respond</a> by Scott Jehl: This script is much smaller than the other, and when you resize your window, it makes the changes appear right away without any lag. It&#8217;s main downside is that it only supports the <code>min-width</code> and <code>max-width</code> media features (the only ones I tend to use anyway!). Also, I found it triggered some totally obscure IE bug in a layout I was working on recently. But in general, I don&#8217;t have any problems with this script and highly recommend it.</li>
<li><a href="http://code.google.com/p/css3-mediaqueries-js/">css3-mediaqueries.js</a> by Wouter van der Graaf: This script is bigger and slower than Respond, but it does support more media features and may be less buggy in some scenarios. It&#8217;s not my first choice, but it&#8217;s a great option too.</li>
</ul>
<p>Both of these scripts will work in non-IE browsers too, by the way. If you want to limit them to IE so others don&#8217;t have to take the HTTP hit, hide the script call in a conditional comment:</p>
<pre><code>&lt;!--[if (lt IE 9)&amp;(!IEMobile 7)]&gt;
&lt;script src="respond.min.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;</code></pre>
<h4>The pros and cons</h4>
<table class="pros-cons">
<caption> Conditional comments vs. JavaScript for IE media query support<br />
</caption>
<tbody>
<tr>
<th class="pro" scope="col">Conditional comments pros</th>
<th class="con" scope="col">JavaScript cons</th>
</tr>
<tr>
<td class="pro">Works when JavaScript is disabled</td>
<td class="con">Doesn&#8217;t work when JavaScript is disabled</td>
</tr>
<tr>
<td class="pro">All the pros of having external media queries</td>
<td class="con">All the cons of having embedded media queries</td>
</tr>
</tbody>
</table>
<table class="pros-cons">
<caption> Conditional comments vs. JavaScript for IE media query support<br />
</caption>
<tbody>
<tr>
<th class="con" scope="col">Conditional comments cons</th>
<th class="pro" scope="col">JavaScript pros</th>
</tr>
<tr>
<td class="con">Feed IE only one static layout, rather than making media queries work so that layout can change on the fly</td>
<td class="pro">Makes existing media queries work so layout can change on the fly</td>
</tr>
<tr>
<td class="con">All the cons of having external media queries</td>
<td class="pro">All the pros of having embedded media queries</td>
</tr>
</tbody>
</table>
<h4>The bottom line</h4>
<p>Plugging in a little script takes no effort whatsoever, so if you&#8217;re using embedded media queries, why not use one of the JavaScripts? For the small percentage of people using IE 8 and earlier with JavaScript turned off, I&#8217;m not concerned about them simply seeing the default styles; if mobile is default, they&#8217;ll get simple but readable and clean, and if desktop is default, it will probably look just right anyway!</p>
<h3>Summing it all up</h3>
<p>By now  you&#8217;ve seen that there are lots of important decisions that go into how you set up your media queries for maximum efficiency, robustness, and ease of use. These decisions include whether to:</p>
<ul>
<li><a href="#mq-embed-external">Make the media queries embedded or external</a></li>
<li><a href="#mq-overlap-stack">Overlap or stack your media queries</a></li>
<li><a href="#mq-default-styles">Make mobile or desktop styles the default</a></li>
<li><a href="#mq-internet-explorer">Use conditional comments or JavaScript to add support for IE 8 and earlier versions</a></li>
</ul>
<p>Hopefully I&#8217;ve given you the information you need to make those decisions easier.</p>
<p>There are lots of other decisions you&#8217;ll need to make along the way that I haven&#8217;t covered, such as:</p>
<ul>
<li>Which media features to use (Use <code>max-width</code> or <code>max-device-width</code>? Use <a href="http://www.quirksmode.org/blog/archives/2010/04/the_orientation.html"><code>orientation</code></a>? That sort of thing.)</li>
<li>Which dimensions to target, aka the breaking points in the design</li>
<li>Which units to use for those breaking points (Pixels or <a href="http://www.goldilocksapproach.com/">ems</a>?)</li>
</ul>
<p>Don&#8217;t let all these decisions scare you off using media queries. Just know that, like any design technique, you can go about it with careful consideration or you can just quickly slap some sloppy media queries on your site. Think through the pros and cons of your media query configuration so that your media queries don&#8217;t just work, but <em>work well</em>.<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://zomigi.com/blog/media-queries-presentation/' title='Media queries presentation at indieconf'>Media queries presentation at indieconf</a></li>
<li><a href='http://zomigi.com/blog/examples-of-flexible-layouts-with-css3-media-queries/' title='Examples of flexible layouts with CSS3 media queries'>Examples of flexible layouts with CSS3 media queries</a></li>
<li><a href='http://zomigi.com/blog/bug-fixes-for-removing-the-inner-shadow-on-ios-inputs/' title='Bug fixes for removing the inner shadow on iOS inputs'>Bug fixes for removing the inner shadow on iOS inputs</a></li>
<li><a href='http://zomigi.com/blog/theres-already-a-book-on-responsive-web-design-want-to-win-it/' title='There&#8217;s already a book on responsive web design. Want to win it?'>There&#8217;s already a book on responsive web design. Want to win it?</a></li>
<li><a href='http://zomigi.com/blog/ie-7-button-text-redraw-bug/' title='IE 7 button text redraw bug'>IE 7 button text redraw bug</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zomigi.com/blog/essential-considerations-for-crafting-quality-media-queries/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>More debate on designers writing HTML and CSS</title>
		<link>http://zomigi.com/blog/more-debate-on-designers-writing-html-and-css/</link>
		<comments>http://zomigi.com/blog/more-debate-on-designers-writing-html-and-css/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 15:21:18 +0000</pubDate>
		<dc:creator>Zoe Gillenwater</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[visual design]]></category>
		<category><![CDATA[work process]]></category>

		<guid isPermaLink="false">http://zomigi.com/?p=308</guid>
		<description><![CDATA[The web is once again debating whether web designers should know how to code, and my opinion remains the same: they need to know the strengths and constraints of the medium, and knowing HTML and CSS can help in this.]]></description>
			<content:encoded><![CDATA[<p>The debate of whether web designers should know how to write HTML/CSS has started up again, sparked by <a href="http://twitter.com/elliotjaystocks/status/9227592793">Elliot Jay Stocks&#8217; tweet</a>: &#8220;Honestly, I&#8217;m shocked that in 2010 I&#8217;m still coming across &#8216;web designers&#8217; who can&#8217;t code their own designs. No excuse.&#8221;</p>
<p>Of course, 140 characters couldn&#8217;t capture his whole opinion on the subject, so he wrote a <a href="http://elliotjaystocks.com/blog/web-designers-who-cant-code/">blog post followup</a>. I strongly recommend reading it. I really agree with it.</p>
<p>Also, he later <a href="http://twitter.com/elliotjaystocks/status/9278904974">tweeted</a>: &#8220;My new opinion, based on insight from commenters:  You DON&#8217;T need to know how to write HTML/CSS. But in many scenarios it can be useful.&#8221;</p>
<p>I agree with this too, for the reasons explained well by <a href="http://www.markboulton.co.uk/journal/comments/on-designers-writing-html">Mark Boulton</a>. A web designer doesn&#8217;t necessarily need to know how to write actual HTML and CSS. But she does need to know about the limitations imposed by browsers, the strengths and weaknesses of the medium. Writing HTML/CSS can make understanding and designing around these limitations a lot <a href="http://carsonified.com/blog/uncategorized/5-good-reasons-why-designers-should-code/">easier</a>. But you can come to this understanding without learning HTML/CSS first.</p>
<p>Basically, my opinion is still the same as it was when I wrote <a href="http://zomigi.com/blog/should-web-designers-build-their-own-pages/">Should web designers build their own pages?</a> back in June 2008. Check that article out for my full opinion—including my very own architect analogy! (Seemingly a must whenever debating this topic.)<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://zomigi.com/blog/should-web-designers-build-their-own-pages/' title='Should web designers build their own pages?'>Should web designers build their own pages?</a></li>
<li><a href='http://zomigi.com/blog/essential-considerations-for-crafting-quality-media-queries/' title='Essential considerations for crafting quality media queries'>Essential considerations for crafting quality media queries</a></li>
<li><a href='http://zomigi.com/blog/css-summit/' title='Me at The CSS Summit online conference'>Me at The CSS Summit online conference</a></li>
<li><a href='http://zomigi.com/blog/the-liquid-web-site-motherload/' title='The liquid web site motherload'>The liquid web site motherload</a></li>
<li><a href='http://zomigi.com/blog/vtm-web-design-conference-2009/' title='Voices That Matter: Web Design Conference 2009'>Voices That Matter: Web Design Conference 2009</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zomigi.com/blog/more-debate-on-designers-writing-html-and-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Living, breathing design comps</title>
		<link>http://zomigi.com/blog/living-breathing-design-comps/</link>
		<comments>http://zomigi.com/blog/living-breathing-design-comps/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 19:51:31 +0000</pubDate>
		<dc:creator>Zoe Gillenwater</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[elastic]]></category>
		<category><![CDATA[flexible]]></category>
		<category><![CDATA[Flexible Web Design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[liquid]]></category>
		<category><![CDATA[work process]]></category>

		<guid isPermaLink="false">http://zomigi.com/?p=17</guid>
		<description><![CDATA[Presenting static image comps to clients can be especially problematic if you create flexible layouts. Try building an (X)HTML/CSS version of the design to show to your client instead in order to make designing and creating flexible layouts easier.]]></description>
			<content:encoded><![CDATA[<p>In my book <a href="http://www.amazon.com/Flexible-Web-Design-Creating-Elastic/dp/0321553845">Flexible Web Design</a>, I give lots of reasons why liquid/elastic layouts make sense. While this will hopefully convince you, the designer, to give them a try, it&#8217;s not necessarily going to convince your client that a flexible layout is acceptable for his or her own site—especially if you present comps to your client as static images created in Fireworks or Photoshop. Andy Clarke makes a great <a href="http://forabeautifulweb.com/blog/about/time_to_stop_showing_clients_static_design_visuals/">argument against presenting clients static design comp images</a> because they set up expectations in the client&#8217;s mind that the design is always going to look exactly that way, instead of varying based on the user&#8217;s browser, text size, installed fonts, monitor colors, etc.</p>
<p>While Andy&#8217;s proposal doesn&#8217;t just pertain to the design process for flexible sites—he seems to advocate it for all types of sites—Andy does ask:</p>
<blockquote><p>Is the fact that so many web pages are fixed width and centered a direct result of clients signing off fixed width design visuals?</p></blockquote>
<p>I&#8217;m willing to answer yes to that question. Not that this is the only reason fixed-width designs get created, but I&#8217;m sure it plays a role in many of them. As I talk a great deal about in my book, as well as the <a href="http://zomigi.com/blog/revised-presentation-slides-available/">presentation</a> I&#8217;ve made at a couple conferences lately, you can&#8217;t build a flexible page unless you&#8217;ve designed it to be flexible in the first place. You may design a page that must be fixed-width inadvertently, and won&#8217;t catch it until you go to build the page in (X)HTML and CSS. But if your client already signed off on the design when it was a static image, it&#8217;s now too late to change the design to make it liquid-compatible. Forcing yourself to build at least a rough version of the page before you present the design to the client is a great way of checking if your design is truly flexible-friendly. If you find that it isn&#8217;t, you can make design changes to avoid CSS headaches later.</p>
<p>A lot of the commentary surrounding Andy&#8217;s proposal has been that building pages for clients will take a lot more time that isn&#8217;t in the budget. I think this is a valid argument. But, I also agree with the arguments that this workflow method can actually be a time-saver—or at least that the extra time spent making the (X)HTML/CSS comp can be made up later. Andy says:</p>
<blockquote><p>As I work almost as fast in markup and CSS as I do in Fireworks, I find that the overall time that I take designing and implementing that design is dramatically reduced as I am not duplicating work. It leaves me free to spend more time on fine tuning a design and I&#8217;m sure that my designs are all the better for that.</p></blockquote>
<p>I&#8217;m right with Andy on this one. I&#8217;ll spend a lot of time futzing with the perfect border color or the perfect amount of spacing under a heading; when it comes time to build the page, I&#8217;ll have to do all that futzing over again in the CSS to find the perfect em measurement, for example, that matches the spacing I created in the Fireworks comp. It&#8217;s often faster for me to just leave all the work on these design details to my CSS development stage.</p>
<p>Another argument for time-saving comes from <a href="http://www.mindfly.com/blog/post/2008/09/A-Modest-Proposal-CSS-Not-Cannibalism.aspx">Kyle Weem&#8217;s response</a> to Andy&#8217;s original post:</p>
<blockquote><p>&#8230;you can absorb that extra time spent in the budget that <em>would have been wasted</em> on extravagant solutions generated to create identical rendering where it need not exist.</p></blockquote>
<p>Another argument I totally agree with, especially if you are trying to create flexible designs. When you build the (X)HTML/CSS before showing to the client, you catch things in your design that are going to be tough and time-consuming to build—either because you&#8217;ve designed them in such a way that you can&#8217;t make things flexible, or it&#8217;s just going to take a lot of hacking to get it looking the same cross-browser.</p>
<p>All this said, this method of showing (X)HTML/CSS pages to clients instead of static design comps is not something I&#8217;ve actually done (though I do sometimes show wireframes before design comps). But as someone who primarily designs liquid layouts now, I can see it being really beneficial to the way I work, and I&#8217;m definitely going to give it a try soon.<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://zomigi.com/blog/essential-resources-for-creating-liquid-and-elastic-layouts/' title='70+ essential resources for creating liquid and elastic layouts'>70+ essential resources for creating liquid and elastic layouts</a></li>
<li><a href='http://zomigi.com/blog/why-browser-zoom-shouldnt-kill-flexible-layouts/' title='Why browser zoom shouldn&#8217;t kill flexible layouts'>Why browser zoom shouldn&#8217;t kill flexible layouts</a></li>
<li><a href='http://zomigi.com/blog/vtm-web-design-conference-2009/' title='Voices That Matter: Web Design Conference 2009'>Voices That Matter: Web Design Conference 2009</a></li>
<li><a href='http://zomigi.com/blog/hiding-and-revealing-portions-of-images/' title='Hiding and revealing portions of images'>Hiding and revealing portions of images</a></li>
<li><a href='http://zomigi.com/blog/foreground-images-that-scale-with-the-layout/' title='Foreground images that scale with the layout'>Foreground images that scale with the layout</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zomigi.com/blog/living-breathing-design-comps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Should web designers build their own pages?</title>
		<link>http://zomigi.com/blog/should-web-designers-build-their-own-pages/</link>
		<comments>http://zomigi.com/blog/should-web-designers-build-their-own-pages/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 19:07:13 +0000</pubDate>
		<dc:creator>Zoe Gillenwater</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[visual design]]></category>
		<category><![CDATA[work process]]></category>

		<guid isPermaLink="false">http://zomigi.com/?p=16</guid>
		<description><![CDATA[Web designers need to know the strengths and constraints of HTML and CSS in order to successfully create visual designs that work for the web. They don't have to actually build the pages, but they should have some idea how to if they had to.]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a <a href="http://www.markboulton.co.uk/journal/comments/design_isnt_about_tools/">recent debate</a> in the web design blog world about whether web designers—those who create the actual visual designs in Fireworks or Photoshop—must or should know HTML and CSS. I suppose the actual thrust of the debate is whether it&#8217;s necessary or desirable to use Fireworks/Photoshop at all as part of the web design process—but I&#8217;d like to focus on this little sub-debate of designers knowing how to write HTML and CSS. Is it necessary?</p>
<p>My answer in a nutshell: Ideally, yes.</p>
<p>I&#8217;ve been lucky enough to always design the pages that I build. I&#8217;ve worked at a design agency, as part of in-house design teams, and freelance, but never have I had a separate designer create comps to then hand off to me to build.</p>
<p>I call myself lucky in this regard because even though I&#8217;ve never experienced this design process firsthand, I&#8217;ve seen how frustrating it can be for other web designers. (Note that I said &#8220;can,&#8221; not &#8220;is.&#8221;) When the visual designer doesn&#8217;t know how to actually build web pages, he or she frequently designs in elements that just don&#8217;t work well on the web. Either they&#8217;re things that cannot be built with HTML and CSS—such as elements that depend on an exact font size—or they&#8217;re things that <em>can </em>be done but are either difficult or unwise to implement, due to current best practices in the areas of standards, usability or accessibility.</p>
<p>It&#8217;s been my experience that the more experience a designer has actually building web pages, the more successful he or she is in designing interfaces and graphic elements that work well with its strengths and constraints. That doesn&#8217;t mean that every designer should build his or her own pages; it&#8217;s fine to have a division of labor, and I&#8217;m sure it&#8217;s actually the smartest process in many teams. Nor does it mean that the designer has to be an advanced HTML or CSS developer. It simply means that the designer ought to have some idea how to build the page if he or she really had to.</p>
<p>Mark Boulton argues in his post <a href="http://www.markboulton.co.uk/journal/comments/design_isnt_about_tools/">&#8220;Design isn&#8217;t about tools&#8221;</a> that &#8220;knowing how to build things in HTML/CSS limits your creativity.&#8221; I see his point and think it&#8217;s a really good one. We all have to be careful to not just keep designing things the same tired way because we&#8217;re used to building things a certain way. It can be a really positive, fun experience to drop a print designer into your comfy design nest to force you to consider new design possibilities, even if you can&#8217;t use them exactly as-is on the web.</p>
<p>But at the same time, it&#8217;s unrealistic to think that you can design without the constraint of any tools. At the Voices That Matter conference I was just at, <a href="http://www.webbedenvironments.com/blog/index.php">Jason Cranford Teague</a> gave a presentation on web typography in which he said that design is about constraint—working within it as well as overcoming it—and that if you want to work without constraint you&#8217;re an artist, not a designer. I think this applies to the question of whether designers should feel constrained by HTML and CSS, and I think the answer is yes. Architects don&#8217;t have to be qualified to build houses, but they have to have some idea of what construction techniques are possible, the physical characteristics of the materials they&#8217;re designing with, general physics, etc. They can&#8217;t just design buildings without any knowledge whatsoever of how they will ultimately be built.</p>
<p>Mark uses a print design analogy to ask &#8220;do print designers need to know how to build a press?&#8221; This analogy makes no sense to me. It&#8217;s like asking if web designers need to know how to build a browser, or a computer even. Of course not. The real question is &#8220;do print designers need to know how a press works&#8221;—and the answer to that is an emphatic <em>yes</em>. They don&#8217;t need to be qualified to actually operate a press, but they need to know the limitations and strengths of the printing press they&#8217;re work is going to be produced by. Print production processes are a pretty important part of the curriculum of any good graphic design program. (That last sentence had a lot of p&#8217;s in it!) Print designers need to know practical things like not to design important info within 1/8&#8243; of the edge of a piece, not to run something that must be matched up perfectly across the fold of a multi-page book, what type of paper they&#8217;re going to be printing on, etc. I suppose you could call this being constrained by your tools—but it doesn&#8217;t necessarily follow that that&#8217;s a bad thing.</p>
<p>(On a little tangent, I applaud Jon Hicks for pointing out during this whole debate that <a href="http://www.hicksdesign.co.uk/journal/graphics-editor-or-text-editor">Fireworks is a better tool for creating web comps than Photoshop</a>. I switched to Fireworks for web work almost five years ago and can&#8217;t imagine going back.)<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://zomigi.com/blog/more-debate-on-designers-writing-html-and-css/' title='More debate on designers writing HTML and CSS'>More debate on designers writing HTML and CSS</a></li>
<li><a href='http://zomigi.com/blog/essential-considerations-for-crafting-quality-media-queries/' title='Essential considerations for crafting quality media queries'>Essential considerations for crafting quality media queries</a></li>
<li><a href='http://zomigi.com/blog/css-summit/' title='Me at The CSS Summit online conference'>Me at The CSS Summit online conference</a></li>
<li><a href='http://zomigi.com/blog/the-liquid-web-site-motherload/' title='The liquid web site motherload'>The liquid web site motherload</a></li>
<li><a href='http://zomigi.com/blog/vtm-web-design-conference-2009/' title='Voices That Matter: Web Design Conference 2009'>Voices That Matter: Web Design Conference 2009</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zomigi.com/blog/should-web-designers-build-their-own-pages/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

