<?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>Kyle Schaeffer - Web Design and SharePoint Branding &#187; Best Practices</title>
	<atom:link href="http://kyleschaeffer.com/category/best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>http://kyleschaeffer.com</link>
	<description>Web Design &#38; SharePoint Branding</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:01:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>10 Things a Website Should Never, Ever Do</title>
		<link>http://kyleschaeffer.com/best-practices/10-things-a-website-should-never-ever-do/</link>
		<comments>http://kyleschaeffer.com/best-practices/10-things-a-website-should-never-ever-do/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 21:19:15 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Web Browsers]]></category>

		<guid isPermaLink="false">http://kyleschaeffer.com/?p=994</guid>
		<description><![CDATA[As a designer of the world wide web, you are armed with the power to amaze, enlighten, entice, and captivate. The web is an easel for your creative aspirations, and the content you design for is the foundation of your &#8230; <a href="http://kyleschaeffer.com/best-practices/10-things-a-website-should-never-ever-do/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As a designer of the world wide web, you are armed with the power to amaze, enlighten, entice, and captivate. The web is an easel for your creative aspirations, and the content you design for is the foundation of your creativity. With so much power at the tips of your fingers, you also possess the ability to deter, annoy, anger, and infuriate. Your users are yours to command, their emotions yours to pluck like the strings of a harp.<span id="more-994"></span></p>
<p>It&#8217;s the latter of these powers that we discuss today: your ability to destroy the desire for users to stay on your site. We&#8217;ll examine the causes of user strife on the web, and see clear examples of common mistakes that designers and developers all-too-often seem to make.</p>
<h2>1. Never interfere with the ability to scroll</h2>
<p>The browser window is a fairly simple application: an address/search bar, a few buttons, and a big window where users read, scroll, and click. Sure, most browsers have other bells and whistles, but it really boils down to these essential elements of the browsing experience. Rule number one: never, ever (ever, ever) interfere with these most basic features of the browser window.</p>
<h3>Example: Microsoft SharePoint 2010</h3>
<p><img class="alignright" title="Microsoft SharePoint 2010" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/sharepoint-2010.jpg" alt="Microsoft SharePoint 2010" width="300" height="175" />One of the most preposterous features of an interface that I&#8217;ve seen is SharePoint 2010&#8242;s new ribbon interface. The default SharePoint 2010 interface includes a simple CSS style that disables the scrollbar on the <code>&lt;body&gt;</code> element. Microsoft chooses to remedy this by adding a scrollbar to other division elements in the interface instead. This results in a fairly impressive &#8220;fixed&#8221; ribbon, but it has some infuriating side-effects.</p>
<ul>
<li>When a SharePoint 2010 page loads, users will not be able to scroll until all JavaScript has loaded.  On slow servers or on large pages, this can take up to 2-3 seconds, which can be quite infuriating.</li>
<li>Some devices don&#8217;t execute the JavaScript in the expected fashion, resulting in the complete inability to scroll on mobile devices and tablets.</li>
</ul>
<h3>An easy solution</h3>
<p>The truth is, creating a &#8220;fixed&#8221; element is a fairly simple CSS technique that has become extremely popular in the last few months. The complexity of Microsoft&#8217;s interface is it&#8217;s downfall. Always practice in simplicity, because fewer things can go wrong in the end. Build simple interfaces, and <em>never</em> disable the scroll bar. Do this, and you&#8217;ll know at least one person who doesn&#8217;t hate your guts.</p>
<h2>2. Never allow form resubmissions</h2>
<p>Forms are a fairly standard feature of the web. Users see them and use them all the time: to sign up, sign in, order, update, and the like. With so much familiarity, it&#8217;s a wonder that forms are one of the largest sources of frustration to users. Between data, validation, formatting, handling errors, and all the auxiliary things that seem to surround web forms, things can get pretty complex for designers and developers. All the while, you try to keep it simple for your users. It&#8217;s a tall order, to be sure, but there is at least one thing that you can do to help users stay calm.</p>
<h3>Example: The Form Resubmission Prompt</h3>
<p><img class="alignnone size-medium wp-image-1008" title="Form Resubmission" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/form-resubmission.jpg" alt="Form Resubmission" /></p>
<p>This is Google Chrome&#8217;s form resubmission prompt. Most browsers have something very similar. This appears when users click on the &#8220;Back&#8221; and &#8220;Forward&#8221; buttons in the browser, or when they &#8220;Refresh&#8221; a page on which they have submitted a form. As web junkies, we might know what this means, but it has a more elusive meaning to your every-day internet users. Most of the time, you&#8217;ll find that users simply click the default option (in this case, &#8220;Continue&#8221;), which can lead to duplication of orders, data, requests, and all sorts of things that would be better off if avoided. Also, it&#8217;s just another annoying prompt that users encounter while they&#8217;re using your site.</p>
<h3>A Simple Solution</h3>
<p>The solution to form resubmissions really depends on the platform your website runs on. In most cases, a simple fix is to separate the script that submits the form data, and the script that receives and processes that data. For example, if you&#8217;re using a PHP-based platform, you might have a form that looks like this:</p>
<pre>&lt;form action="submit.php"&gt;
  &lt;input type="text" name="user" required /&gt;
  &lt;input type="password" name="pass" required /&gt;
  &lt;input type="submit" value="Log in" /&gt;
&lt;/form&gt;</pre>
<p>To avoid the resubmission prompt, your <code>submit.php</code> script would <strong>forward</strong> to another page, rather than displaying a page in the browser.</p>
<pre>if(isset($_POST['user']) &amp;&amp; isset($_POST['pass'])){
  // do something with the form data
  <strong>header('Location:/login/form.php?success=true');</strong>
}</pre>
<p>This receiving script never actually displays anything in the browser window. Instead, it receives the form data, does something with it, and then forwards the user somewhere else. Using this technique, when users click on the &#8220;Back&#8221; or &#8220;Forward&#8221; button, the browser will skip the <code>submit.php</code> page completely, and never see the annoying form resubmission prompt.</p>
<h2>3. Never disable keyboard support</h2>
<p><img class="alignright size-full wp-image-1009" title="Sprint Sign-In" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/sprint-sign-in.jpg" alt="Sprint Sign-In" width="179" height="357" />While we&#8217;re on the topic of forms, let&#8217;s look at another deviation from web standards you&#8217;ll want to avoid. To the right, you&#8217;ll see a screenshot of the login form at <a href="http://mysprint.sprint.com">mysprint.sprint.com</a>. I have a Sprint mobile phone, and I occasionally use this login form to sign in and review my account, see my bill, or (more commonly) daydream about all the fancy new mobile phones that I don&#8217;t have.</p>
<h3>What went wrong</h3>
<p>The font sizes are a little small for my taste, but the appearance of this form is not the worst I&#8217;ve seen (yes, that was a compliment). Design and aesthetics aside, there&#8217;s one feature of this form that drives me absolutely crazy. It&#8217;s an extremely simple form, one that I&#8217;ve encountered on countless other websites before. As usual, I would expect to enter my username and password to sign in without a fuss.</p>
<p>Unfortunately, this is not the case. While focusing in either the username or password textbox, pressing the ENTER key does absolutely nothing. I&#8217;m not the type of user that wastes time after filling out a form by lifting my hand from the keyboard and finding the submit button with my mouse cursor. I&#8217;m all about speed: on most websites, it&#8217;s type, type, ENTER, and the form has been submitted. On Sprint&#8217;s website, however, they&#8217;ve removed this behavior, and thus they&#8217;ve earned a place on my list of don&#8217;t-do&#8217;s.</p>
<h2>4. Never fail to give feedback</h2>
<p><img class="alignright size-full wp-image-1016" title="Facebook - Add Favorite" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/facebook-add-favorites.jpg" alt="Facebook - Add Favorite" width="201" height="344" />Feedback is important, especially if you&#8217;re working with the awesomeness of AJAX. Traditionally, you knew what was going on in a web page, because any time you clicked on something, you had to wait while the next page loaded. There was a very apparent interaction period, and very obvious feedback from that interaction. With the introduction of new technology like AJAX, however, that feedback is not always so obvious. Today&#8217;s websites are much more interactive, and the result of those interactions (whether successful or not) needs to be communicated to the user.</p>
<h3>Example: Facebook</h3>
<p>There&#8217;s an easy way to test this: visit a web page, turn off your wireless adapter, and then click on things and see what happens. Obviously, because you&#8217;re not online, anything you do should be very obviously followed by a &#8220;no connection&#8221; message or some sort of indication that you&#8217;ve failed to do something. Facebook, a website that makes gratuitous use of AJAX for interaction, is not so good about warning users when things have failed.</p>
<p><strong>Editor&#8217;s note:</strong> yes, I am using pirate Facebook.</p>
<p>One particular example is the new &#8220;lists&#8221; feature that allows you to mark a list as &#8220;favorite.&#8221; Even when you&#8217;re offline, Facebook gives you no indication that the action has failed. Never assume that users will have a fast connection, or that AJAX requests will complete. You should always provide feedback if something fails, especially when no page loads are involved.</p>
<h2>5. Never disable keyboard navigation</h2>
<p>Different strokes for different folks. That&#8217;s a saying that I like to spew off at random times, usually in a failed attempt at humor, but the lesson of this silly quip is tried and true: everyone has their own way of doing things. This can also be applied to navigation on the internet. Some people prefer to use their cursor for absolutely everything, and only resort to keyboard use when absolutely necessary. Others use the keyboard almost entirely, tabbing, backspacing, and scrolling their way through the world of the world wide web. Others, still, use gestures and touch screens to flick and fly their way through the internet. As a crafter of the interactive, you must adhere to all of these people. Never detract from your users&#8217; ability to navigate in whatever way they damn well please.</p>
<h3>Example: No, I don&#8217;t want to search</h3>
<p><img class="alignright size-full wp-image-1027" title="eBay Auto-focus" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/ebay-search.jpg" alt="eBay Auto-focus" width="202" height="101" />I&#8217;m going to use eBay as an example, just because they&#8217;re so big, but many websites <em>out there</em> are guilty of this annoyance. Upon arriving at eBay&#8217;s website, they use JavaScript to auto-focus on the search bar. I guess they&#8217;ve already decided, before you even visit, that you want to search their website. For some users, however, this can be incredibly annoying. A common and simple way to scroll down the page, in all browsers, is to press the space key. Pressing this key will advance the screen about one page, so you can continue reading without having to worry about scroll bars and the like. If you&#8217;re auto-focused on a search box, however, it disables your ability to do this. Even if it&#8217;s only a minor annoyance, it can be incredibly frustrating to users who like to navigate in this fashion. Likewise, I often use the backspace key instead of the back button to go back when I didn&#8217;t find what I was looking for. With the focus on a search field, backspace navigation simply doesn&#8217;t work.</p>
<p>The fix for this one is easy: don&#8217;t do it. It&#8217;s annoying.</p>
<h2>6. Never move content without user interaction</h2>
<p>Websites can be so damn sneaky. I guess they need to make a buck, but who doesn&#8217;t? One thing that will drive your users bonkers is anything that moves without a prompt from the user. Yes, I&#8217;m talking about you, &#8220;auto-expanding-advertisement-that-plays-a-stupid-video-of-a-guy-who-walks-across-my-screen-when-I-just-want-to-read-the-damn-article&#8221; guy. I also dislike anything that happens on hover (including drop-down menus). Hover is so 2000&#8242;s, get with the times, people. The only time your website should &#8220;move&#8221; or &#8220;do something&#8221; is when users tell it to. Most simply, any time they click, drag, or scroll. That sounds simple and obvious, but not everyone adheres to this most basic of principles.</p>
<h3>Example: Digg.com</h3>
<p><img class="alignnone size-full wp-image-1028" title="Digg Advertisement" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/digg-advertisement.jpg" alt="Digg Advertisement" width="600" height="300" /></p>
<p>While the quality of Digg&#8217;s content is another concern, one thing that does drive me crazy is the sponsored links that appear in the rollup. Notice the promotion from NewEgg.com. This link does not actually appear on page load, but rather when users hover their mouse cursor into the rollup of popular stories. This means that if you&#8217;re a fast clicker (aren&#8217;t we all?), you will often accidentally click on the advertisement instead of the story you&#8217;re interested in. Good for Digg, bad for users. Stop being so shifty, internet.</p>
<h2>7. Never use fixed position without a fallback</h2>
<p>A &#8220;fixed&#8221; element in the browser window is one that stays on the screen, even as you scroll down the page. It&#8217;s a simple CSS technique, but it&#8217;s been amazingly popular in recent months. One thing I&#8217;ve noticed in all these fixed designs is the failure to provide a fallback for users who are on smaller screens. The truth of the matter is that the web isn&#8217;t just for desktops any more. Internet connectivity is coming in all sorts of shapes and sizes: desktops, laptops, mobiles, tablets, e-readers, gaming consoles, and even refrigerators (yes, even refrigerators). The future promises only more diversity in internet-connected devices, and that means you can&#8217;t assume users will have a large viewing area on which to see your website.</p>
<h3>Example: Pandora.com</h3>
<p><img class="alignright size-full wp-image-1035" title="Pandora Fixed" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/pandora-fixed-nav.jpg" alt="Pandora Fixed" width="403" height="269" />This is a screenshot of Pandora&#8217;s fancy new HTML5/CSS3 design. First of all, I&#8217;ll say that I love Pandora.  Maybe too much. It&#8217;s pretty awesome, and it even lets me give all of my radio stations quirky little names like &#8220;Harmonizatorasaurous&#8221; (eat that, spell-check).</p>
<p>Pandora&#8217;s new design includes a fixed header, like many new designs, but it seems the header does not provide a fallback for users on a smaller screen. When reducing the window width, it clips the player controls off the edge of the screen. If a fixed element is clipped, users can&#8217;t see it, even if they try to scroll to see more, which can be a huge problem.</p>
<h3>A simple solution</h3>
<p>An easy solution to this problem is to make the default behavior of your site&#8217;s header to maintain a static position, but when users have a large enough screen, you can make things fixed for a more impressive presentation.  The following jQuery snippet does the trick quite nicely:</p>
<pre>$(window).resize(function(){
  resizeUI();
}); 
$(document).ready(function(){
  resizeUI();
});

<strong>// resize on page load AND window resize</strong>
<strong>function resizeUI(){</strong>
<strong> if($(window).width() &gt; 500){</strong>
<strong> $('#header').css('position', 'fixed');</strong>
<strong> }</strong>
<strong> else{</strong>
<strong> $('#header').css('position', 'static');</strong>
<strong> }</strong>
<strong>} </strong></pre>
<p>This script runs both on page load AND as users resize the window, so no matter what happens, you can decide whether or not to use fixed elements. You&#8217;ll have to mess with the values that the script looks at (width and height) to determine what works best for your site&#8217;s design, but it&#8217;s a useful technique to use.</p>
<h2>8. Never use pop-up windows</h2>
<p>Do I really even have to mention this one? I thought that pop-ups were notorious for the infuriating behavior that have on users, but I still see them &#8220;pop up&#8221; from time to time (pun <em>intended</em>).</p>
<h3>Example: TinyMCE</h3>
<p><img class="alignright size-full wp-image-1036" title="TinyMCE" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/tinymce.jpg" alt="TinyMCE" width="185" height="98" />I never use pop-ups. I always recommend against them. A common excuse is that <em>your</em> site should stay open, in it&#8217;s own tab, even if users click a link that takes them away from your site. I&#8217;ve got a simple response to that: wrong! Don&#8217;t let your head grow so big that you think your website is god&#8217;s gift to the internet. Users have gotten pretty comfortable with the idea of tabbed browsing, and they know how to manage their windows. Unless you&#8217;re Google, you&#8217;re not allowed to use pop-ups. It&#8217;s that simple.</p>
<p>Imagine my surprise when I attempted to implement the TinyMCE JavaScript editor into a web application I was building, and realized it still used pop-up windows for things like links and images. I am building a PHP application, and I have had stars in my eyes for WordPress the entire time, so TinyMCE was the obvious choice. I was so taken aback by this behavior that I ended up switching to CKEditor, another popular editor that has recognized the need to rid the world of these annoying little boxes, and I&#8217;m all the happier for it.</p>
<h2>9. Never get quirky (well, not <em>too</em> quirky)</h2>
<p>I love websites that are different, but not <em>too</em> different. There&#8217;s a fine balance to be made between adhering to expectations, and getting so weird that users have no idea what&#8217;s going on. As with most users, if I visit a website and am prompted to &#8220;explore this insanely huge image of nonsense to learn how to navigate our site,&#8221; I&#8217;m going to leave and never return. I&#8217;ve never been a proponent of Flash, for this very reason, but I also recognize that it has it&#8217;s place. Flash can enhance a website&#8217;s content with some awesome features, but it should never be used to present content in its entirety.</p>
<h3>Example: Sony.com</h3>
<p><img class="alignright size-full wp-image-1038" title="Sony" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2011/09/sony.jpg" alt="Sony" width="305" height="133" />Check out <a href="http://www.sony.com">Sony.com</a>, and you&#8217;ll realize that a full 5-8 seconds will go by before you actually see anything on the screen that you can click on. Almost the entire site is in Flash, and it breaks about five of the ten &#8220;don&#8217;t do&#8217;s&#8221; that I&#8217;ve described in this article. All that aside, Sony has provided a non-Flash version of their site, which also subsequently presents a loading spinner for about 2-3 seconds that covers all of the content on the page. I&#8217;m not entirely sure why the designer who created the Sony website was so fond of things that come between users and consuming the content they came to read, but I do know this: it&#8217;s annoying. Don&#8217;t do it.</p>
<h2>10. Never do THIS&#8230;</h2>
<p>Okay, this last one is really just for fun, but never do THIS&#8230;</p>
<pre>body * {
  -webkit-transition: all 0.5s ease;
  -moz-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
}
body *:hover {
  -webkit-transform: rotate(180deg);
  -moz-transform: rotate(180deg);
  -o-transform: rotate(180deg);
  transform: rotate(180deg);
}</pre>
<p>Try it out by clicking on this button (you&#8217;ve been warned):</p>
<input id="crazy-button" type="button" value="Let's get crazy" />
<script src="/wordpress/wp-content/themes/shakefive/js/crazy.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/10-things-a-website-should-never-ever-do/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>From &#8220;Developer&#8221; to &#8220;Designer&#8221;</title>
		<link>http://kyleschaeffer.com/best-practices/from-developer-to-designer/</link>
		<comments>http://kyleschaeffer.com/best-practices/from-developer-to-designer/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 16:34:16 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Web Browsers]]></category>

		<guid isPermaLink="false">http://kyleschaeffer.com/?p=964</guid>
		<description><![CDATA[It&#8217;s easy to forget how a website really works. I mean really works. I&#8217;ve had the pleasure of working with many brilliant and talented developers (programmers) who could bend the functionality of any application or server-side platform at the drop &#8230; <a href="http://kyleschaeffer.com/best-practices/from-developer-to-designer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s easy to forget how a website really works. I mean <em>really works</em>. I&#8217;ve had the pleasure of working with many brilliant and talented developers (programmers) who could bend the functionality of any application or server-side platform at the drop of a hat. They are problem-solvers, as is everyone in this industry of the online.<span id="more-964"></span></p>
<p>With most developers, I&#8217;ve found that there can be a disconnect between how I understand websites, and how they&#8217;ve come to understand them. Not just <em>a </em>disconnect: <em>The Disconnect</em>. If you work in a team environment, you know the feeling. I say &#8220;element,&#8221; and you say &#8220;control.&#8221; I say &#8220;script,&#8221; and you say &#8220;method.&#8221; Most developers are ultimately, completely, and entirely focused on the server-side application.</p>
<p>That&#8217;s okay. I need my developers, and they need me. It&#8217;s a good relationship for all of us, with our complimentary skills, tools, and techniques. They make it work, and I make it look good.</p>
<h2>How to Connect</h2>
<p>Overcoming the <em>Disconnect</em> is all about education, on both sides of the fence. Developers and designers alike would benefit from understanding how the technology that they use comes together. The grand finale of everything that we do online ends up in a single place, where it can be seen, read, clicked, and tested: the browser window.</p>
<p>As a designer, that&#8217;s where my beautiful designs will end up, and they somehow need to be translated from Photoshop into HTML and CSS that works well with the server-side application. Good designers understand the technology before they create the designs. Likewise, as developers, the controls and methods that you create are all somehow translated into HTML, whether you&#8217;ve recognized that or not. Understanding the output of what you do in the application is just as important as making the application work.</p>
<h2>Don&#8217;t Forget the Browser</h2>
<p>This is where it all ends up. Everything that we do as designers, developers, project managers, or architects: it all comes together in the browser window. The browser is the tool that is used to present all of your hard work, everything that you&#8217;ve done throughout an entire project. With so much responsibility resting upon the shoulders of the browser, why is it that so many people ignore it completely?</p>
<p>Back in <em>The Day</em>, the browser is all there was. In 1989, Tim Berners-Lee created the world&#8217;s first web server. When requested, it <em>served</em> up documents to be viewed inside the very first web browser. These documents were pure HTML, and the browser interpreted that language in order to create Hyper-Text documents that could be <em>linked</em> together. As you probably know, this simple concept caught on, and by the mid 1990&#8242;s, the Internet had become arguably the most influential product of Man in the 20th century.</p>
<p>Everyone that works in the industry of the world wide web should pay their respects to the oft-neglected browser. It has so much power, and it is the tool that allows us to do what we do. The browser is everything. The W3C and WHATWG can make all the recommendations they want: nothing really happens until browsers support it. In the mid 2000&#8242;s, the W3C started working on a recommendation called XHTML 2.0. It failed. The browser manufacturers didn&#8217;t like it, and that&#8217;s why we&#8217;re now working with HTML5 instead of XHTML2. Similarly, Microsoft created something called the XMLHTTPRequest in the early- to mid-2000&#8242;s, and everyone loved it. The major browsers quickly adopted this technology, and AJAX was born.</p>
<p>The point is, the browser truly has the power in web application development. It doesn&#8217;t matter if you&#8217;re a programmer or a designer: you need to understand how technology works inside the confines of this little window. In all the amazing technology that surrounds the Internet, it&#8217;s really based on a few simple languages: HTML, CSS, and JavaScript.</p>
<h2>Making Requests</h2>
<p>Web browsers are fairly simple applications. In essence, they do two things: make requests, and handle responses. A request might be something like &#8220;show me the document at KyleSchaeffer.com,&#8221; or &#8220;give me the image at /images/kittens.jpg.&#8221; The server that you&#8217;re requesting from then responds and the browser does something with the response. It all sounds very simple, but it&#8217;s so easy to forget this fundamental layer of web technology. I&#8217;ve helped troubleshoot dozens of web applications, and my first question is always &#8220;What request is the browser making?&#8221;</p>
<p>This entire process is called an <strong>HTTP request</strong>. HTTP requests are sent by your browser every time you type something into the address bar. The first requests is almost always an HTML document, and then the browser subsequently makes additional requests for things like CSS files, JavaScript, and images. Even if your web application is running on PHP or ASP.NET or SharePoint, the server is returning an HTML document, which subsequently loads additional resources. Simple, right?</p>
<h3>1. The Request</h3>
<p>Every HTTP request has a <strong>URI</strong>, or Uniform Resource Identifier. That&#8217;s a fancy way of saying the <em>address</em> of the resource you&#8217;re requesting. The address can be both absolute (<code>http://kyleschaeffer.com/images/kittens.jpg</code>) or relative (<code>/images/kittens.jpg</code>). The browser sends this request to the &#8220;Internet,&#8221; which routes the request to the appropriate server, somewhere <em>out there</em>. The browser then waits for a response.</p>
<h3>2. The Response</h3>
<p>After sending a request, the server that you requested the document from will send back a <em>response</em>. Again, the browser handles the responses, and each resource that is requested is handled differently. First of all, the browser reads the HTTP <strong>response code</strong>, which is an indication of the status of your request. The most common HTTP response codes are:</p>
<ol>
<li><strong>200 OK</strong> - The most common response; the resource you requested was found</li>
<li><strong>301 Moved Permanently</strong> - The resources has moved, and the browser will redirect the request to the new location</li>
<li><strong>304 Not Modified</strong> - The resource was found, and your browser already has the most recent version in the browser cache (yay!)</li>
<li><strong>401 Unauthorized</strong> - You need to sign in to see this resource</li>
<li><strong>403 Forbidden</strong> - You&#8217;re not allowed to see this</li>
<li><strong>404 Not Found</strong> - The resource you requested does not exist</li>
<li><strong>408 Request Time-Out</strong> - That took too long, sorry</li>
<li><strong>500 Internal Server Error</strong> - Something went wrong!</li>
</ol>
<p>My descriptions of each response are less than technical, but you get the idea. If you&#8217;ve ever wondered what the &#8220;404&#8243; in &#8220;404 Not Found&#8221; meant, it&#8217;s the HTTP response code for &#8220;not found.&#8221; For a more comprehensive list of HTTP response codes, visit the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html">W3C&#8217;s documentation</a>.</p>
<p>Another important element of the HTTP response is the <strong>Content Type</strong>. This tells your browser how to handle the requested resource when it&#8217;s downloaded. Unlike on your computer, your browser does not decide how to use a resource based on it&#8217;s file extension! It&#8217;s all about the content type. Some of the more clever server-side programmers can actually utilize this element of the HTTP response to create server-side scripts that actually disguise themselves as other types of content (like a PHP script pretending to be JSON or XML).</p>
<h3>3. Execution</h3>
<p>At this point, the browser now knows the HTTP response code, and the resource content type. Using this information, it&#8217;s time to make something happen. The browser downloads the resource, and presents it inside the browser window. Browsers can sometimes handle resource requests differently, so this is where you get into the nuances of browser testing. One browser might handle HTML and CSS requests slightly different from another, so testing your applications is merely a practice of testing how these HTTP responses are handled.</p>
<h2>From &#8220;Developer&#8221; to &#8220;Designer&#8221;</h2>
<p>Bridging the divide between developers and designers is all about understanding how the different technologies of the web come together. The browser window is the one place where the user experience, the architecture, the design, the program, the database, and everything else that goes on behind the scenes comes to fruition and is finally presented. Clients pay for you to meet needs and requirements, but what they ultimately expect is something that appears inside the little box that they call the Internet. Embrace it, learn it, love it, know it inside and out, and you&#8217;ll find that disconnecting from <em>The Disconnect</em> is not so difficult after all.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/from-developer-to-designer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Responsive Layouts Using CSS Media Queries</title>
		<link>http://kyleschaeffer.com/best-practices/responsive-layouts-using-css-media-queries/</link>
		<comments>http://kyleschaeffer.com/best-practices/responsive-layouts-using-css-media-queries/#comments</comments>
		<pubDate>Tue, 03 May 2011 02:23:03 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Columns]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://kyleschaeffer.com/?p=898</guid>
		<description><![CDATA[The days of the desktop are numbered. In the past, designing a web interface involved targeting a screen resolution in the vicinity of 960 pixels wide. For many years, this worked, and it worked well, because 99% of online users &#8230; <a href="http://kyleschaeffer.com/best-practices/responsive-layouts-using-css-media-queries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<p>The days of the desktop are numbered. In the past, designing a web interface involved targeting a screen resolution in the vicinity of 960 pixels wide. For many years, this worked, and it worked well, because 99% of online users could easily read and scroll at that resolution, regardless of the browser, operating system, or machine they were using. <em>Times have changed.</em><span id="more-898"></span></p>
<p>The supreme rule of desktop design began to wane in the past couple of years. With the explosion of the mobile browser phenomenon (largely due to devices like the iPhone, Blackberry, and the Android operating system), online traffic began to show the first signs of diversification. With increasing numbers of users on these mobile devices, the distinction between <em>mobile</em> and <em>desktop</em> content was born. As you most likely have noticed, many online publishers have chosen to neatly dissect their content into two distinct applications that serve two distinct types of devices. You have &#8220;mobile&#8221; versions of many websites available today, which often offer similar or identical content to what can be found on the desktop version of that same website. Very simply, the web server detects the device that&#8217;s requesting the content, and serves up a different document (or redirects to a different location) depending on the device being used.</p>
<p>Today, this dichotomy between mobile and desktop content persists as the most popular strategy for serving up web content to a multitude of devices. The technical implementation of this strategy differs from site to site, but the end result is the same: a design and layout that targets a single device or resolution. This has been a great approach for many online publishers because it offers so much flexibility in the appearance of mobile content. By segregating a design into two entirely different implementations, the limits to what can be done on a mobile site are nearly limitless. As with every design, however, there are disadvantages to this approach that cannot be overlooked:</p>
<ul>
<li><strong>Increased effort</strong> – it is more difficult to create and maintain two separate design layouts simultaneously.</li>
<li><strong>Publishing concerns</strong> – creating a division between mobile and desktop content begs the question: where does the content come from? Should all desktop content be available on the mobile site? Do you publish everything twice (once for desktop, once for mobile users), or do you dual-publish to both mediums simultaneously?</li>
<li><strong>Planning for diversification</strong> – is &#8220;mobile vs. desktop&#8221; really good enough?</li>
</ul>
<p>The last disadvantage listed here is perhaps the most important point to consider. Recent history has shown that targeting a single device (i.e. the desktop) did not withstand the test of time. Is the simple distinction between &#8220;mobile&#8221; and &#8220;desktop&#8221; content really good enough?</p>
<h3>Mobile is important, but not end-all.</h3>
<p>The truth of the matter is that mobile devices are taking off. According to <a href="http://www.businessinsider.com/mary-meekers-web-2010-11#-10" target="_blank">Mary Meeker of Morgan Stanley</a>, the sale of &#8220;smartphones&#8221; is expected to overtake PC sales (both desktops and notebooks) by next year. Browsing statistics are showing this trend as well. <a href="http://gs.statcounter.com/" target="_blank">StatCounter</a> shows that about 6.5% of all users in North America are browsing on mobile devices. You can count on about one in twenty users experiencing your online content on a three inch screen – how does your content stack up in this scenario? If you haven&#8217;t thought about it yet, it&#8217;s time to start.</p>
<p>The growth of the smartphone landscape and the diversification of browsing statistics are the driving factor behind the explosion of mobile-friendly site design. Today, this practice is entirely acceptable, but don&#8217;t count on anything in this industry to stick for more than a few years. Mobile devices aren&#8217;t the only new kids on the block.</p>
<h3>Enter the tablet.</h3>
<p>Tablet devices like the iPad and similar devices that utilize the Android operating system have been somewhat of a curveball in the industry of web design. They&#8217;re not quite mobile devices, and they&#8217;re not quite desktops, but rather somewhere in between. In the current design landscape, where everything has been neatly divided between mobile and desktop content, many designers are choosing to place tablets into the &#8220;mobile&#8221; category, serving up tablet content in like kind. This does not always go over well with tablet users, who justifiably feel that the tablet offers unique advantages of a desktop computer, namely a better browsing experience than what can be had on a smaller mobile device.</p>
<p>What, then, do we do with these users?</p>
<h2>Responsive Web Design</h2>
<p>The ongoing problem is that as designers, we&#8217;ve set our minds on this idea that a web interface is going to be displayed on a screen that is 1024 pixels wide (or larger). It&#8217;s a desktop mindset; anything smaller than 1024 is a &#8220;mobile&#8221; device and generally gets a pixel value of about 320 pixels. All devices that access our online content must adhere to one of these two layouts – there are two numbers, and nothing in between.</p>
<p>The trouble for web designers is that internet connectivity is rapidly spreading to a vast array of devices and products that people use every day. Someone might access your online portal from a desktop, phone, notebook, netbook, tablet, or even some consumer appliances. The Nintendo Wii, for instance, comes loaded with an Opera browser that&#8217;s quite good, and is hindered only by the fact that many televisions only have a resolution that is 480 to 720 pixels wide. At this resolution, many website layouts simply don&#8217;t provide an enjoyable user experience due to poor formatting and display on smaller screens. Furthermore, there is no end in sight. Expect this diversification of internet-ready devices to increase in the coming years, and plan to change the way you design and create layouts for the web.</p>
<p>The great thing is, whether you recognize it or not, this is actually a very good thing. Web layouts have been too rigid and design-centric for a long time now, and forcing designers to apply layouts to a multitude of devices will encourage them to create content that can be consumed in a variety of mediums. In the end, this translates into a better experience for the user, who doesn&#8217;t have to worry about what device they are on, what resolution they&#8217;ve chosen, or what issues they may encounter. <a href="http://ethanmarcotte.com/" target="_blank">Ethan Marcotte</a> sums it up best in his article, &#8220;<a href="http://www.alistapart.com/articles/responsive-web-design/" target="_blank">Responsive Web Design</a>&#8221; from A List Apart:</p>
<blockquote><p>Rather than tailoring disconnected designs to each of an ever-increasing number of web devices, we can treat them as facets of the same experience. We can design for an optimal viewing experience, but embed standards-based technologies into our designs to make them not only more flexible, but more adaptive to the media that renders them. In short, we need to practice responsive web design.</p></blockquote>
<p><strong>Responsive web design</strong> is creating web layouts that can adapt to a multitude of displays and devices. Using this technique, you can eliminate the need to create device-centric designs (like a &#8220;mobile&#8221; site), and allow your content to be displayed from a single source, on an unlimited number of mediums.</p>
<h2>Techniques for Responsive Web Design</h2>
<p>Responsive web design is not &#8220;one big thing.&#8221; It&#8217;s a collection of disciplines and techniques that you employ to ensure that your designs can appear fluidly on a multitude of display sizes. The fundamental change that you have to make to start creating responsive designs is to ask yourself with everything that you do: what happens with this content when the display shrinks? Plan for a multitude of resolutions from the very beginning. By mere acknowledgement and foresight, you&#8217;ll find that the challenge of creating a responsive layout is not so difficult to overcome.</p>
<h3>1. Layout Width</h3>
<p>The most important element of flexibility that must be employed in your responsive design is a fluid layout width. This is the condemning factor that breaks many designs when they are viewed on smaller display screens. Create wrapper, content, and column widths that can stretch display ideally in different resolutions. There is no &#8220;trick&#8221; to this technique, it&#8217;s merely a change in the way you create columns in your style sheets. Here&#8217;s an example:</p>
<pre>#wrapper {
  width: 80%;
  margin: auto;
  max-width: 1200px;
}</pre>
<p>This is a simple example of a fluid design width. Setting a max-width on your design is a good idea to salvage any formatting issues for users on very large resolution monitors.</p>
<h3>2. Responsive Design and Column Widths</h3>
<p>In most designs, you might be working with multiple column widths to display content in a number of different ways. In your style sheet, you could simply apply a percentage width to each column, but this technique is generally not ideal. In many cases, a sidebar column may include fixed-width elements like advertisements, menus, or text that does not necessarily adapt in any beneficial way as the width of your layout grows. Instead, you may choose to adapt only a single column as the layout width changes. This is a common layout structure that can easily be created within your existing style sheet. Consider the following example:</p>
<pre>#wrapper {
  width: 80%;
  margin: auto;
  max-width: 1200px;
}
<strong>#column-main {</strong>
<strong>  margin-left: 200px;</strong>
<strong>}</strong>
<strong>#column-sidebar {</strong>
<strong>  width: 200px;</strong>
<strong>  float: left;</strong>
<strong>}</strong></pre>
<p>In this example, the &#8220;main&#8221; column will always fill the width of the layout area, and the sidebar column (in this example, on the left) will always remain exactly 200 pixels wide.</p>
<h3>3. What about images?</h3>
<p>A common concern when moving from a fixed-width to a fluid layout is HTML images (the &lt;img&gt; element). An image file, for the most part, is a fixed-size file that does not scale as your design width decreases. This results in some rather unsavory presentation bugs, like large images being drawn beyond the edge of the browser window. The solution is a simple addition to your design&#8217;s style sheet:</p>
<pre>img {
  max-width: 100%;
}<span style="font-size: 13px; line-height: 19px; color: #444444; font-family: Georgia, 'Bitstream Charter', serif; white-space: normal;"> </span></pre>
<p>This simple addition causes any images in your design to display at full size by default. As the width of the design layout shrinks so that the image is too wide to display in the confines of it&#8217;s parent element, the image too, begins to shrink.</p>
<p>It&#8217;s worth noting that the image scaling ability of Internet Explorer is admittedly poor at best. Ethan Marcotte shares his very handy <a href="http://unstoppablerobotninja.com/entry/fluid-images/" target="_blank">Fluid Images</a> script to help alleviate your scalable image woes.</p>
<h3>4. No More Zoom</h3>
<p>Many mobile devices and tablets utilize a &#8220;zoom&#8221; feature to display content that is too large to fit on smaller display screens. This is an important utility for mobile and tablet users, but it creates a detrimental experience for users, as they have to constantly zoom in, pan, and zoom out in order to browse your web document&#8217;s content. You can disable this zooming behavior by way of a simple &lt;meta&gt; element in your design&#8217;s header.</p>
<pre>&lt;meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" /&gt;</pre>
<p>This meta element is only interpreted by a number of browsing devices (namely smartphones and tablets). <strong>You should only disable the zoom feature if it enhances users&#8217; ability to consume content on your site</strong>. If you&#8217;ve formatted your design layout so that users don&#8217;t need to pan or zoom, the zoom feature actually impairs the user from navigating your content (which only needs to scroll vertically). If you&#8217;ve incorrectly formatted your layout, however, disabling the zoom feature will only further infuriate your users, as you are removing a very important navigation capability of the browser.</p>
<h3>5. CSS Media Queries</h3>
<p>The final and most powerful technique that you can employ for responsive web design is a fairly new feature of CSS technology called the <strong>media query</strong>. Very simply, CSS media queries allow you to apply changes to your site&#8217;s design based on the viewing size and capability of the device on which your content is displayed. This is an extremely powerful tool for creating responsive designs, and it has garnered support across all major mobile browsers (including Safari, Chromium, Opera, and even the forthcoming Internet Explorer Mobile [Windows Phone 7]). Here&#8217;s a simple example of using a media query in your design&#8217;s style sheet:</p>
<pre>#wrapper {
  width: 80%;
  margin: auto;
  max-width: 1200px;
  <strong>min-width: 800px;</strong>
}
<strong>@media screen and (max-width: 800px) {</strong>
<strong>  #wrapper {</strong>
<strong>    width: 90%;</strong>
<strong>    min-width: 0;</strong>
<strong>  }</strong>
<strong>}</strong></pre>
<p>In this example, we use the same fluid layout as before, but we&#8217;ve added a new minimum width (800 pixels) to the style sheet. If the width of the screen drops below 800 pixels, all of the styles defined in our media query will take effect, and the wrapper will be resized to 90% of the design width (with no minimum width).</p>
<p>The power of media queries becomes more apparent in a layout with columns. Consider the following example:</p>
<pre>#wrapper {
  width: 80%;
  margin: auto;
  max-width: 1200px;
  <strong>min-width: 800px;</strong>
}
#column-main {
  margin-left: 200px;
}
#column-sidebar {
  width: 200px;
  float: left;
}
@media screen and (max-width: 800px) {
  #wrapper {
    width: 90%;
    min-width: 0;
  }
  <strong>#column-main {</strong>
