<?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; Text</title>
	<atom:link href="http://kyleschaeffer.com/tag/text/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>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>39</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>
		<item>
		<title>CSS in Print Media</title>
		<link>http://kyleschaeffer.com/best-practices/css-in-print-media/</link>
		<comments>http://kyleschaeffer.com/best-practices/css-in-print-media/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 15:41:55 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Print Media]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=178</guid>
		<description><![CDATA[Most of the time, web designers will optimize a site to display on screen media (any type of screen, such as a computer monitor or a mobile device screen). If your site has a lot of information that could potentially &#8230; <a href="http://kyleschaeffer.com/best-practices/css-in-print-media/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Most of the time, web designers will optimize a site to display on screen media (any type of screen, such as a computer monitor or a mobile device screen).  If your site has a lot of information that could potentially be printed out by your visitors, you should consider adding print-specific CSS to your design in order to make your print media visitors happy.  Depending on your design itself, the visitor&#8217;s printer, and the visitor&#8217;s web browser, you can get a number of different results when printing a given page from the internet.  Here are a few quick and simple steps you can take to make your site display just as well on paper as it does on the screen.<span id="more-178"></span></p>
<h2>Targeting Print Media With CSS</h2>
<p>Browsers already have built-in support that allows you to separate your screen media CSS from your print media CSS.  By default, when you visit a page, you are going to see the &#8220;screen&#8221; version of your CSS style sheet, but if you hit the print button in your browser (and if the web designer for that particular site has created print-version CSS styles), you may see an entirely different set of CSS styles that have been optimized for display on paper.  Here&#8217;s how it&#8217;s done:</p>
<pre>&lt;style type=&quot;text/css&quot;&gt;
@media screen {
	body {
		background: #000;
		color: #fff;
	}
}
@media print {
	body {
		background: #fff;
		color: #000;
	}
}
@media screen, print {
	p {
		margin: 0 0 1.5em 0;
	}
}
&lt;/style&gt;</pre>
<p>In the CSS shown above, we have segregated our CSS into three distinct sections.  First, we show the CSS that is to be used <em>only</em> in screen media (<code>@media screen</code>).  Next, we designate a block of our CSS to be used only in print media (<code>@media print</code>).  Finally, we have a block of CSS that includes styles to be used in both screen and print media (<code>@media screen, print</code>).  This allows you to create styles only once if they are the same in both print and screen media.</p>
<h2>Font Sizes</h2>
<p>In a <a href="http://www.kyleschaeffer.com/?p=18">previous post</a>, I talked about the different font size units and the web.  In this post, I concluded that the percent (<code>%</code>) unit is the font size most suitable for internet screen media.  Because we are creating a print-version style sheet, however, the percent unit is no longer preferred.  When you create a document in a word processor, such as Microsoft Word or iWorks Pages, you choose the font size based off of a unit called &#8220;points.&#8221;  Points are font sizes optimized for printing, so we&#8217;ll want to make use of them in our print-media CSS style sheet.  Generally, you&#8217;ll want to set the base font size on your <code>body</code> tag to 11 or 12 points.</p>
<pre>&lt;style type=&quot;text/css&quot;&gt;
@media screen {
	body {
		font-size: 100%;
	}
}
@media print {
	body {
		font-size: 12pt;
	}
}
&lt;/style&gt;</pre>
<h2>Design Width</h2>
<p>Many site designs have a fixed pixel width, which doesn&#8217;t translate very well to print media.  Some browsers, such as Internet Explorer, will actually shrink your entire design in order to fit everything on the page, but many other browsers will simply clip the contents of your site when printing.  Generally, neither of these scenarios are desirable (shrinking your site often makes the font sizes too small).  Because you can&#8217;t predict the type of printer or the type of media on to which your site is being printed, you should always use a percentage width (preferably 100%) for your site layout.  Here&#8217;s how:</p>
<pre>&lt;style type=&quot;text/css&quot;&gt;
@media screen {
	.myOuterDiv {
		width: 1000px;
		margin: auto;
	}
}
@media print {
	.myOuterDiv {
		width: 100%;
	}
}
&lt;/style&gt;</pre>
<p>In this example, visitors to your site would see the <code>myOuterDiv</code> box as 1000 pixels wide (aligned in the center of the screen), but when printing the page, that particular <code>&lt;div/&gt;</code> tag would expand to the full width of the printed media.</p>
<h2>Other Considerations</h2>
<p>In many cases, you may want to hide something entirely on print media.  Navigation, for instance, often serves no purpose on printed media.  Search boxes, breadcrumbs, and forms are other examples of elements that you may want to hide when printing.  To do this, just add <code>display: none</code> to an element in the print media CSS:</p>
<pre>&lt;style type=&quot;text/css&quot;&gt;
@media screen {
	.topNavDiv {
		font-weight: bold;
		text-align: center;
	}
}
@media print {
	.topNavDiv {
		display: none;
	}
}
&lt;/style&gt;</pre>
<h2>Putting it All Together</h2>
<p>I&#8217;ve combined all of the elements discussed above into a simple HTML example.  Click on the link below to visit a sample HTML page that displays entirely differently on the screen and on print media.  You don&#8217;t have to print out the page!  Just go into your browser&#8217;s &#8220;Print Preview&#8221; function to see the difference.</p>
<p><a href="http://www.kyleschaeffer.com/printmedia">See the print media style sheet in action</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/css-in-print-media/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS Font-Size: em vs. px vs. pt vs. percent</title>
		<link>http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/</link>
		<comments>http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 17:06:56 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=18</guid>
		<description><![CDATA[One of the most confusing aspects of CSS styling is the application of the font-size attribute for text scaling. In CSS, you&#8217;re given four different units by which you can measure the size of text as it&#8217;s displayed in the &#8230; <a href="http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most confusing aspects of CSS styling is the application of the <strong>font-size</strong> attribute for text scaling.  In CSS, you&#8217;re given four different units by which you can measure the size of text as it&#8217;s displayed in the web browser.  Which of these four units is best suited for the web?  It&#8217;s a question that&#8217;s spawned a diverse variety of debate and criticism.  Finding a definitive answer can be difficult, most likely because the question, itself, is so difficult to answer.<span id="more-18"></span></p>
<h2>Meet the Units</h2>
<ol>
<li><strong>&#8220;Ems&#8221; (em):</strong>  The &#8220;em&#8221; is a scalable unit that is used in web document media.  An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt.  Ems are scalable in nature, so 2em would equal 24pt, .5em would equal 6pt, etc.  Ems are becoming increasingly popular in web documents due to scalability and their mobile-device-friendly nature.</li>
<li><strong>Pixels (px):</strong>  Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen).  One pixel is equal to one dot on the computer screen (the smallest division of your screen&#8217;s resolution).  Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser.  One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.</li>
<li><strong>Points (pt):</strong>  Points are traditionally used in print media (anything that is to be printed on paper, etc.).  One point is equal to 1/72 of an inch.  Points are much like pixels, in that they are fixed-size units and cannot scale in size.</li>
<li><strong>Percent (%):</strong>  The percent unit is much like the &#8220;em&#8221; unit, save for a few fundamental differences.  First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%).  While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.</li>
</ol>
<h2>So, What&#8217;s the Difference?</h2>
<p>It&#8217;s easy to understand the difference between font-size units when you see them in action.  Generally, <strong>1em = 12pt = 16px = 100%</strong>.  When using these font-sizes, let&#8217;s see what happens when you increase the base font size (using the body CSS selector) from 100% to 120%.</p>
<p><img class="size-full wp-image-23  " title="Font-sizes as they increase from 100% to 120%." src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2008/09/font-size-1.gif" alt="Font-sizes as they increase from 100% to 120%." /></p>
<p>As you can see, both the em and percent units get larger as the base font-size increases, but pixels and points do not.  It can be easy to set an absolute size for your text, but it&#8217;s much easier on your visitors to use scalable text that can display on any device or any machine.  For this reason, the em and percent units are preferred for web document text.</p>
<h2>Em vs. Percent</h2>
<p>We&#8217;ve decided that point and pixel units are not necessarily best suited for web documents, which leaves us with the em and percent units.  In theory, both the em and the percent units are identical, but in application, they actually have a few minor differences that are important to consider.</p>
<p>In the example above, we used the percent unit as our base font-size (on the body tag).  <strong>If you change your base font-size from percent to ems</strong> (i.e. <strong>body { font-size: 1em; }</strong>), you <em>probably</em> won&#8217;t notice a difference.  Let&#8217;s see what happens when &#8220;1em&#8221; is our body font-size, and when the client alters the &#8220;Text Size&#8221; setting of their browser (this is available in some browsers, such as Internet Explorer).</p>
<p><img class="size-full wp-image-27" title="Font-size as the client changes the text size in their browser." src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2008/09/font-size-2.gif" alt="Font-size as the client changes the text size in their browser." /></p>
<p>When the client&#8217;s browser text size is set to &#8220;medium,&#8221; there is no difference between ems and percent.  When the setting is altered, however, the difference is quite large.  On the &#8220;Smallest&#8221; setting, ems are much smaller than percent, and when on the &#8220;Largest&#8221; setting, it&#8217;s quite the opposite, with ems displaying much larger than percent.  While some could argue that the em units are scaling as they are truly intended, in practical application, the em text scales too abruptly, with the smallest text becoming hardly legible on some client machines.</p>
<h2>The Verdict</h2>
<p>In theory, the em unit is the new and upcoming standard for font sizes on the web, but in practice, the percent unit seems to provide a more consistent and accessible display for users.  When client settings have changed, percent text scales at a reasonable rate, allowing designers to preserve readability, accessibility, and visual design.</p>
<p><strong>The winner:</strong>  percent (%).</p>
<h2>Addendum (January 2011)</h2>
<p>It&#8217;s been a couple years since I wrote this post, and I&#8217;d like to sum up the discussion and debate that has happened in that time. Generally, when I create a new design, I will use percent on the <code>body</code> element (<code>body { font-size: 62.5%; }</code>), and then use the <code>em</code> unit to size it from there. As long as the <code>body</code> is set using the percent unit, you may choose to use either percent or ems on any other CSS rules and selectors and still retain the benefits of using percent as your base font size. Over the past couple of years, this has really become the standard in design.</p>
<p>Pixels are now considered <em>acceptable</em> font size units (users can use the browser&#8217;s &#8220;zoom&#8221; feature to read smaller text), although they are starting to cause some issues as a result of mobile devices with very high density screens (some Android and iPhone devices have upwards of 200 to 300 pixels per inch, making your 11- and 12-pixel fonts very difficult to see!). As a result, I will continue to use percent as my base font size in web documents. As always, discussion and debate is encouraged and welcome; thanks for all the great comments over the course of the past two years!</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/feed/</wfw:commentRss>
		<slash:comments>210</slash:comments>
		</item>
	</channel>
</rss>