<strong>    margin-left: 0;</strong>
<strong>  }</strong>
<strong>  #column-sidebar {</strong>
<strong>    width: auto;</strong>
<strong>    float: none;</strong>
<strong>  }</strong>
}</pre>
<p>In this example, when the width of the device screen drops below 800 pixels, we completely reformat the appearance of the columns in our design. Rather than displaying a fixed-width sidebar column, at 800 pixels or less, this design switches to a stacked column layout (with the sidebar displaying on top or below the main column). This preserves space on smaller screens, and provides an easy way to display multiple columns on devices that aren&#8217;t suited for column-based layouts.</p>
<p>The great part about media queries is that you can define multiple queries in your style sheet. You can have a design layout for desktop machines, a new layout for tablets, and yet another new layout for smaller devices like mobile phones. The number of variations is limited only by what you can do within your style sheet. Furthermore, the latest versions of desktop browsers like Firefox, Safari, Chromium, and even Internet Explorer will recognize media queries as you resize the browser window, allowing you to test your variations on the fly. If you&#8217;re using said modern browser, simply resize this window to see how my design responds to new device sizes.</p>
<h2>Looking Forward</h2>
<p>Responsive web design is an important next step in presentation on the web. Expect the device landscape to broaden and diversify, and expect your job as a designer to increasingly become the curator of a flexible and fluid online experience that is more focused on content and less on pixels or devices. The idea of &#8220;mobile vs. desktop&#8221; is fairly new and very strong, but the mobile distinction will likely become an element of features and convenience, rather than an element of presentation, as it is so largely viewed today.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/responsive-layouts-using-css-media-queries/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Constraint Aids in Design</title>
		<link>http://kyleschaeffer.com/best-practices/constraint-aids-in-design/</link>
		<comments>http://kyleschaeffer.com/best-practices/constraint-aids-in-design/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 03:57:04 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://kyleschaeffer.com/?p=680</guid>
		<description><![CDATA[I am starting to see a pattern. It is approaching the end of the year, and as with many, hindsight is on the mind. Over the course of my blog, I think I&#8217;ve set a course and direction for what &#8230; <a href="http://kyleschaeffer.com/best-practices/constraint-aids-in-design/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am starting to see a pattern.  It is approaching the end of the year, and as with many, hindsight is on the mind.  Over the course of my blog, I think I&#8217;ve set a course and direction for what I write.  The web has definitely changed since <a href="http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/">my first post</a> in September of 2008; so too have we, as designers, developers, and avid fans of the internet.  We have altered our methods, our tools, and our expectations for what a website should be.  In all of this change, I have clung to one idea that holds me steady on this shaky ground:  constraint.<span id="more-680"></span></p>
<p>Constraint is not a buzz word.  You don&#8217;t sell design with promises of constraint.  No, constraint is a discipline in design; it is an essential tool for success in the creative process.  All designers begin the creative process in roughly the same fashion:  you start with a blank area of two-dimensional space, and you apply your creative ideas in whatever way that suits the medium in which you work.  Many designers begin with paper, drawing and sketching their ideas as they emerge.  Others may choose to begin in an electronic format, using wireframes, graphic design applications, and the like.  No matter the medium in which you choose to work, the process is essentially the same.  The problem with this very early stage of creative development is that it lacks constraints of any kind.  You can draw anything you can possibly imagine on a piece of paper.  It can be a concise and well-planned idea, or it can be complete nonsense.  Although the space in which you are now working lacks constraint, the medium in which you eventually implement your idea (the browser window) does not.</p>
<p>As many designers are, I am a detail-oriented person.  Every errant pixel or unpolished element in a design can drive me mad.  When I begin the creative process, it&#8217;s entirely too tempting to explore my ideas completely and thoroughly at the very inception of the thought.  My mind wanders astray as I work out the details of color, functionality, even the HTML, CSS, or the JavaScript that will be needed to implement the idea.  The problem is, these details don&#8217;t matter, at least not yet.  My failure to focus on the <em>Big Picture</em>, the vision of what this should <em>really</em> be inside my head, can lead to the failure of the design on the whole.  When you first begin the design process, you must remove the details from your mind.</p>
<h2>Tools of Constraint</h2>
<p>There are some fantastically simple ways to fight your urge to delve into the details of design at such an early stage of your idea.  Use any or all of these methods to improve the quality of your design process.</p>
<ol>
<li><strong>Constraints of Space<br />
</strong>Although it seems amazingly elementary to consider, constraining the space in which you work can greatly hinder your ability to focus on the needless details in such an early stage of idea development.  On paper, try dividing your space into smaller sections, forcing you to focus on the most important elements of design.  If you are working in an electronic medium, try to avoid using the zoom tool for the same effect.  Develop your ideas in a constrained space, and you&#8217;ll find that you spend less time thinking about the endless details of everything that you create.</li>
<li><strong>Constraints of Medium</strong><br />
Design your idea to the lowest possible standards for the medium(s) in which it will be implemented.  For instance, if you are creating a website design, consider <a href="http://www.lukew.com/ff/entry.asp?1117">designing for mobile devices first</a>.  This forces a sense of simplicity in all that you create, which is something that cluttered and disorganized websites often lack.  Ensure that your design will function on every possible platform in which it will live, and enhance the experience of your idea for users who can support it.</li>
<li><strong>Constraints of Expectation</strong><br />
Understand the expectations of your users, and recognize the established design patterns of the platform in which you work.  Don&#8217;t try to reinvent the wheel unless it makes sense in the bigger context of your project.  Don&#8217;t be afraid to use shared resources to accomplish a common goal, but know when to deviate from the <em>rules</em> in order to avoid a sense of mediocrity.</li>
</ol>
<h2>Gradation of Constraint</h2>
<p>Brandon Schauer has created a fantastic <a href="http://www.adaptivepath.com/ideas/essays/archives/000863.php">multi-page sketchboard template</a>, which can be used to begin the creative process.  These templates are fantastic to work with, as they essentially divide a letter-sized area of paper into six divisions, forcing you to work within the spacial constraints of each individual division.  Furthermore, Brandon has wisely chosen to include a very subtle suggestion of a browser window in the background of each division of the paper.  This is a constant reminder of the constraints of the medium or platform in which you are designing.  Brandon also includes a larger, single-sized sketchboard template that can be used to go into greater detail once the <em>big ideas</em> of your design have been explored and polished.</p>
<p>The wisdom of this larger template cannot be overlooked.  There is a time in every design process where you must move beyond the constraints of the drawing board.  Many designers may move from sketching directly into graphic design, or perhaps into wireframes and prototyping.  It can be difficult to suddenly jump from such a well-defined, constrained medium of design into an area that lacks similar constraint.  You&#8217;ll find that by creating a <em>gradation of constraint</em>, where you constantly &#8220;zoom in&#8221; to focus on an idea a little at a time, you can aid your mind in avoiding the needless details of implementation until they are necessarily significant.</p>
<p>Use the tools of constraint to explore your ideas a little at a time.  Focus on the vision of the design that you have in your head, and elegantly correct your design&#8217;s course over the span of its development to ensure that the <em>idea</em> of the design, and the <em>reality</em> of the design are one and the same.  Avoid detail-diving, however tempting it may be.  Do these things, and you&#8217;ll find, as I have found, that the vision of clarity in your mind can gradually and surely become clarity within the browser window.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/constraint-aids-in-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taking it Down a Notch</title>
		<link>http://kyleschaeffer.com/best-practices/taking-it-down-a-notch/</link>
		<comments>http://kyleschaeffer.com/best-practices/taking-it-down-a-notch/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 22:50:12 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://kyleschaeffer.com/?p=638</guid>
		<description><![CDATA[Bigger, better, and bolder. That&#8217;s the direction of things. The art of the interface is a little more complex than it was yesterday. We have new techniques, new technology (languages and libraries and acronyms, oh my), and even more bandwidth &#8230; <a href="http://kyleschaeffer.com/best-practices/taking-it-down-a-notch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Bigger, better, and bolder. That&#8217;s the direction of things.  The art of the interface is a little more complex than it was yesterday.  We have new techniques, new technology (languages and libraries and acronyms, oh my), and even more bandwidth to back it all up.  What to do with all this power?  The possibilities are nearly limitless.  I say, <em>take it down a notch</em>.<span id="more-638"></span></p>
<h2>Let me explain&#8230;</h2>
<p>Now, don&#8217;t get me wrong.  I&#8217;m not suggesting that we participate in an exercise of mediocrity; quite the opposite, in fact.  I merely suggest that we take a step back and look at interface design on the web as a whole.  There&#8217;s something so beautiful about it, isn&#8217;t there?  Perhaps the beauty lies in the very nature of the web; a rare medium in which art and logic can collide.  As you well know, the fusion of these two seemingly opposing forces can sometimes end in a gruesome battle between form and function.  That simply shouldn&#8217;t be the case.</p>
<p>The form of an interface should support the application&#8217;s underlying function, and vice versa.  The battle that undoubtedly ensues between these two elements is ultimately what damages the design, and any compromise by either party can result only in mediocrity.  As the interface designer, it&#8217;s your job to cool the tempers on both sides of the development fence, and to facilitate a relationship that fosters that holy center ground, which at times can seem quite elusive and difficult to attain.</p>
<h2>A practice of simplicity</h2>
<p>The battle is set.  The warriors are ready to fight.  In the blue corner, Logic eyes its formless opponent with a cold-hearted certainty.  You are the mediator, and the time has come for you to tame your design into something everyone can be happy about.  Logic is your first adversary.  This is the underlying technology and function of your design.  It is simple and unforgiving.  Treat it as such.</p>
<p>In terms of design, this is the underlying <acronym title="HyperText Markup Language">HTML</acronym> and server-side functionality behind the pages.  It needs to be simple, semantic, accessible, and structured in a way that makes sense to the logic of your application.  Ask yourself with each snippet of markup that you type in, &#8220;What does this ultimately do?&#8221;  Think about the data of what you&#8217;re marking up, and not the appearance of it.  We&#8217;ll worry about the form of your design later.</p>
<h3 id="example-logo">A simple example</h3>
<p><img title="Site header and logo concept" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/09/taking-it-down-logo.png" alt="Site header and logo concept" /></p>
<p>How would you implement your site&#8217;s logo?  Before you drop in an <code>&lt;img/&gt;</code> or a <code>&lt;div/&gt;</code>, think about what the logo <em>really</em> is.  What does it (logically) do?  In fact, it&#8217;s a header – it is used to describe or encapsulate the content below it.  Use the <code>&lt;h1/&gt;</code> tag – that&#8217;s what it&#8217;s for.  I don&#8217;t care about your silly logo or designer font.  My name is Logic, and I demand simplicity.  Give me what I want:</p>
<pre>&lt;h1 class="medazio-logo"&gt;Medazio: a completely made up word.&lt;/h1&gt;</pre>
<p>The visual appearance of our site header is not entirely simplistic, but the <acronym title="HyperText Markup Language">HTML</acronym> markup for it certainly is.</p>
<h3 id="example-comment">A little complexity, please</h3>
<p><img title="Site comments concept" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/09/taking-it-down-comment.png" alt="Site comments concept" /></p>
<p>How would you implement a design for this comment?  As soon as you look at this image, it&#8217;s easy to see the layout, the colors, or even the position of the data.  Now, take a step back and remove the appearance of the image from your mind.  We&#8217;re working with the logic of the data, remember?  The position and orientation of the data simply doesn&#8217;t matter right now.  Don&#8217;t create classes like <strong>commentBottom</strong> – you&#8217;ll probably kick yourself later when you decide to switch things around a bit.  Use something more descriptive of the actual data contained in your markup, like <strong>comment-description</strong> or <strong>comment-meta</strong>.  In our case, we&#8217;ll do something very similar:</p>
<pre>&lt;ol class="comments"&gt;
  &lt;li class="comment <strong>hreview vcard item</strong>"&gt;
    &lt;p class="<strong>description</strong>"&gt;Lorem ipsum dolor...&lt;/p&gt;
    &lt;p class="comment-meta <strong>reviewer</strong>"&gt;
      &lt;img class="<strong>photo</strong>" src="/path/to/kyle.png" alt="Kyle" /&gt;
      &lt;a class="<strong>fn url</strong>" href="/profiles/kyle"&gt;Kyle&lt;/a&gt; @
      &lt;span class="<strong>dtreviewed</strong>" title="2010-02-18T21:49:38-07:00"&gt;
        Feb 18, 2010 9:49 pm
      &lt;/span&gt;
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;</pre>
<p>Notice that we&#8217;ve used self-describing class names for most of the data within the comment.  The class names in <strong>bold</strong> are not required, but we&#8217;ve added them in order to adhere to the very useful <a href="http://microformats.org/wiki/hreview">hreview microformat</a>.  This helps define your data beyond what can be done with <acronym title="HyperText Markup Language">HTML</acronym> tags and attributes.  Additionally, we can append classes together to reduce the need to create extraneous style selectors later on.  Logic is now appeased.</p>
<h2>And in the red corner&#8230;</h2>
<p>Meet Art, an element of design not so easily defined as Logic.  Logic suffers without Art, its disobedient and relentlessly unpredictable counterpart.  It&#8217;s not &#8220;art&#8221; by any traditional sense of the word, no, but it is art nonetheless.  It&#8217;s bold and daring and difficult.  Art is what makes an interface attractive.  I dare not attempt to encapsulate the process by which one creates attractive design (it&#8217;s a creative process, after all), but I will dabble in the application of it.</p>
<p>Our tool for artistic application is the style sheet.  We will use <acronym title="Cascading Style Sheet">CSS</acronym> to infuse our structured <acronym title="HyperText Markup Language">HTML</acronym> with our creative ideas.  Using the aforementioned examples, let&#8217;s see how we can bring our flat and unforgiving concept images into interactive life.</p>
<h3>Making the header happen</h3>
<p>Remember the <a href="#example-logo">logo</a>?  Let&#8217;s take our cold-hearted <acronym title="HyperText Markup Language">HTML</acronym> and add some &#8220;fresh,&#8221; <acronym title="Cascading Style Sheet">CSS</acronym>-style.</p>
<pre>.medazio-logo {
   width: 223px;
   height: 31px;
   background: url(medazio-logo.png);
   text-indent: -9999px;
}</pre>
<p>We&#8217;re using image replacement to bump that pesky header text out of the way (make way, fabulous logo coming through).  The human eye is appeased by the appearance of our logo, and likewise the eye of the machine (search crawlers, screen readers, etc.) is equally appeased by the semantic structure of our <acronym title="HyperText Markup Language">HTML</acronym> document.  Even more exciting is the fact that our style sheet actually supports the logic of our design.  We&#8217;re achieving the appearance that our design demands without compromising the integrity of its structure or function.  Much rejoicing is in order.</p>
<h3>Adding style to our comments</h3>
<p>Similarly, let&#8217;s take the same approach with our <a href="#example-comment">comment <acronym title="HyperText Markup Language">HTML</acronym></a>:</p>
<pre>ol.comments {
   margin: 0;
   padding: 0;
}
li.comment {
   list-style: none;
   margin: 0 0 20px 0;
}
li.comment p.description {
   background: #f8f8f8;
   border-bottom: 4px solid #eee;
   margin: 0;
   padding: 20px;
}
li.comment p.comment-meta {
   background: url(chat-arrow.png) no-repeat 37px 0;
   padding: 5px 0 0 0;
}</pre>
<p>With a few simple lines of <acronym title="Cascading Style Sheet">CSS</acronym>, our sensationally semantic <acronym title="HyperText Markup Language">HTML</acronym> comment becomes exactly what we always dreamed it would be.  The best part?  Both the technology and the design of our application are meeting in the middle.  Better that than we, the designers, having to force the union in a rather rude and unsightly manner.</p>
<h2>You, the negotiator</h2>
<p>The cruel truth of the matter is that not every design element will be so simple or quite as easy to negotiate as this.  These are simple examples of a much bigger concept that takes time and practice to master.  You, as a designer, are the negotiator of both logic and art.  You are forced into a difficult role in which you must understand both the creative aspirations and the technical limitations of your project.  Most design professionals fall on either one side or the other of the art vs. technology skill-set.  Forcing yourself into an impartial role between the two is a difficult, yet imperative step in your journey to design bliss.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/taking-it-down-a-notch/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Designing Body Type</title>
		<link>http://kyleschaeffer.com/best-practices/designing-body-type/</link>
		<comments>http://kyleschaeffer.com/best-practices/designing-body-type/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 21:26:55 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=612</guid>
		<description><![CDATA[Header text gets all the love, doesn&#8217;t it? From Photoshop to the browser window, the focus seems to be on design elements like logos, navigation, and of course, header type. It&#8217;s great fun to use tools like Typekit to make &#8230; <a href="http://kyleschaeffer.com/best-practices/designing-body-type/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Header text gets all the love, doesn&#8217;t it? From Photoshop to the browser window, the focus seems to be on design elements like logos, navigation, and of course, header type. It&#8217;s great fun to use tools like <a href="http://typekit.com">Typekit</a> to make your header text something a little less than ordinary. It defines your site, gives you a unique look and feel, and gives readers that oh-so-scannable sensation they know and love. When you really think about it, however, readers aren&#8217;t there for the header text. The headers serve as an essential tool to quickly find what you&#8217;re looking for, but the real prize here is the body text, isn&#8217;t it? This is where your information is, this is where you write and communicate to readers, and this is an area of design that cannot be neglected. Sadly, it often is.<span id="more-612"></span></p>
<p>Body text is often an after-thought in design. We have all been guilty of this at some point in our careers. When you implement your CSS, you might simply throw a <code>body { font-family: blah, blah blah; }</code> into the CSS, and after that you move on. You&#8217;ve probably figured out the whole base font size <em>thing</em> too, which can help, but there&#8217;s so much more you can do. Let&#8217;s look at a number of things to help your body type become something a bit more visually appealing and readable.</p>
<h2>Text Color</h2>
<p>Hopefully you&#8217;ve already figured this one out, but I dare not exclude it for the sake of accuracy. Probably the single most important thing you can do to your body text is change both the color of the text as well as the background color of the area shown behind the text. Here&#8217;s a few pointers:</p>
<ul>
<li>Readers generally prefer dark text on a light background. There are a few impressive exceptions to this rule, but for the most part, it&#8217;s best to stick with the old &#8220;dark on light&#8221; tried-and-true formula.</li>
<li>While contrast is important, don&#8217;t take it too far. Black text (<code>#000000</code>) on a white background (<code>#ffffff</code>) is perhaps a bit too much contrast. Opting for a slightly lighter shade of text can make it easier on your readers&#8217; eyes. If I&#8217;m working on a white background, I generally choose a font color that is at or in the general vicinity of <code>#666666</code> (don&#8217;t be afraid to add a subtle hue of color too, but keep it dark).</li>
<li>Add some variety by slightly changing the color of elements in your body text like darker <code>&lt;strong&gt;</code> text or lighter <code>&lt;li&gt;</code> items. You don&#8217;t have to stick with a single color for all text in the entire design.</li>
<li>Keep the focus on your article or body text. If you have a sidebar or widgets that appear to the side of your actual body text, try lightening their text color (or reducing contrast with a different background color) to make sure that users focus on the real content of the page.</li>
</ul>
<h2>Font Size</h2>
<p>Another obvious and quite important element of your body text style is the font size. There are <a href="http://www.kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/">a number of different ways</a> to establish a default font size for your text. While the method of setting your font sizes is a matter of debate, there are a few best practices you should be aware of.</p>
<ul>
<li>It&#8217;s easiest on your users to set the <code>body</code> font size at <code>62.5%</code>, and use <code>ems</code> to size your fonts from there (<code>.wrapper { font-size: 1.3em; }</code> would set the font size to 13 pixels in height).</li>
<li>Choose a base font size of at least 12 pixels in height. There are exceptions to every rule, but you&#8217;ll find that users are frustrated by tiny font sizes, and are apt to leave a site even before using the handy browser zoom feature.</li>
<li>Deviate from the base font size only where it makes sense in the overall theme of the design. Consistency is key. Set default CSS styles for things like the <code>&lt;small&gt;</code> tag and headers.</li>
</ul>
<h2>Font Family</h2>
<p>Fonts are a bit tricky in web design, basically because you&#8217;re forced to choose one of about ten fonts that are used on every other website in the world. <a href="http://typekit.com">Typekit</a> is great for header text, but you&#8217;re better off using regular web-friendly fonts for your body text. Here&#8217;s a few pointers:</p>
<ul>
<li><strong>Serif vs. Sans-Serif:</strong> First choose the font style you&#8217;ll be working with. Choose something that fits with your design&#8217;s overall theme or concept. Serif fonts like Times and Georgia give your site a vintage and book-like feel. They are flowing, artistic, and regal in theme. Sans-serif fonts like Arial or Helvetica can be used to portray a clean, professional, and strong atmosphere in your design.</li>
<li>Choose a <a href="http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html" target="_blank">common font</a> for your body text that is available on both Mac and PC platforms. There are some great fonts on the Mac, but you&#8217;ll want to design your site so that it looks good no matter what device is accessing it.</li>
<li>It&#8217;s completely acceptable to add a &#8220;nice to have&#8221; font into your design, such as Helvetica or Myriad Pro. These fonts can gracefully degrade to Arial without jarring the layout of your page too much.</li>
<li>Georgia and Times are not the only serif fonts available! Try experimenting with fonts like Book Antiqua or Platino Linotype, which have a more book-like and artistic feel.</li>
<li>Courier New is a great fixed-width font best used for displaying CSS, HTML, or some kind of code to your readers.</li>
<li>Don&#8217;t forget other elements in your design! By default, text boxes, buttons, and select menus will not use the body font family and/or size, so make sure to set a consistent font on all elements in your design.</li>
<li>Don&#8217;t use Comic Sans.</li>
</ul>
<h2>Margin, Spacing, and Line Height</h2>
<p>This is probably the most overlooked element of body type design. After you&#8217;ve developed the <strong>character</strong> design of your body type, take a step back and examine the <strong>paragraph</strong> style.</p>
<ul>
<li>Unless you specify otherwise, the lines of text in your design are drawn very close together, and it can be difficult for readers to follow as they read down the page. Add a bit of CSS such as <code>p { line-height: 1.5em; }</code> to make this text easier on the eyes.</li>
<li>Likewise, paragraphs of text have default margins applied to them that may make them appear too close together or too far away from the headers that appear above them. Try adding some CSS such as <code>p { margin: 0 0 1.5em 0; }</code> to standardize the spacing around paragraphs.</li>
<li>Paragraph text is not the only thing you&#8217;ll see in a page. Don&#8217;t forget to style other HTML elements like lists (<code>&lt;ul&gt;</code> or <code>&lt;ol&gt;</code>), the horizontal rule (<code>&lt;hr /&gt;</code>), and block quotes or call-out boxes.</li>
</ul>
<h2>Be Creative</h2>
<p>Following these rules isn&#8217;t a guaranteed way to make your body type look amazing, and breaking any or all of these rules certainly doesn&#8217;t guarantee that your design will be ugly and fail. In the end, it&#8217;s all about being creative and paying attention to all the tiny details that go into making a website look amazing. The difference between a good design and a bad one can be very subtle. Create something fun, stick to a theme, and take note of every visual detail that appears on the page, body type included.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/designing-body-type/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Input Prompt Text:  A Better Way</title>
		<link>http://kyleschaeffer.com/best-practices/input-prompt-text/</link>
		<comments>http://kyleschaeffer.com/best-practices/input-prompt-text/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 02:43:37 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=565</guid>
		<description><![CDATA[It&#8217;s a very cool feature to have a form field that has prompt text such as Enter search keywords&#8230; right inside the input box, itself. It looks good, it makes sense to users, and it can save a lot of &#8230; <a href="http://kyleschaeffer.com/best-practices/input-prompt-text/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a very cool feature to have a form field that has prompt text such as <em>Enter search keywords&#8230;</em> right inside the input box, itself. It looks good, it makes sense to users, and it can save a lot of real estate in your design by negating the need for field labels. The problem, however, is that there are about one hundred ways to implement prompt text, and ninety-nine of them are wrong. Let&#8217;s look at this thing from all angles and come up with a fantastically simple and reliable way to make this work.<span id="more-565"></span></p>
<h2>What is input prompt text?</h2>
<p>You&#8217;re probably familiar with the concept, even if you don&#8217;t know what I&#8217;m talking about. Here&#8217;s an example:</p>
<p>
<input type="text" style="color: #999; font-style: italic; width: 250px;" value="Enter search keywords..." />
<input type="button" value="Search" /></p>
<p>The <em>prompt text</em> appears inside the form field as soon as the page loads, so users immediately know what it&#8217;s for. Simple, right?</p>
<h2>Why it Doesn&#8217;t Work</h2>
<p>There are a number of problems you&#8217;ll encounter while implementing prompt text into your forms. Watch out for these caveats when you&#8217;re developing your own solution.</p>
<ol>
<li><strong>Input validation</strong> &mdash; if someone submits the form without first removing the prompt text, your prompt text is submitted in lieu of real data. Fixing this is a pain. Avoiding this entirely is recommended.</li>
<li><strong>Prompt style</strong> &mdash; it&#8217;s best to style the prompt text so that it doesn&#8217;t look like real form data. Creativity is a virtue, but generally web users will expect light (gray) text and italics. This can be problematic because you&#8217;ll have to swap the input style back and forth using JavaScript.</li>
<li><strong>Losing focus</strong> &mdash; when users focus on a form field, don&#8217;t type anything, and then click somewhere else, you should always add the prompt text <em>back into the input box</em>.  Otherwise, users could miss the intent of the form field entirely.  Again, you&#8217;ll have to do this with JavaScript, which can be a little tricky.</li>
<li><strong>Progressive enhancement</strong> &mdash; always make sure that users without JavaScript can still understand and interact with your form fields. This is progressive enhancement at its finest.</li>
</ol>
<h2>The Solution</h2>
<p>Almost everything related to the problems listed above originates from one basic fact: you&#8217;re trying to create both a <strong>field</strong> and a <strong>label</strong> using a single HTML element. When you take a step back and think about that, it really doesn&#8217;t make much sense, does it? The solution lies in separating the form field from the label entirely. We&#8217;ll use a little bit of jQuery to create an elegant solution that dynamically creates these labels and places them over our form fields. Because we&#8217;re creating two separate elements, we can use CSS to style them independently. Perfect!</p>
<p><strong>The jQuery:</strong></p>
<pre>$(document).ready(function(){
  $('input[type=text][title],input[type=password][title],textarea[title]').each(function(i){
    $(this).addClass('input-prompt-' + i);
    var promptSpan = $('&lt;span class=&quot;input-prompt&quot;/&gt;');
    $(promptSpan).attr('id', 'input-prompt-' + i);
    $(promptSpan).append($(this).attr('title'));
    $(promptSpan).click(function(){
      $(this).hide();
      $('.' + $(this).attr('id')).focus();
    });
    if($(this).val() != ''){
      $(promptSpan).hide();
    }
    $(this).before(promptSpan);
    $(this).focus(function(){
      $('#input-prompt-' + i).hide();
    });
    $(this).blur(function(){
      if($(this).val() == ''){
        $('#input-prompt-' + i).show();
      }
    });
  });
});</pre>
<p><strong>The CSS:</strong></p>
<pre>.input-prompt {
  position: absolute;
  font-style: italic;
  color: #aaa;
  margin: 0.2em 0 0 0.5em;
}</pre>
<p><strong>The HTML:</strong></p>
<pre>&lt;input type=&quot;text&quot; <strong>title=&quot;Enter search keywords...&quot;</strong> /&gt;</pre>
<p>Basically, this script finds any <code>&lt;input&gt;</code> tags that have a <code>title</code> attribute (i.e. <code>&lt;input title=&quot;Enter search keywords...&quot; /&gt;</code>). For each of these form fields, it takes the <code>title</code> and creates a little <code>&lt;span&gt;</code> tag next to it. The CSS positions the <code>&lt;span&gt;</code> tag so that it appears <em>on top</em> of the form field. The rest is just a little bit of scripting that makes sure to hide and show the labels based on what the user is doing with the input box.</p>
<h2>The Result</h2>
<p>Here is a demo of the code shown above:</p>
<p><script type="text/javascript">jQuery(document).ready(function(){
  jQuery('input#demo').each(function(i){
    jQuery(this).addClass('input-prompt-' + i);
    var promptSpan = jQuery('<span class="input-prompt"/>');
    jQuery(promptSpan).attr('id', 'input-prompt-' + i);
    jQuery(promptSpan).append(jQuery(this).attr('title'));
    jQuery(promptSpan).click(function(){
      jQuery(this).hide();
      jQuery('.' + jQuery(this).attr('id')).focus();
    });
    if(jQuery(this).val() != ''){
      jQuery(promptSpan).hide();
    }
    jQuery(this).before(promptSpan);
    jQuery(this).focus(function(){
      jQuery('#input-prompt-' + i).hide();
    });
    jQuery(this).blur(function(){
      if(jQuery(this).val() == ''){
        jQuery('#input-prompt-' + i).show();
      }
    });
  });
});</script><br />
<style type="text/css">.input-prompt { position: absolute; font-style: italic; color: #aaa; margin: 0.7em 0 0 1em; }</style>
<input id="demo" type="text" title="Enter search keywords..." size="50" style="padding: 0.5em;" />
<p>Users without JavaScript enabled will see the normal title tool tips when they hover their mouse cursor over the form field.  Please note that you&#8217;ll probably have to adjust the <code>margin</code> a bit in the CSS to make sure the labels fit the size of your input boxes. For more information on jQuery and all the great things it can do, visit <a href="http://jquery.com/">jQuery.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/input-prompt-text/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>The Perfect jQuery AJAX Request</title>
		<link>http://kyleschaeffer.com/best-practices/the-perfect-jquery-ajax-request/</link>
		<comments>http://kyleschaeffer.com/best-practices/the-perfect-jquery-ajax-request/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 14:10:41 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=538</guid>
		<description><![CDATA[If you&#8217;re into client-scripting, then jQuery AJAX is probably your thing (if it&#8217;s not, perhaps it should be!). jQuery has some fantastic support for AJAX, and implementing it into your web application is so easy it&#8217;s stupid. The AJAX functionality &#8230; <a href="http://kyleschaeffer.com/best-practices/the-perfect-jquery-ajax-request/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re into client-scripting, then <a href="http://api.jquery.com/category/ajax/">jQuery AJAX</a> is probably <em>your thing</em> (if it&#8217;s not, perhaps it should be!). jQuery has some fantastic support for AJAX, and implementing it into your web application is so easy it&#8217;s stupid.  The AJAX functionality in the AJAX library is so flexible, sometimes it&#8217;s easy to get lost when you&#8217;re trying to do something very simple.  I&#8217;ve come up with a very basic jQuery AJAX template that I use for just about everything I do, and I thought it might be useful to share.<span id="more-538"></span></p>
<h2>The Old Way</h2>
<p>Did you work with AJAX <em>way back when</em>, when it first came out?  You might remember that an AJAX request looked a little like this.</p>
<pre>var xmlhttp;
xmlhttp = GetXmlHttpObject();
if(xmlhttp == null){
  alert(&quot;Boo! Your browser doesn't support AJAX!&quot;);
  return;
}
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.open(&quot;GET&quot;, &quot;http://www.google.com&quot;, true);
xmlhttp.send(null);

function stateChanged(){
  if(xmlhttp.readyState == 4){
    // do something with the response text
    alert(xmlhttp.responseText);
  }
}
function GetXmlHttpObject(){
  // IE7+, Firefox, Chrome, Opera, Safari
  if(window.XMLHttpRequest){
    return new XMLHttpRequest();
  }

  //IE5, IE6
  if(window.ActiveXObject){
    return new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
  }
  return null;
}</pre>
<p>In a nutshell, that sucks!  All of that code to simply request the contents of Google&#8217;s home page, and then alert in the window.  That&#8217;s not very helpful at all.  Alternatively, here is the exact same function written in jQuery:</p>
<pre>$.ajax({
  url: 'http://www.google.com',
  success:function(data){
    alert(data);
  }
});</pre>
<p>As you can plainly see, the jQuery AJAX method is much easier to wrap your mind around.  You give it a URL to request, and then you give it a set of instructions if a successful request is made.  Easy!</p>
<p>I understand that it&#8217;s not very useful to request the contents of a web page and alert it to your users (in fact, that&#8217;s probably pretty annoying), so let&#8217;s take it up a notch.  jQuery AJAX features a ridiculous amount of customization options, events, and the like to give you a huge amount of flexibility, and it can be hard to find a good place to start.  I&#8217;ll help you find the starting line, and you can take it from there.</p>
<h2>The Perfect AJAX Request</h2>
<p>I&#8217;m fairly positive that by using the term <em>perfect</em>, I&#8217;m going to get a good amount of nay-sayers telling me why jQuery AJAX sucks, but that&#8217;s not what I&#8217;m getting at.  This jQuery function is <em>perfect</em> in the sense that it handles 99% of all the AJAX requests you&#8217;ll ever need to make, it includes a success and failure function to ensure that users get the proper feedback they need, and you&#8217;ll get a spinning loading image while the request is being processed to boot.  Throw on top of that the fact that it&#8217;s extremely easy to use, and I&#8217;d say you have something that&#8217;s pretty damned close to perfect, at least in my book.  Here is the template:</p>
<pre>$.ajax({
  type: 'POST',
  url: '<strong>http://kyleschaeffer.com/feed/</strong>',
  data: { <strong>postVar1: 'theValue1', postVar2: 'theValue2'</strong> },
  beforeSend:function(){
    // this is where we append a loading image
    $('#ajax-panel').html('&lt;div class=&quot;loading&quot;&gt;&lt;img src=&quot;<strong>/images/loading.gif</strong>&quot; alt=&quot;Loading...&quot; /&gt;&lt;/div&gt;');
  },
  success:function(data){
    // successful request; do something with the data
    $('#ajax-panel').empty();
    $(data).find('item').each(function(i){
      $('#ajax-panel').append('<strong>&lt;h4&gt;' + $(this).find('title').text() + '&lt;/h4&gt;&lt;p&gt;' + $(this).find('link').text() + '&lt;/p&gt;</strong>');
    });
  },
  error:function(){
    // failed request; give feedback to user
    $('#ajax-panel').html('&lt;p class=&quot;error&quot;&gt;&lt;strong&gt;Oops!&lt;/strong&gt; Try that again in a few moments.&lt;/p&gt;');
  }
});</pre>
<p>In this case, I&#8217;m loading my site&#8217;s RSS feed into a <code>&lt;div/&gt;</code> with an ID of <code>ajax-panel</code>.  What does it look like exactly, you ask?  Let&#8217;s try it out.</p>
<style type="text/css">#ajax-panel { background: #f5f5f5; border: 1px #ddd solid; padding: 20px; margin: 0 0 5px 0; } .loading { padding: 50px 0; text-align: center; }</style>
<div id="ajax-panel"></div>
<div class="ajax-panel-actions">
<input id="load-feed" type="button" value="Load the RSS feed now!" />
<input id="load-feed-fail" type="button" value="Try a FAILED AJAX Request" /></div>
<p><script type="text/javascript" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/04/the-perfect-ajax.js"></script></p>
<h3>Data Types</h3>
<p>We&#8217;re loading an RSS feed in this example, so the AJAX function is designed to interpret XML data. jQuery AJAX also understands a number of other data formats, such as HTML, plain text, and even JSON. Find out more about data types at the <a href="http://api.jquery.com/jQuery.ajax/">jQuery AJAX documentation page</a>.</p>
<h3>Loading Image</h3>
<p>Did you notice the spinning loading image? In the <code>beforeSend</code> function, we&#8217;re appending a loading image to our AJAX panel, and we&#8217;re then taking it out when a request has completed.  If you&#8217;re not already aware, be sure to check out the very handy website, <a href="http://www.ajaxload.info/">Ajaxload</a>.  This site allows you to quickly create <em>spinner</em> images of any size and color. They have an impressive array of bars, circles, flowers, and the like, so all your design needs should be satiated by the array of options they provide.  It&#8217;s always a good idea to include a loading image when working with AJAX requests &mdash; depending on the client&#8217;s connection speed and a number of other variables, the time it takes to complete a request can vary.  Don&#8217;t assume it will be lickity-split and lightning fast every time.  Give your users some feedback to let them know that you&#8217;re working on it.</p>
<h3>POST Data</h3>
<p>You may have noticed that we&#8217;re using <code>POST</code> as the request type.  <code>POST</code> requests works just like <code>GET</code> requests, except you get the added flexibility to also send data and other variables along with your request.  We sent some dummy data that isn&#8217;t used by the RSS feed (<code>data: { postVar1: 'theValue1', postVar2: 'theValue2' }</code>), so feel free to change or omit this line of code in order to customize your AJAX request function. As an example, you could send a variable like <code>userId: '45'</code> to a custom PHP script that in return sends you information about a particular user. The possibilities are endless!</p>
<h2>Remember the Search</h2>
<p>Take what you&#8217;ve learned and venture into the wide world of web development armed with the knowledge you now possess.  Destroy post-backs wherever they may live, and always remember that Google hates AJAX and won&#8217;t interpret anything on your page that&#8217;s loaded via script!  Good luck, and happy styling.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/the-perfect-jquery-ajax-request/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>9 Amazing Things You Can Do in Firefox 3.6</title>
		<link>http://kyleschaeffer.com/best-practices/9-amazing-things-firefox-3-6/</link>
		<comments>http://kyleschaeffer.com/best-practices/9-amazing-things-firefox-3-6/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 16:43:32 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Browsers]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=480</guid>
		<description><![CDATA[The latest update to Mozilla&#8217;s wonderful web browser, Firefox 3.6, includes support for some fantastic CSS version 3 recommendations that you may or may not be aware of. Obviously, these tricks won&#8217;t work in Internet Explorer just yet, but look &#8230; <a href="http://kyleschaeffer.com/best-practices/9-amazing-things-firefox-3-6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The latest update to Mozilla&#8217;s wonderful web browser, Firefox 3.6, includes support for some fantastic <a href="http://www.w3.org/Style/CSS/current-work#CSS3">CSS version 3 recommendations</a> that you may or may not be aware of. Obviously, these tricks won&#8217;t work in Internet Explorer just yet, but look for widespread support coming in the (hopefully) very near future.<span id="more-480"></span></p>
<p>Most of the new features revolve around background image and color management. This has been a definite pain point for designers in the past, as we&#8217;ve had to create extraneous <code>&lt;div/&gt;</code> tags and other silly markup hacks to implement our favorite visual elements. Fear not, for all browsers will soon support these great features! If you&#8217;ve already installed Firefox 3.6, you should plainly see all the great features in my examples below. If you haven&#8217;t installed the latest update, head on over to <a href="http://www.mozilla.com/firefox/">Mozilla&#8217;s website</a> now to download the latest version.</p>
<style type="text/css">
.box {
	margin: 0 0 20px 0;
	padding: 20px;
	border: 1px #ddd solid;
	-webkit-border-radius: 15px;
	-moz-border-radius: 15px;
	-o-border-radius: 15px;
	border-radius: 15px;
	text-align: justify;
}
.shiny-box {
	background: -moz-linear-gradient(top, #fff, #e9e9e9);
}
.slide {
	background: -moz-linear-gradient(top -45deg, violet, blue);
	color: #fff;
}
.rainbow {
	background: -moz-linear-gradient(left 20deg, violet, red, orange, yellow, green, teal, blue, purple);
	color: white;
}
.alpha {
	background: -moz-linear-gradient(left, rgba(255,255,255,1), rgba(255,255,255,0)), #4aceff url(http://thepeev.com/wp-content/themes/thepeev/images/plant.png) bottom no-repeat;
}
.radial {
	background: -moz-radial-gradient(top left, white 20%, orange);
}
.slasher {
	background: -moz-repeating-linear-gradient(left -45deg, #fff, #f5f5f5 1px, #fff 5px, #fff 1px);
}
.burst {
	background: -moz-repeating-radial-gradient(-5px -5px, circle, #bfeeff, #bfeeff 15px, #fff 15px, #fff 30px, #bfeeff 30px, #bfeeff 40px);
	border: 5px #bfeeff solid;
}
.layers {
	background: url(http://demos.hacks.mozilla.org/openweb/resources/images/logos/firefox-48.png), -moz-linear-gradient(left, rgba(255, 255, 255, 0),  rgba(255, 255, 255, 0.8)), url(http://demos.hacks.mozilla.org/openweb/resources/images/patterns/flowers-pattern.jpg);
	background-repeat: no-repeat, no-repeat, repeat;
	background-position: bottom right, left, right;
	color: #fff;
}
.layers strong {
	color: #fff;
}
.sizer {
	background: #f5f5f5 url(http://demos.hacks.mozilla.org/openweb/resources/images/logos/firefox-48.png) bottom right no-repeat;
	-moz-background-size: 120px;
	-webkit-background-size: 120px;
	-o-background-size: 120px;
}
</style>
<h2>The Linear Gradient</h2>
<p>You can now add linear gradients to your HTML elements with a handy CSS attribute called <code>-moz-linear-gradient</code>. Here are a few examples to get you started.</p>
<h3>A simple example:</h3>
<p class="box shiny-box"><strong>Are you using <a href="http://www.mozilla.com/firefox/">Firefox 3.6</a>? Check out my linear gradient background.</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tempor odio ac elit faucibus vel rhoncus purus hendrerit. Pellentesque imperdiet fermentum lacinia.</p>
<h3>The CSS:</h3>
<pre>.shiny-box {
	background: -moz-linear-gradient(top, #fff, #e9e9e9);
}</pre>
<h3>Drawing gradients at an angle:</h3>
<p class="box slide"><strong>Gradient backgrounds can be drawn at an angle.</strong> Quisque mollis, dui quis hendrerit accumsan, dui lorem congue nibh, et scelerisque neque tortor ac magna. Quisque faucibus lectus tellus. Cras sodales, nulla in suscipit ultricies, mi neque pulvinar augue, a congue lacus tellus eu lorem. Donec varius posuere ligula, adipiscing adipiscing nibh eleifend eu. Nulla sagittis porttitor placerat. Praesent non pretium nisl. Curabitur tempor ante sed orci commodo placerat. Curabitur faucibus ornare augue. Duis adipiscing libero sed ante venenatis posuere. Etiam sodales felis ac est ultricies volutpat. Pellentesque varius iaculis dui, in interdum turpis porta ac. Ut rutrum consequat lectus sit amet euismod. Proin suscipit metus vitae magna condimentum eget blandit ante blandit. Duis lorem magna, luctus sed rutrum non, dictum a erat. In egestas libero a nisl faucibus lobortis. Duis aliquam erat vitae ipsum placerat quis dignissim elit pretium. Sed dictum interdum feugiat. Praesent feugiat libero a enim vulputate ut viverra tortor ornare. Donec vel diam mi. Morbi porttitor porttitor mattis.</p>
<h3>The CSS:</h3>
<pre>.slide {
	background: -moz-linear-gradient(top -45deg, violet, blue);
	color: #fff;
}</pre>
<h3>Stringing colors together:</h3>
<p class="box rainbow"><strong>Specify multiple colors in your gradients.</strong> In fermentum ipsum eget quam pharetra sagittis. Phasellus mollis, nulla nec sagittis pharetra, magna tortor commodo felis, eget dictum sem ipsum gravida ligula. Aliquam pharetra libero quis ligula sollicitudin condimentum. Sed sed diam nulla. Fusce malesuada gravida felis, id porttitor lacus porttitor sed. Maecenas mollis feugiat ultrices. In ac viverra ligula. Maecenas suscipit tempor nibh ac mattis. Morbi ac metus velit. Morbi enim purus, adipiscing at consectetur eget, blandit id nibh.</p>
<h3>The CSS:</h3>
<pre>.rainbow {
	background: -moz-linear-gradient(left 20deg, violet, red, orange, yellow, green, teal, blue, purple);
	color: white;
}</pre>
<h2>Alpha Gradients</h2>
<p>Alpha gradients allow you to specify an RGBA transparency for background images and colors. This allows you to &#8220;fade&#8221; your background on a gradient, so it gets slightly more opaque as you near the edge of your element. It works a lot like the linear gradients shown above.</p>
<h3>Let&#8217;s try it out:</h3>
<p class="box alpha"><strong>Apply alpha gradients to background colors and images.</strong> Mauris id mauris diam, vel hendrerit tortor. Pellentesque leo erat, ullamcorper et consectetur eget, elementum id ipsum. Vestibulum et diam mi, quis commodo velit. Maecenas bibendum purus id sapien sodales ut dapibus est consectetur. Donec vel elementum quam. Suspendisse quis risus nulla. Cras imperdiet, est sit amet rhoncus tincidunt, elit turpis consectetur enim, sit amet gravida erat magna id urna. Cras feugiat, orci nec hendrerit pulvinar, tortor mi dapibus neque, in varius massa velit vitae mi. Fusce dignissim malesuada felis in tincidunt. Donec lacus magna, blandit quis ullamcorper consectetur, interdum in nisl. Curabitur luctus lorem in leo aliquam vestibulum. Ut tempus ornare augue non aliquet. Sed id elit eget sem condimentum tempus et non libero. Proin at nisi quis dolor dignissim varius. Nam fermentum mauris eget justo laoreet vitae tristique quam varius. Praesent sodales sem sed dolor aliquet sagittis. Vestibulum fringilla ultricies nunc. In lacus nisl, mollis blandit aliquam ut, tristique in libero. Suspendisse lacinia aliquet aliquet.</p>
<pre>.alpha {
	background: -moz-linear-gradient(left, rgba(255,255,255,1),
	rgba(255,255,255,0)),
	#4aceff url(http://thepeev.com/wp-content/themes/thepeev/images/plant.png) bottom no-repeat;
}</pre>
<h2>Radial Gradients</h2>
<p>Radial gradients allow for some really cool effects like gradient &#8220;shine&#8221; and other neat things you&#8217;d otherwise have to create in Photoshop.</p>
<h3>The example:</h3>
<p class="box radial"><strong>You can even draw radial gradients. See how I shine!</strong> Donec malesuada, augue in pulvinar tincidunt, tellus lectus iaculis mi, vel facilisis ante mauris et sem. Nunc pretium orci in lacus sollicitudin rhoncus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sollicitudin risus eu libero vestibulum vel mattis diam sagittis. Duis vel dui non erat eleifend dignissim vitae vitae dui. Curabitur dictum imperdiet diam euismod viverra.</p>
<h3>The CSS:</h3>
<pre>.radial {
	background: -moz-radial-gradient(top left, white 20%, orange);
}</pre>
<h2>Repeating Gradients</h2>
<p>As if this wasn&#8217;t enough, you&#8217;ll also have support for repeating gradients, which allows you to do some really cool stuff.</p>
<h3>Check it out:</h3>
<p class="box slasher"><strong>Repeating gradients make it easy to add slash-boxes.</strong> Vestibulum at fringilla dolor. Pellentesque id consectetur enim. Suspendisse vel nibh magna, et imperdiet mi. Aliquam erat volutpat. Maecenas dui quam, volutpat vitae cursus et, suscipit sit amet lorem. Duis congue, nisi eu aliquet ultricies, ipsum ligula rutrum libero, quis rhoncus nisi mauris lacinia nunc. Nam iaculis, nibh et faucibus tempor, massa magna eleifend urna, sit amet pulvinar arcu velit et lacus.</p>
<h3>The CSS:</h3>
<pre>.slasher {
	background: -moz-repeating-linear-gradient(left -45deg, #fff, #f5f5f5 1px, #fff 5px, #fff 1px);
}</pre>
<h3>Use it with radial gradients:</h3>
<p class="box burst"><strong>Repeating radial gradients make it easy to add special effects to your design.</strong> Aliquam tempor tempor nunc, ut dapibus nisl vehicula et. Nullam felis metus, consectetur eu pretium eu, iaculis eu tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut quis ligula orci, id molestie orci.</p>
<h3>The CSS:</h3>
<pre>.burst {
	background: -moz-repeating-radial-gradient(-5px -5px, circle, #bfeeff, #bfeeff 15px, #fff 15px, #fff 30px, #bfeeff 30px, #bfeeff 40px);
	border: 5px #bfeeff solid;
}</pre>
<h2>Background Images</h2>
<p>This is one that I&#8217;m really excited about. You can apply multiple background images to a single layer. Here&#8217;s how it works:</p>
<h3>Multiple background layers:</h3>
<p class="box layers"><strong>You can layer multiple background images on a single element. This example was taken direclty from Mozilla&#8217;s demonstration page.</strong> Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque imperdiet elit dignissim libero sollicitudin tempus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis mattis, leo at rhoncus varius, leo eros tempus ligula, eget blandit mi tortor vitae ante. Nulla varius aliquet massa ac varius. Vestibulum a ipsum vitae ante lobortis facilisis vitae eu risus.</p>
<h3>The CSS:</h3>
<pre>.layers {
	background: url(http://demos.hacks.mozilla.org/openweb/resources/images/logos/firefox-48.png),
	-moz-linear-gradient(left, rgba(255, 255, 255, 0),  rgba(255, 255, 255, 0.8)),
	url(http://demos.hacks.mozilla.org/openweb/resources/images/patterns/flowers-pattern.jpg);
	background-repeat: no-repeat, no-repeat, repeat;
	background-position: bottom right, left, right;
	color: #fff;
}</pre>
<h3>You can also resize background images!</h3>
<p class="box sizer"><strong>You can scale a background image to any size. It&#8217;s so ugly!</strong> Morbi sapien urna, convallis quis accumsan mattis, congue non ante. Phasellus bibendum nibh id orci consequat hendrerit rhoncus in leo. Ut a mauris eu nisl accumsan pulvinar sit amet at leo. Aenean sit amet enim sit amet tellus pellentesque tempus. Vivamus lobortis dui sed arcu venenatis vel vehicula felis vestibulum. Fusce vel ipsum eu nulla fermentum gravida. Suspendisse tincidunt euismod consectetur.</p>
<h3>The CSS:</h3>
<pre>.sizer {
	background: #f5f5f5 url(http://demos.hacks.mozilla.org/openweb/resources/images/logos/firefox-48.png) bottom right no-repeat;
	-moz-background-size: 120px;
	-webkit-background-size: 120px;
	-o-background-size: 120px;
}</pre>
<h2>Other Additions</h2>
<p>Mozilla has included some other great new features, such as the highly anticipated CSS attribute <code>@font-face</code>, which allows you to embed WOFF downloadable fonts into your web design. Type is finally coming to the web! For details on this and the many other great new features in Firefox 3.6, visit Mozilla&#8217;s <a href="https://developer.mozilla.org/En/Firefox_3.6_for_developers">update details for developers</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/9-amazing-things-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Buttons and Accessibility</title>
		<link>http://kyleschaeffer.com/best-practices/image-buttons-and-accessibility/</link>
		<comments>http://kyleschaeffer.com/best-practices/image-buttons-and-accessibility/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:29:32 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=358</guid>
		<description><![CDATA[Image buttons are a fairly common occurrence in web media. As with everything else in web design, you have a dizzying arsenal of methods from which you can choose to create this type of design element, and choosing the right &#8230; <a href="http://kyleschaeffer.com/best-practices/image-buttons-and-accessibility/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Image buttons are a fairly common occurrence in web media. As with everything else in web design, you have a dizzying arsenal of methods from which you can choose to create this type of design element, and choosing the right method can greatly aid in your design&#8217;s accessibility, performance, and SEO-friendliness.<span id="more-358"></span></p>
<h2>Concerning Accessibility</h2>
<p>Accessibility is chiefly important for a web designer (or at least, it should be). When you create your HTML, keep things as simple as possible. Assume that every single user who visits your site will (1) not have CSS support, (2) will disable all images on your page, and (3) will not have JavaScript enabled. If you design your HTML in this fashion, you&#8217;ll find that creating accessible content is much easier to do. Once you have an accessible document that works on all systems, you can use the fantastic features of CSS and client-side scripting to really bring your site to life. These &#8220;nice to have&#8221; features (style, scripting, etc.) are not essential to the structure of your document or the content that&#8217;s contained within. When it comes down to it, users are after your content, so that&#8217;s priority number one.</p>
<h2>A Simple Example</h2>
<p>With that in mind, let&#8217;s say we wanted to create an image that links to another page (this is so very simple, but it serves as a great example of this technique). Because we&#8217;re assuming that users have disabled all images, we certainly don&#8217;t want to use the <code>&lt;img/&gt;</code> tag for our link, because those users without image support simply won&#8217;t see it. For that reason, our link will look like any other link on the site.</p>
<pre>&lt;a class="learnGuitar" href="http://www.mahalo.com/how-to-play-guitar-for-newbies"&gt;Learn Guitar&lt;/a&gt;</pre>
<p>I know&#8230;this is really simple, but stay with me; I promise we&#8217;re going somewhere with this. Our very simple HTML has passed our criteria:  users with CSS disabled will see the link, as will users without images or script. It&#8217;s very simply an accessible link on our page, read as easily by normal users as it is by search engines or even people using screen readers. Next, for users who can utilize our &#8220;nice to have&#8221; features, we&#8217;ll add a bit of CSS to make our image appear.</p>
<pre>.learnGuitar {
	display: block;
	width: 200px;
	height: 50px;
	background: url('/path/to/learn-guitar.png');
	text-indent: -9999em;
}</pre>
<p>As you can see, we&#8217;re using the <code>text-indent</code> CSS property to bump our text out of the way, and in it&#8217;s place, we&#8217;re using <code>background</code> to set an image for our link. All you have to do for your own image is adjust the width, height, and background URL to match. What you get when you&#8217;re all done is this:</p>
<style type="text/css">.learnGuitar{display: block;width: 200px;height: 50px;background: url('http://kyleschaeffer.com/wordpress/wp-content/uploads/2009/11/learn-guitar.png');text-indent: -9999em;}.learnGuitar:hover{border-style: none;background-color: transparent;}</style>
<p><a class="learnGuitar" href="http://www.mahalo.com/how-to-play-guitar-for-newbies">Learn Guitar</a></p>
<h2>Adding a Hover Image</h2>
<p>Easy and accessible CSS image replacement! It looks great, but let&#8217;s take it one more level to really make sure users know that our button DESERVES to be clicked. Let&#8217;s add a hover style. I&#8217;m going to use an image &#8220;sprite&#8221; for the hover image, which means that both our static and hover states are contained within the same image. Here&#8217;s my *single* image that&#8217;s used for this type of style:</p>
<p><img src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2009/11/learn-guitar-hover.png" alt="Learn Guitar Image Sprite" title="Image sprite - note that both button states are contained within the same image!" width="200" height="100" /></p>
<p>We&#8217;ll adjust our CSS to account for our new hover image. Note that the <code>height</code> and <code>width</code> attributes will not change! The hover-state image will be &#8220;clipped,&#8221; so that it&#8217;s only visible when users move their mouse cursor over our image button.</p>
<pre>.learnGuitar {
	display: block;
	width: 200px;
	height: 50px;
	background: url('/path/to/learn-guitar.png') top;
	text-indent: -9999em;
}
.learnGuitar:hover {
	background-position: 0 -50px;
}</pre>
<p>Now, when users move their mouse cursor over our image button, the CSS will &#8220;slide&#8221; the background image so that the hover state is displayed instead of the static state.</p>
<style type="text/css">.learnGuitarHover{display: block;width: 200px;height: 50px;background: url('http://kyleschaeffer.com/wordpress/wp-content/uploads/2009/11/learn-guitar-hover.png') top;text-indent: -9999em;}.learnGuitarHover:hover{background-position: 0 -50px;border-style: none;background-color:transparent;}</style>
<p><a class="learnGuitarHover" href="http://www.mahalo.com/how-to-play-guitar-for-newbies">Learn Guitar</a></p>
<p>Crafting your image buttons in this fashion can really save on performance and download times. Perhaps more importantly, your site will be much more &#8220;friendly&#8221; to visually impaired users using screen readers, and you&#8217;ll find that search engines will have an easier time understanding what your links and other content are all about.</p>
<p>Let me know if you have any questions or comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/image-buttons-and-accessibility/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

