<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
			<title>Tagged with "css"</title>
			<link>http://www.addedbytes.com/feeds/tag-feed/</link>
			<description></description>
			<language>en</language>
			<copyright>Web Development in Brighton - Added Bytes 2006</copyright>
			<ttl>120</ttl>
			<item>
				<title>PDF Cheat Sheets</title>
				<link>http://www.addedbytes.com/blog/pdf-cheat-sheets/</link>
				<description><![CDATA[ <p>As requested by everyone, PDF versions of the <a href="http://www.addedbytes.com/php/php-cheat-sheet/">PHP</a>, <a href="http://www.addedbytes.com/css/css-cheat-sheet/">CSS</a> and <a href="http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/">mod_rewrite</a> cheat sheets are now online. Enjoy!</p> <p>As requested by everyone, PDF versions of the <a href="http://www.addedbytes.com/php/php-cheat-sheet/">PHP</a>, <a href="http://www.addedbytes.com/css/css-cheat-sheet/">CSS</a> and <a href="http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/">mod_rewrite</a> cheat sheets are now online. Enjoy!</p> <br><br>]]></description>
				<pubDate>Fri, 13 May 2005 16:49:00 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/blog/pdf-cheat-sheets/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=pdf&amp;start=0" class="ditto_tag" rel="tag">pdf</a>,<a href="/feeds/tag-feed/?tags=php&amp;start=0" class="ditto_tag" rel="tag">php</a>
			</item>

			<item>
				<title>Preload Images with CSS</title>
				<link>http://www.addedbytes.com/blog/code/preloading-images-with-css/</link>
				<description><![CDATA[ How to preload images using CSS and so avoid delays with rollover effects. <p>As support for CSS improves, pseudo-selectors like :hover, :active and :focus will become more widely used. Already :hover is in use on many sites to provide rollover states to buttons, as on this site (the menu bar). The other pseudo selectors will, in time, give far more opportunities for the use of rollover images.</p>

<p>One potential problem with image rollovers, though, is that in order for an image to be displayed, it must be downloaded. Consequently, for rollovers to work smoothly and quickly, all the necessary images must be already available on the user's PC. Otherwise, the rollovers will behave badly, like in this <a href="http://www.addedbytes.com/css_preload/">example using large images</a>.</p>

<p>Until recently, rollover effects were achieved through use of JavaScript, and as a result, a plethora of solutions to the preloading image problem in JavaScript are available. However, using JavaScript to preload images, though not a bad idea when using JavaScript to control rollovers, becomes less bright when it is CSS that's controlling them. A user could very easily (and this is becoming more common) have a CSS-capable browser without JavaScript support or with JavaScript turned off.</p>

<p>So there's a clear need for a way to use CSS to preload images or find another way to avoid the problem. Which gives us two relatively simple solutions to our problem.</p>

<p>The first solution is to create a single background image for your element that actually contains both the rollover and non-rollover images, and then position is using the background-position CSS property. Instead of changing the image when the mouse moves over the element, you can simply change the background-position to reveal the previously hidden rollover image. There's a more detailed <a href="http://wellstyled.com/css-nopreload-rollovers.html">explanation of this technique</a> over at WellStyled.com.</p>

<p>The other option available to you is to trick the browser into downloading the image before it is required for the rollover. This can be done by applying the image as a background to an element, and then hiding it using the background-position property. The image will then be downloaded but will not be displayed. Then, when the rollover is activated, it will operate smoothly and instantly.</p>

<p>First, you need to select an element that doesn't currently have a background image. If so select an element that does have a background image, you will either end up not preloading the image you are after, or you will prevent the element's normal background displaying. Neither is ideal.</p>

<p>Once you have picked an element to use for this purpose, you need to add the background image. The following CSS can be applied to the element and will place the background image outside the viewable area of the image:</p>

<code>background-image: url("rollover_image.png");
background-repeat: no-repeat;
background-position: -1000px -1000px;</code>

<p>Your rollover image will then be loaded when the page itself is initially loaded, along with the other images. When a rollover is then activated, the image will already be available to the browser and the effect will be instant.</p> <br><br>]]></description>
				<pubDate>Thu, 23 Dec 2004 10:13:43 +0000</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/blog/code/preloading-images-with-css/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=code&amp;start=0" class="ditto_tag" rel="tag">code</a>,<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=design&amp;start=0" class="ditto_tag" rel="tag">design</a>,<a href="/feeds/tag-feed/?tags=howto&amp;start=0" class="ditto_tag" rel="tag">howto</a>,<a href="/feeds/tag-feed/?tags=image&amp;start=0" class="ditto_tag" rel="tag">image</a>,<a href="/feeds/tag-feed/?tags=images&amp;start=0" class="ditto_tag" rel="tag">images</a>,<a href="/feeds/tag-feed/?tags=preload&amp;start=0" class="ditto_tag" rel="tag">preload</a>,<a href="/feeds/tag-feed/?tags=rollover&amp;start=0" class="ditto_tag" rel="tag">rollover</a>,<a href="/feeds/tag-feed/?tags=web&amp;start=0" class="ditto_tag" rel="tag">web</a>,<a href="/feeds/tag-feed/?tags=webdesign&amp;start=0" class="ditto_tag" rel="tag">webdesign</a>,<a href="/feeds/tag-feed/?tags=webdev&amp;start=0" class="ditto_tag" rel="tag">webdev</a>
			</item>

			<item>
				<title>View Page Structure</title>
				<link>http://www.addedbytes.com/blog/code/view-page-structure/</link>
				<description><![CDATA[ A tool that outputs the structure of a page. Makes working with CSS (especially resolving inheritance issues) much easier. <p>A couple of days ago, I was having a little CSS trouble. In the end, it turned out that I had set a property of an element "above" in the document tree, and the problematic element was inheriting that property.</p>

<p>It struck me that it would be easier to work through this kind of CSS problem with some kind of simple tool to show how a page was put together. If I could see all the tags on the page in a nested format, with parent and child relationships obvious, and without all the text getting in the way, my life would be easier.</p>

<p>So, I put together this tool. In simple terms, it will fetch a page from a web server and output the tags within the page in a nested list. The JavaScript side of it will also highlight children of an element when you hover over it.</p>

<p>Classes and ids attributes are highlighted, as are tag names. Class and ID names, though, must be enclosed in quotation marks to be highlighted. Text, closing tags and line breaks are not shown. Though I can understand some people may find it useful to see text, I found it made the tree too large to be usable.</p>

<p>I've used it a few times, and am quickly finding it saves quite a lot of time solving simple CSS problems or conflicts. Which is exactly what it was supposed to do. Enjoy!</p>

<h3>Highlighting Issues</h3>

<p>When writing the tool, I came across a fairly unusual problem. I wanted, when the mouse was over an element, to highlight its children. However, this cannot be done with CSS (at least, I couldn't think of a way to make it work).</p>

<p>The problem with the CSS was that whenever you hover over an element, you are also hovering over its parents. So they, and their children, are highlighted - meaning everything is highlighted. For this reason, the highlighting of elements uses JavaScript.</p>

<h3>How to Use</h3>

<p>The page structure tool is written to accept a URL either by GET or POST. You can therefore use it one of two ways.</p>

<p>First, you can use the tool by visiting the URL below, replacing "##url##" with the address of the page you want to view:</p>

<p>http://www.addedbytes.com/view_structure.php?url=##url##</p>

<p>Alternatively, you can use the following form to submit an address to the page:</p>

<form action="http://www.addedbytes.com/view_structure.php" method="post"><label for="viewstrucinput">Enter URL</label> <input id="viewstrucinput" name="url" type="text" /> <input type="submit" value="View" /></form>

<h3>Bookmarklet</h3>

<p>To make life a little easier, I've coded a quick JavaScript bookmarklet for you to use, that, when activated, will automatically submit the URL of the page you are viewing to the tool. Simply copy or drag the link below to your links bar, your favourites folder or anywhere else you wish:</p>

<ul><li><a href="javascript:void(location.href='http://www.addedbytes.com/view_structure.php?url='+location.href);">View Page Structure</a></li></ul>

<h3>Notes</h3>

<ul><li>This tool works best with valid code, especially XHTML.</li><li>A certain amount of basic code improvement is done before processing (for example all empty tags are automatically closed).</li><li>Sites with non-empty tags that aren't closed properly may not show up correctly.</li><li>Sites with large amounts of nested code should still show up, but it may be difficult to view the output.</li></ul>

<h3>Example</h3>

<p>If you want to see an example of the output of this tool, you can view the  <a href="http://www.addedbytes.com/view_structure.php?url=http://www.addedbytes.com">structure for AddedBytes.com</a>.</p> <br><br>]]></description>
				<pubDate>Tue, 12 Oct 2004 16:24:00 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/blog/code/view-page-structure/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=cheatsheet&amp;start=0" class="ditto_tag" rel="tag">cheatsheet</a>,<a href="/feeds/tag-feed/?tags=code&amp;start=0" class="ditto_tag" rel="tag">code</a>,<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=design&amp;start=0" class="ditto_tag" rel="tag">design</a>,<a href="/feeds/tag-feed/?tags=imported&amp;start=0" class="ditto_tag" rel="tag">imported</a>,<a href="/feeds/tag-feed/?tags=resources&amp;start=0" class="ditto_tag" rel="tag">resources</a>,<a href="/feeds/tag-feed/?tags=tool&amp;start=0" class="ditto_tag" rel="tag">tool</a>,<a href="/feeds/tag-feed/?tags=tools&amp;start=0" class="ditto_tag" rel="tag">tools</a>,<a href="/feeds/tag-feed/?tags=useful&amp;start=0" class="ditto_tag" rel="tag">useful</a>,<a href="/feeds/tag-feed/?tags=webdesign&amp;start=0" class="ditto_tag" rel="tag">webdesign</a>,<a href="/feeds/tag-feed/?tags=xhtml&amp;start=0" class="ditto_tag" rel="tag">xhtml</a>
			</item>

			<item>
				<title>The Box Model For Beginners</title>
				<link>http://www.addedbytes.com/articles/for-beginners/the-box-model-for-beginners/</link>
				<description><![CDATA[ An explanation of what the box model is and how it is treated by different user agents. <p>The term "box model" is often used by people when talking about CSS-based layouts and design. Not everyone understands what is meant by this though, and not everyone understands why it is so important.</p>

<p>Any HTML element can be considered a box, and so the box model applies to all HTML (and XHTML) elements.</p>

<p>The box model is the specification that defines how a box and its attributes relate to each other. In its simplest form, the box model tells browsers that a box defined as having width 100 pixels and height 50 pixels should be drawn 100 pixels wide and 50 pixels tall.</p>

<p>There is more you can add to a box, though, like padding, margins, borders, etc. This image should help explain what I'm about to run through:</p>

<p style="text-align:center;"><img src="content/box-model/box.png" alt="Outline of box model" /></p>

<p>As you can see, a box is made up of four distinct parts. The outside one, the margin, is completely invisible. It has no background color, and will not obstruct elements behind it. The margin is outside the second part, which is the border. The border outlines the visible portion of the element. Inside the border is the third part of the box, the padding, and then inside that the content area of the box. The padding defines the space between the content area of the box and the border.</p>

<p>(Note that in the image above, the only border of the three drawn that would actually be visible is the solid line - the dashed lines are added to help demonstrate the box model).</p>

<p>When you define a width and a height for your box using CSS, you are defining not the entire area taken up by the content, padding, border and margin. You are actually just defining the content area itself - the bit right in the middle. The padding, border and margin must be added to that in order to calculate the total space occupied by the box. (From this point on, we will use width for demonstrations, but the same principles apply to both width and height).</p>

<code>box {
    width: 200px;
    border: 10px solid #99c;
    padding: 20px;
    margin: 20px;
}</code>

<p>The above CSS, applied to a box, would mean that that box occupied 300 pixels of space horizontally on the page. The content of the box would occupy 200 pixels of that (dashed line added to demonstrate the edge of the area occupied by the box):</p>

<p style="text-align:center;"><img src="content/box-model/box_demo.png" alt="Box model demonstration." /></p>

<p>In the above image, you can see that the pale blue area is 240 pixels wide (200 pixels of content plus 20 pixels padding either side). The border is 10 pixels wide either side, making the total width including the border 260 pixels. The margin is 20 pixels either side, making the total width of the box 300 pixels.</p>

<p>In practice, this can cause some confusion. For example, if I have a 100 pixel wide space available, and want to fill it with a pale red box with a dark red border and a small amount of padding, it would be very easy to write the CSS like so:</p>

<code>box {
    width: 100px;
    border: 1px solid #900;
    padding: 10px;
    margin: 0;
    background: #fee;
}</code>

<p>(A declaration of 0, as used for the margin above, does not require a unit to be added. Any value other than 0 does require a unit, e.g. px for pixels. Also, although "background" is defined as a shorthand property, it is more widely supported than the more correct "background-color".)</p>

<p>However, that will not give us a 100 pixel wide box, as the width declaration defines the content area of the box. The content area of the box will be 100 pixels - the total width of the box as defined above will be 122 pixels:</p>

<p style="text-align:center;"><img src="content/box-model/box_demo2.png" alt="Box model demonstration." /></p>

<p>In order to set the above box to only occupy 100 pixels horizontally, you would need to set the width of the content area to be 100 pixels minus the padding and minus the border, in this case 78 pixels, like so:</p>

<code>box {
    width: <strong>78px</strong>;
    border: 1px solid #900;
    padding: 10px;
    margin: 0;
    background: #fee;
}</code>

<p>To calculate the overall width of a box, including all padding, borders and margins, you would use the following formula:</p>

<code>total box width = content area width + left padding + right padding + left border + right border + left margin + right margin</code>

<h3>Compatibility</h3>

<p>At this point, you should now have a good understanding of what the box model is, and how boxes <em>should</em> be treated by different browsers. However, as you will soon learn (if you did not know already), not every browser does as it is supposed to. In order to use boxes, and by extension make the most of CSS in your website, you will need to be aware of how the different browsers treat boxes in practice and how to overcome and work around the problems presented by these idiosyncrasies.</p>

<h3>Top Notch</h3>

<p><img src="images/browser_logos/opera6.gif" alt="Opera 6" /> <img src="images/browser_logos/opera7.gif" alt="Opera 7" /> <img src="images/browser_logos/mozilla.gif" alt="Mozilla" /> <img src="images/browser_logos/firefox.gif" alt="Firefox" /> <img src="images/browser_logos/camino.gif" alt="Camino" /> <img src="images/browser_logos/safari.gif" alt="Safari" /> <img src="images/browser_logos/konqueror.gif" alt="Konqueror" /> <img src="images/browser_logos/netscape6.gif" alt="Netscape 6" /> <img src="images/browser_logos/netscape7.gif" alt="Netscape 7" /> <img src="images/browser_logos/ie6.gif" alt="Internet Explorer 6" /></p>

<p>Most browsers released in the last few years have no problem with boxes and render boxes correctly. Opera 6 and 7, Mozilla 1 (and by extension other browsers based on the Gecko engine like Netscape 7, Camino and Firefox and other derivatives), Safari, Konquerer (and derivatives) and Internet Explorer 5 for the Mac are all shining examples of how a web browser <em>should</em> behave, all rendering boxes flawlessly. IE 6 for Windows also will render a box correctly, as long as the [url=http://www.addedbytes.com/design/dtds-explained]Document Type Definition[/url] for the page is correct.</p>

<h3>Whoops, Mrs Miggins, You're Sitting On My Artichokes</h3>

<p><img src="images/browser_logos/ie5.gif" alt="Internet Explorer 5" /> <img src="images/browser_logos/ie6.gif" alt="Internet Explorer 6" /></p>

<p>Some browsers don't display a box correctly. Unlike those below here, these browsers are widely enough used on the web that it is usually worth the effort to work through the problem. There are various methods for doing this, some better than others, that follow on. Most notable among the browsers with problems are Internet Explorers 4 and 5 and Internet Explorer 6. IE 6 is easy to work around, by adding a correct DTD (which you should be doing anyway).</p>

<p>Internet Explorer 5 is the main reason there is a box model problem at all. It, unfortunately, does not follow the simple definition for box layout as defined by the W3c. When you define a width for a box and it is rendered in IE5, instead of that width defining the content area of the box, it <em>includes the borders and padding</em>. Margins are added on to the content width correctly, but padding and borders are not. Unfortunately, this leaves us with some unpleasant choices:</p>

<ol><li><strong>Use a box model hack</strong><br />
Hack's like [url=http://www.tantek.com/CSS/Examples/boxmodelhack.html]Tantek's box model hack[/url] are unfortunately something of a necessity. While some might argue that using hacks like this is completely missing the point of using CSS for web design, commercial necessity and the prevalence of IE5 leave us with little in the way of choice. The IE5 box model hack is in use all over the web and has spawned plenty of variants.</li><li><strong>Add in extra code</strong><br />
Some might consider this a slightly "better" way of working around this problem. Rather than adding a style sheet hack, you can nest elements within each other. Adding a div within another div means that rather than using padding, you can use just margins, which are handled correctly by IE5. As with the box model hack, it is far from a perfect solution, but there are few other options if you want a site to look the same in IE5 as other more capable browsers.</li></ol>

<h3>Hall of Shame</h3>

<p><img src="images/browser_logos/ie4.gif" alt="Internet Explorer 4" /> <img src="images/browser_logos/netscape4.gif" alt="Netscape 4" /></p>

<p>On the one hand, the browsers that I am about to mention are appalling, all failing dismally to render a simple box correctly for one reason or another. On a more positive note, users of these browsers, mostly old versions of current browsers, make up an extremely small, and continually shrinking, portion of web users. While you could probably find a workaround for the bugs in the display of boxes in these browsers, it is almost certainly not worth the effort - you are likely to cause yourself more harm than good with workarounds for these!</p>

<p>Netscape 4's box model is awful, but even worse, the simple box model hacks to fix the problem for IE5 and IE6 will crash Netscape 4. Netscape 4's style sheet support is abysmal overall, and it is being supported less and less. Though it is strictly a personal choice, I don't think it is worth the time and effort to support Netscape 4 any more - it's just not used enough, and the number of users is only ever going to shrink.</p>

<p>Internet Explorer 4 suffers, basically, the same problem as IE5. It treats boxes in a very similar way. However, it falls over in far more ways, and many of the available hacks will crash IE4. As it is also used by few people, and that number is dropping, many designers ignore it.</p>

<h3>What does the future hold?</h3>

<p>CSS3 promises us the option to determine how we want the user agent to treat boxes, and specify which box model we want to use. Support for CSS3 at a level that will be possible is many many years away yet. Until then, we are stuck with the CSS2 box model, and while IE5 is still used by a significant percentage of the web's population, we are going to have problems with boxes.</p> <br><br>]]></description>
				<pubDate>Fri, 09 Jul 2004 11:48:54 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/articles/for-beginners/the-box-model-for-beginners/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=box&amp;start=0" class="ditto_tag" rel="tag">box</a>,<a href="/feeds/tag-feed/?tags=boxmodel&amp;start=0" class="ditto_tag" rel="tag">boxmodel</a>,<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=design&amp;start=0" class="ditto_tag" rel="tag">design</a>,<a href="/feeds/tag-feed/?tags=for+beginners&amp;start=0" class="ditto_tag" rel="tag">for beginners</a>,<a href="/feeds/tag-feed/?tags=html&amp;start=0" class="ditto_tag" rel="tag">html</a>,<a href="/feeds/tag-feed/?tags=model&amp;start=0" class="ditto_tag" rel="tag">model</a>,<a href="/feeds/tag-feed/?tags=tutorial&amp;start=0" class="ditto_tag" rel="tag">tutorial</a>,<a href="/feeds/tag-feed/?tags=webdesign&amp;start=0" class="ditto_tag" rel="tag">webdesign</a>
			</item>

			<item>
				<title>Faux Columns for Liquid Layouts</title>
				<link>http://www.addedbytes.com/blog/code/faux-columns-for-liquid-layouts/</link>
				<description><![CDATA[ Using CSS for layouts can be a problem when using backgrounds for two columns that are not of equal length. This article expands on the solution to this problem from AListApart. <p>In January of 2004, <a href="http://simplebits.com/">Dan Cederholm</a> (author of <a href="http://www.amazon.co.uk/exec/obidos/ASIN/1590593812/tooyoo-21">Web Standards Solutions</a>) posted an article on <a href="http://www.alistapart.com">AListApart</a> entitled "<a href="http://www.alistapart.com/articles/fauxcolumns/">Faux Columns</a>". In it, he explained how designers can overcome a common problem in CSS-based designs.</p>

<p>The problem is one that usually rears its ugly head with two and three column designs (though for now, we'll just worry about two columns). If your two columns each have a different background color, how do you make the colours extend to the bottom of the page using css? Equal height columns are difficult to achieve using height and overflow properties. Each column will be of a different height, and you do not always know which is the taller of the two. It is all too easy to end up with a site where one column just doesn't extend all the way to the bottom of the page, where it should end.</p>

<p>CSS does actually include a rather nifty little tool that can be used to work around this problem, the "min-height" declaration, that allows you to specify a minimum height for an element - which you can use to ensure that one specific column is always larger than the other, allowing you to avoid this problem. Unfortunately (and perhaps unsurprisingly) Internet Explorer does not support this declaration, so in practice it isn't a useful solution to the problem.</p>

<p>Dan, in his article (which if you haven't read yet, I suggest you do before continuing), outlines a solution he uses on his own site. This solution involves tiling a background on the page, to give the appearance that there are distinct columns that extend the full length of the page. It's a simple but clever solution, and can be seen in use on a great many sites on the web.</p>

<p>During the recent redesign of this site, though, I came across a small problem. Though Dan's solution is perfect for fixed-width layouts, it just wouldn't work with a percentage-based, liquid layout. The problem was simple - a graphic cannot alter itself based upon the user's screen. If you come up with a background image like the below, and tile it on a page, the left hand column will need to be 200 pixels wide. If your column is 20% of the page, though, that could make it anything from 20 to 2000 pixels - and as a result your columns will rarely look as you intended. This makes equal height columns in liquid layouts a tricky proposal.</p>

<p>However, Dan's solution can be used to apply a background to a page when the layout is liquid, using background positioning.</p>

<p>Background positioning can allow us to give our background the appearance of being liquid. When you positioning a background using pixels, you position the top left corner of the image. When you position a background using percentages or keywords, you don't. Instead, you position a <em>point within the image itself</em>. For example, let's say we have a page and a simple background image. We use the following to set and position the background:</p>

<code>body {
    background-image: url("image.gif");
    background-repeat: no-repeat;
    background-position: 25% 10%;
}</code>

<p>The above will set "image.gif" as the background of the page. It will position the background 25% of the way across the page from the left, and 10% of the way down the page from the top. However, it is not the left hand corner that will appear at that point. It is the point 25% from the left hand side of the background image and 10% from the top that will appear at that point, like so:</p>

<p style="text-align: center;"><img src="content/faux-columns-for-liquid-layouts/faux-example.gif" alt="Example of background positioning based upon percentages" /></p>

<p>We can use this to apply a background to a page that will give the illusion of a pair of columns, even though the columns are not of a fixed width. Let's say we have two columns (for now), of 25% and 75% width. We can create a simple image, 1 pixel tall by 2000 pixels wide (why so wide will become apparent shortly - but don't be afraid to go even larger if you wish - 4000 pixels wouldn't necessarily be a bad thing). We want the left column to be a nice shade of orange, and the right a nice shade of grey, with a black line to divide them. So the image needs to have a black line 25% of the way along, with everything to the left orange and everything to the right grey, like so (scaled for visibility):</p>

<p style="text-align: center;"><img src="content/faux-columns-for-liquid-layouts/faux-example2.gif" alt="Example of background image" /></p>

<p>Now, we position the background using the following CSS:</p>

<code>body {
    background-image: url("background.gif");
    background-repeat: repeat-y;
    background-position: 25% 0;
}</code>

<p>Now, if you were to draw a line down the page, 25% of the way across from the left hand side, then 25% of our background image would be to the left of that line and 75% to the right. If we use the 2000 pixel wide background mentioned earlier, and position it as above, we'll have an orange background for 25% of the page, a black line, then grey will fill the remaining 75% of the page. You can <a href="http://www.addedbytes.com/content/faux-columns-for-liquid-layouts/faux1.html">see an example of that here</a>. If you resize your browser window, while viewing the example, you will see the columns expand and contract to maintain the same proportions of the columns. With a little imagination, and the use of partly transparent background images, you can create image borders between elements using the same technique.</p>

<p>A little markup and a little more CSS, and we can turn the above into a respectable liquid page, with columns that expand and contract with the users' windows, and always extend just as far as they are needed. A <a href="http://www.addedbytes.com/content/faux-columns-for-liquid-layouts/faux2.html">more complete example is here</a>, and this technique is also in use at this very site [please note that this technique is in use in versions 3, 4 and 5 of this site, accessible through the footer], allowing the flexible navigation and content columns to always appear equal in length, despite the fact they almost never are.</p> <br><br>]]></description>
				<pubDate>Tue, 22 Jun 2004 17:31:13 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/blog/code/faux-columns-for-liquid-layouts/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=design&amp;start=0" class="ditto_tag" rel="tag">design</a>,<a href="/feeds/tag-feed/?tags=faux&amp;start=0" class="ditto_tag" rel="tag">faux</a>,<a href="/feeds/tag-feed/?tags=fluid&amp;start=0" class="ditto_tag" rel="tag">fluid</a>,<a href="/feeds/tag-feed/?tags=hacks&amp;start=0" class="ditto_tag" rel="tag">hacks</a>,<a href="/feeds/tag-feed/?tags=html&amp;start=0" class="ditto_tag" rel="tag">html</a>,<a href="/feeds/tag-feed/?tags=layout&amp;start=0" class="ditto_tag" rel="tag">layout</a>,<a href="/feeds/tag-feed/?tags=liquid&amp;start=0" class="ditto_tag" rel="tag">liquid</a>,<a href="/feeds/tag-feed/?tags=reference&amp;start=0" class="ditto_tag" rel="tag">reference</a>,<a href="/feeds/tag-feed/?tags=tutorial&amp;start=0" class="ditto_tag" rel="tag">tutorial</a>,<a href="/feeds/tag-feed/?tags=web&amp;start=0" class="ditto_tag" rel="tag">web</a>,<a href="/feeds/tag-feed/?tags=webdesign&amp;start=0" class="ditto_tag" rel="tag">webdesign</a>
			</item>

			<item>
				<title>Background Images for Beginners</title>
				<link>http://www.addedbytes.com/articles/for-beginners/background-images-for-beginners/</link>
				<description><![CDATA[ Everything you ever wanted to know about using background images in CSS. <p>Many web sites, let's face it, are fairly bland (yes, including this one). Many use too few images to brighten up their pages or end up with boring sites, rather than use them to add interesting visual effects. However, adding images does not have to be tricky, and one of the quickest, most effective ways to do that is with backgrounds.</p>

<h3>Selecting Images</h3>

<p>A few years ago, Geocities and Angelfire were packed with sites that used incredibly bright, garish backgrounds on their pages. Instantly, tiled backgrounds went out of fashion, and are often derided. However, there is no reason you can't use a tasteful tiled background on your pages, as long as you remember to keep it reasonably subtle and make sure your page content is still readable. For those of you who doubt that tiles backgrounds can ever be tasteful, take a peek at the [url=http://www.squidfingers.com/patterns/]free backgrounds available from Squidfingers.com[/url], all of which look great and could easily improve a web page.</p>

<p>Of course, there's no reason you have to use a tiled background on a site. Sometimes a single, simple image can be extremely effective. Sometimes a collection of background images works best, as a quick visit to [url=http://www.csszengarden.com]CSSZenGarden.com[/url] will demonstrate. If using a background image, make sure it doesn't clash with your design, and make sure your site works without it, as not everyone will be able to see it.</p>

<p>There's also no reason that the background you add needs to be a page background. Backgrounds can work well as borders to elements, or backgrounds to specific parts of pages, rather than the entire document.</p>

<h3>Adding Backgrounds</h3>

<p>Defining a background in CSS is fairly simple, and the below is an example of the quickest way to do it.</p>

<code>body {
    background-image: url("background.gif");
}</code>

<p>That code will place "background.gif" at the top left of the body of the page being styles. The image will also tile itself so it covers the entire page. And when you scroll down the page, the background will move as you do so.</p>

<p>Some people may not be seeing images though - they may have them turned off, for example - so it is important to set a background colour as well. This is done using the "background-color" property, as below. Please note that if you have transparent areas in your image, the colour you choose as a background will show through those areas too. Also, when setting a background to the &lt;body&gt; element, it is important to not assume that everyone has the same default background colour as you, as they may not.</p>

<code>body {
    background-color: #ffffff;
    background-image: url("background.gif");
}</code>

<h3>Stop that Background!</h3>

<p>The first thing many designers want to do is stop a background from tiling and moving. They want one image as the background, and they want it to stay still while you scroll. These two settings are controlled by "background-repeat" and "background-attachment".</p>

<p>"background-repeat" tells the browser which direction or directions the image should be tiled in, if at all. The values allowed for background-repeat are "no-repeat", "repeat-x", "repeat-y" and "repeat". "repeat" is the default behaviour for most browsers, so usually not worth specifying. "repeat-x" tells the browser to repat the image horizontally, and "repeat-y" vertically. "no-repeat" tells the browser to only use the image once - not to tile it in any direction. To tell the browser not to tile the image we used above, we might use the following code:</p>

<code>body {
    background-color: #ffffff;
    background-image: url("background.gif");
    background-repeat: no-repeat;
}</code>

<h3>More control</h3>

<p>"background-attachment" tells the browser whether or not the image should move when the user scrolls with a page. The default is for it to move with the window, so this property is generally only used when a designer wants an image to stay still while a user scrolls up and down a page. The "background-attachment" property can have one of two values, "scroll" (the default) or "fixed". Continuing with the same example we've used above, making a single image, that isn't going to tile, stay still while the user scrolls, could use the following code:</p>

<code>body {
    background-color: #ffffff;
    background-image: url("background.gif");
    background-repeat: no-repeat;
    background-attachment: fixed;
}</code>

<h3>Positioning</h3>

<p>The "background-position" property in CSS applies to any element with a background image applied. It can be used to move a background image around a page, and with a little creative use of server-side scripting could even be used to make a background image appear in a different place for each used who visits your site. However, for now, let's stick to the basics.</p>

<p>Background positions can be set in any one of three ways: using keywords, using percentages, or using pixels.</p>

<p>Keywords are the most commonly used of these, probably because they are quite simple to use. They work as a pair, though you do not need to name both of them. You name the vertical part first, and the horizontal second. The vertical part can have a value of "top", "center" or "bottom", and the horizontal can be "left", "center", or "right". The defaults for these are "top" and "left". If, however, you wanted the image we've been working with so far to be at the bottom right, you might use code like this:</p>

<code>body {
    background-color: #ffffff;
    background-image: url("background.gif");
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: bottom right;
}</code>

<p>Pixels are also easy to use. If you want to place a background image 100 pixels from the left hand side of the page, and 50 pixels from the top, you could use the following, though it's important to remember that when using pixels or percentages to position a background, it is the horizontal part you define first:</p>

<code>background-position: 100px 50px;</code>

<p>Percentages can be more tricky to work with. When you define a percentage, you do not always, as with pixels, define where the top left corner of the background image will be placed. For example, if you were to place a background image at "10% 10%", you might expect the top left corner of the image to be 10% of the way down the page, and 10% of the way across the page from the left hand side. However, what will happen in practice is that the point 10% of the way down the image, and 10% from the left hand side of the image, will be 10% of the way down the page, and 10% of the way across the page from the left hand side. (It is worth noting that the same principles apply to keywords - center being equivalent to 50% and right and bottom equivalent to 100% for positioning purposes - keywords are usually easier to get your head around though.)</p>

<p>While this can cause the occasional glitch, percentages are, however, quite easy to work with when you get used to them. For example, if you wanted to place an image dead center to the page, the following would place the center point of an image at the center point of a page:</p>

<code>body {
    background-color: #ffffff;
    background-image: url("background.gif");
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: 50% 50%;
}</code>

<h3>Shorthand Laziness</h3>

<p>All things considered, the final bit of code above is quite a handful. That's a lot to type in order to add a background to an image. If you want to save yourself some time, and some bytes, you can use shorthand declerations to set backgrounds. If you remember the default values for properties too, you'll save yourself even more time and bandwidth.</p>

<p>The above code, in shorthand, would be this:</p>

<code>body {
    background: #ffffff url("background.gif") no-repeat fixed bottom right;
}</code>

<p>You don't need to set every value in the above to use it though. For example, if you wanted to set a background image on a page, using a background colour of white, but you wanted the image to tile and to move when you scrolled, you could just use this:</p>

<code>body {
    background: #ffffff url("background.gif");
}</code>

<p>As you can see, this makes background declerations far more manageable (and is actually slightly more widely supported than the longer alternative). </p>

<h3>Getting Creative</h3>

<p>Bearing in mind we can attach a background to a particular side of an element, there is no reason we can't use backgrounds as borders to elements. Apply a border to the bottom of links, with a little padding, and you'll have a very unusual underlining effect. Backgrounds can be applied to virtually any element - make the most of them!</p>

<h3>Microsoft Difficuly</h3>

<p>It may have occurred to you already that using semi-transparent images (for example PNGs), you could create some pretty impressive effects. Sadly, Microsoft do not yet support PNGs properly, meaning we can't use semi-transparent backgrounds very easily. However, all is not lost. If you want semi-transparent backgrounds, you can use IE's "AlphaImageLoader", which will make an image translucent by percentage to fake the effect. As the "AlphaImageLoader" is proprietary Microsoft technology, it will not affect how your site looks in other browsers.</p> <br><br>]]></description>
				<pubDate>Mon, 14 Jun 2004 14:44:05 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/articles/for-beginners/background-images-for-beginners/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=for+beginners&amp;start=0" class="ditto_tag" rel="tag">for beginners</a>,<a href="/feeds/tag-feed/?tags=webdesign&amp;start=0" class="ditto_tag" rel="tag">webdesign</a>
			</item>

			<item>
				<title>RGB Colours for Beginners</title>
				<link>http://www.addedbytes.com/articles/for-beginners/rgb-colours-for-beginners/</link>
				<description><![CDATA[ There are different ways to define colours in web design, depending on the language you are writing. This tutorial explains how to define colours correctly. <p>HTML (version 4 and onwards), XHTML and CSS allow you to use different techniques to specify colours to use within documents.</p>

<p>Colours in XHTML are virtually redundant (really, no colour should ever be specified within an XHTML document, it should be specified through CSS), however it allows for deprecated elements, for example the &lt;b&gt; or &lt;font&gt; tags. Some deprecated elements do allow colour attributes.</p>

<p>The following 16 named colours (and only these names) are valid for HTML 4 and above, XHTML and CSS:</p>

<ul><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Black (#000000)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #008000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Green (#008000)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #C0C0C0;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Silver (#C0C0C0)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #00FF00;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Lime (#00FF00)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #808080;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Gray (#808080)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #808000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Olive (#808000)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #FFFFFF;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> White (#FFFFFF)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #FFFF00;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Yellow (#FFFF00)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #800000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Maroon (#800000)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #000080;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Navy (#000080)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #FF0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Red (#FF0000)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #0000FF;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Blue (#0000FF)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #800080;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Purple (#800080)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #008080;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Teal (#008080)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #FF00FF;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Fuchsia (#FF00FF)</li><li><span style="width: 1em; height: 1em; margin: 2px; border: 1px solid #000; background-color: #00FFFF;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Aqua (#00FFFF)</li></ul>

<p>Colours can also be specified in RGB Hex codes in HTML, XHTML and CSS. RGB Hex codes are six digit hexadecimal numbers (hexadecimal numbers being made up of the digit 0-9 and letters A-F, A representing 10 as a single digit, through to F representing 15). They are made up of three pairs, each of which when translated to decimal will equal a value between 0 and 255 (00 to FF). An example colour would be "#FF9933". The first pair of digits refers to the amount of red in a colour ("FF"), the second the amount of green ("99"), and the last pair the amount of blue("33"). These numbers must <strong>always</strong> be prefixed with a hash symbol (#). Please see this [url=http://www.addedbytes.com/Resources/Colour_Chart/]RGB Hex Colour Chart[/url] for a list of web-safe colour codes, with examples (web-safe colours are those that should look the same across all systems, and should avoid issues with AOL's image-caching systems).</p>

<p>CSS allows further methods of defining colours. However, these will not work in HTML or XHTML.</p>

<p>The first of these is useful for saving yourself a few bytes in your CSS files. RGB Hex codes can be abbreviated to three digits. This is possible where each of the three pairs of a colour code consist of two of the same digit. In our example above, "#FF9933", the three pairs are all made of a two identical digits, so that can be abbreviated to "#F93". You still need the hash symbol, and this can only be done when <em>all three</em> of the pairs are made up of two identical digits.</p>

<p>You can also define colours in decimal form in CSS. This is quite useful if you have trouble working with hexadecimal definitions. The syntax for using decimal colour definitions in CSS is:</p>

<code>* {
    color: rgb(255, 153, 51);
}</code>

<p>This will set the colour of all elements on a page to the decimal equivalent of "#FF9933". The "amount" of each of the three colours - red, green and blue - is defined as a number between 0 and 255 in this definition. For those of you who were wondering, here are values of hexadecimal numbers converted to decimal:</p>

<ul><li>FF - 255</li><li>EE - 238</li><li>DD - 221</li><li>CC - 204</li><li>BB - 187</li><li>AA - 170</li><li>99 - 153</li><li>88 - 136</li><li>77 - 119</li><li>66 - 102</li><li>55 - 85</li><li>44 - 68</li><li>33 - 51</li><li>22 - 34</li><li>11 - 17</li><li>00 - 0</li></ul>

<p>Last, you can define CSS colours as percentages in RGB, rather than in decimal or hexadecimal numbers. All you need do is add the percent sign (%) after the number you wish to use, in the same piece of code you use for decimal colour definitions:</p>

<code>* {
    color: rgb(100%, 60%, 200%);
}</code>

<p>Hexadecimal numbers convert into percentages like so:</p>

<ul><li>FF - 100%</li><li>EE - 93%</li><li>DD - 87%</li><li>CC - 80%</li><li>BB - 73%</li><li>AA - 67%</li><li>99 - 60%</li><li>88 - 53%</li><li>77 - 47%</li><li>66 - 40%</li><li>55 - 33%</li><li>44 - 27%</li><li>33 - 20%</li><li>22 - 13%</li><li>11 - 7%</li><li>00 - 0%</li></ul>

<p>In instances where a colour is defined that is outside the possible range of numbers allowed (eg 0-255 in decimal), numbers will be assumed to be equal to the maximum allows. For example, a colour of "rgb(500,0,0)" will be equivalent to "rgb(255,0,0)".</p>

<p>Personally, I try to always use the standard hexadecimal code for defining colours, as that has been the convention on the web for so long, and that is the only convention that works across all the languages in use on the web.</p> <br><br>]]></description>
				<pubDate>Mon, 14 Jun 2004 11:31:01 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/articles/for-beginners/rgb-colours-for-beginners/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=color&amp;start=0" class="ditto_tag" rel="tag">color</a>,<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=for+beginners&amp;start=0" class="ditto_tag" rel="tag">for beginners</a>
			</item>

			<item>
				<title>CSS Selectors for Beginners</title>
				<link>http://www.addedbytes.com/articles/for-beginners/css-selectors-for-beginners/</link>
				<description><![CDATA[ CSS Selectors allow you to specify the types and groups of elements you want to apply certain styles to. <p>Selectors are a tool within CSS that allow you to ensure that a style is only applied to a set page element, of group of them. In its simplest form, a selector can be simply a tag name. For example, you may have a rule on a web page that looks like this:</p>

<code>h1 {
    font-weight: bold;
    font-size: 1.5em;
    color: #f00;
}</code>

<p>The above will turn all text within &lt;h1&gt; tags large, bold and red. The start of the rule, "h1", tells the user agent to only apply that rule, the large bold redness, to text within &lt;h1&gt; tags. This is a part of CSS1, the first level of CSS. Any browser that supports CSS at all should support basic selectors like these.</p>

<p>However, while the above is useful, it doesn't let you apply styles very specifically to individual elements, or to only a small subset of items of one type, or group. So next, we have classes and ids, used within code to allow us to apply styles to, respectively, elements of a specific group, and unique single elements on a page. You apply these by adding "class" and "id" attributes to the HTML of your document, and then adding selectors to the CSS, like so:</p>

<code>&lt;html&gt;
    &lt;head&gt;
        &lt;style type="text/css"&gt;&lt;!--

            p {
                font-size: 0.8em;
            }

            .main_text {
                color: #f00;
            }

            #first_paragraph {
                font-weight: bold;
            }

        --&gt;&lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;

        &lt;p id="first_paragraph" class="main_text"&gt;
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        &lt;/p&gt;

        &lt;p  class="main_text"&gt;
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        &lt;/p&gt;

        &lt;p&gt;
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        &lt;/p&gt;

    &lt;/body&gt;
&lt;/html&gt;</code>

<p>The first selector in the CSS tells the browser that the following style applies to all text within "&lt;p&gt;" tags. The second rule starts with the selector ".main_text", telling the browser that the following rule applies to all elements of class "main_text", the "." telling the browser this rule applies to a class, and the "main_text" identifying that class. The third rules starts with the selector "#first_paragraph". The "#" at the beginning tells the browser that the rule only applies to one element, with the id "first_paragraph".</p>

<p>Again, the above is a part of CSS1, and should be supported by any browser with basic CSS support.</p>

<p>If you want, you can apply styles to elements depending upon their position within a page. For example, if you want to apply styling to any list item in an unordered list, but not ordered lists, you can write a CSS rule like so:</p>

<code>ul li {
    font-weight: bold;
}</code>

<p>The above will make any list item within an unordered list bold. This type of selector, where the style is applies to a specific descendant of an element within the code, will be supported by most browsers with any CSS support, the notable exception being Netscape Navigator 4, which does not understand descendant selectors.</p>

<p>Selectors can be combined as well. For example, if you wanted to apply a style to links within an unordered list, and make one stand out, the following CSS and HTML would do the job admirably:</p>

<code>&lt;html&gt;
    &lt;head&gt;
        &lt;style type="text/css"&gt;&lt;!--

            ul a {
                color: #f00;
            }

            ul #unique {
                font-weight: bold;
            }

        --&gt;&lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;

        &lt;ul&gt;

            &lt;li&gt;
                &lt;a&gt;First link&lt;/a&gt;
            &lt;/li&gt;

            &lt;li&gt;
                &lt;a&gt;Second link&lt;/a&gt;
            &lt;/li&gt;

            &lt;li&gt;
                &lt;a id="unique"&gt;Unique link&lt;/a&gt;
            &lt;/li&gt;

        &lt;/ul&gt;

    &lt;/body&gt;
&lt;/html&gt;</code>

<p>The above will set all links within the list to red, then the link with the id "unique" to bold.</p>

<p>And there you have the basic CSS selectors. Beleive it or not, the simple rules above, when combined (and together with a few creative styles) can create amazing looks for sites with just a few lines of code.</p> <br><br>]]></description>
				<pubDate>Mon, 17 May 2004 13:05:58 +0100</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/articles/for-beginners/css-selectors-for-beginners/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=for+beginners&amp;start=0" class="ditto_tag" rel="tag">for beginners</a>,<a href="/feeds/tag-feed/?tags=selectors&amp;start=0" class="ditto_tag" rel="tag">selectors</a>,<a href="/feeds/tag-feed/?tags=tutorial&amp;start=0" class="ditto_tag" rel="tag">tutorial</a>
			</item>

			<item>
				<title>Printer Friendly Pages for Beginners</title>
				<link>http://www.addedbytes.com/articles/for-beginners/printer-friendly-pages/</link>
				<description><![CDATA[ Most designers create printer friendly pages by creating two seperate pages for each single page of information. This article will teach you how to do the same with CSS and no duplication. <p>CSS is a great new tool for web designers. Now it is more widely supported, and browser-makers are sticking to the W3C standards, we can begin to explore the possibilities it has offered us since the 90s but that we could not make use of.</p>

<p>CSS allows you to seperate your design from your markup, making maintenance infinitely easier, and your site more likely to work in different devices, both of which are definite pluses. It also, however, allows you to tell a page to display a different way depending upon what device is being used to render it.</p>

<p>This is achieved using the "media" attribute of the "&lt;link&gt;" or "&lt;style&gt;" tags, like so:</p>

<code>&lt;link media="screen" href="style.css" type="text/css"&gt;</code>

<code>&lt;style media="screen" type="text/css"&gt;</code>

<p>There are several media types available to you - [i]all, aural, braille, handheld, print, projection, screen, tty, tv[/i] - and a [url=http://www.w3.org/TR/1998/PR-CSS2-19980324/media.html#media-types]list of available media types with more detail[/url] is available from W3C (where you can find out more about media groups, as well).</p>

<p>With such a range of options, you can, if you like, create one HTML document that will display exactly as you like depending entirely upon which device is being used to view it. You can hide large images from PDAs, you can specify seperate font styling for overhead  projectors - you can write your site so that it works well with the technology at the user's disposal. And one very useful side effect of this is that you can specify an entire print style without the need for copies of every page of your content, like the following, that will use the "normal.css" style sheet for screens, and the "printer.css" style sheet when printing.</p>

<code>&lt;link media="screen" href="normal.css" type="text/css"&gt;
&lt;link media="print" href="printer.css" type="text/css"&gt;</code>

<p>For print styling, there are a lot of factors to consider. Are many users going to want to print out your header? No. But do you want your logo on the page? Yes. Is the navigation worth printing? No. Each item on a web page serves a purpose, and on paper, that may not be worth much.</p>

<p>It is best, then, to start at the beginning. With an unstyled HTML document. Pick a page to start working on, and remove all styles from it. With an unformatted page in front of you, it should be pretty easy to see what needs styling and how, but don't rush in. There's a lot to think about.</p>

<h3>Fonts</h3>

<p>Fonts are very different on the web to print. Sans-serif fonts are, allegedly, the best to use on the web. Serif fonts are, apparently, better on paper. So first things first, set your font to a serif font you like (personally, I like Georgia for Windows). As with picking all fonts, make sure you provide alternatives for those without the first-choice font.</p>

<p>Font sizing is a bit different on paper too. It's usually best just to leave this to the default, but if you want to specify a font, make sure you run plenty of tests to make sure it's easily legible.</p>

<code>* {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 12pt;
}</code>

<h3>Links</h3>

<p>Links are not going to be a lot of use on paper, by their very nature. But that does not make them useless.</p>

<code>a {
    color:#000000;
    text-decoration: underline;
}

a:after {
    content: " ( "attr(href)" )";
}</code>

<p>The above, if added to a printer style sheet, will make all links black and underlined, and add the address of the link in brackets afterwards, meaning that if a user did want to visit any site linked to from that page at a later date, they can.</p>

<h3>Spacing</h3>

<p>In print, margins and spacings are as important as with the web. There is no harm in adding in a little space between words and lines, and a decent gap around the edges, if it will make a print-version easier to read.</p>

<code>body {
    padding: 10%;
    line-height: 1.2;
    word-spacing: 1px;
}</code>

<h3>Hide Useless Stuff</h3>

<p>You can hide elements in this style sheet easily enough, using display none. This will save some space on the paper, and reduce useless junk on the page, something the user will be very grateful for. Elements worth hiding are usually form elements, some images, marquees, and flash content. If you are unsure, print the page and then work through that page deciding what is useful and what is not.</p>

<code>.navigation {
    display: none;
}</code>

<h3>Colours</h3>

<p>Print colours will show up very differently to screen colours, especially as a high proportion still have black and white printers. Even those who don't will be grateful to you if you keep the proportion of colour to a minimum, simply because of the expense.</p>

<p>Highlight and emphasize things using italics, underlining, boldness and size in your print style sheet. Remove all references to colours where you can, save to set colours to black.</p>

<h3>Page Address</h3>

<p>You may want to add the address of the page itself to the page, and hide it, except when the page is printed, so that the user can return to your page later if they wish.</p>

<h3>Tell the User</h3>

<p>A user may see a page without a "printer friendly" link and print anyway, but they may be put off. Try and add a note to your page explaining that the page they are now viewing is printer friendly, and encouraging them to print it.</p>

<h3>Finally</h3>

<p>Do plenty of testing and reading. The print industry has been around a very very long time, and there are plenty of resources around for you to research what makes a document easy to read on paper as opposed to screen - make use of them. The more you test, too, the more likely you will be to notice small flaws in the print version of your site, in the same way that looking at your site during the design process highlights tiny imperfections that make all the difference once fixed.</p>

<p>Wish these simple measures, you should now be able to create an alternative version of your entire site, that will be invisible to the user until they actually print a page. They do not need to do anything bar click the print button.</p> <br><br>]]></description>
				<pubDate>Mon, 15 Mar 2004 18:30:00 +0000</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/articles/for-beginners/printer-friendly-pages/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=css&amp;start=0" class="ditto_tag" rel="tag">css</a>,<a href="/feeds/tag-feed/?tags=design&amp;start=0" class="ditto_tag" rel="tag">design</a>,<a href="/feeds/tag-feed/?tags=for+beginners&amp;start=0" class="ditto_tag" rel="tag">for beginners</a>,<a href="/feeds/tag-feed/?tags=printing&amp;start=0" class="ditto_tag" rel="tag">printing</a>,<a href="/feeds/tag-feed/?tags=web&amp;start=0" class="ditto_tag" rel="tag">web</a>,<a href="/feeds/tag-feed/?tags=webdesign&amp;start=0" class="ditto_tag" rel="tag">webdesign</a>,<a href="/feeds/tag-feed/?tags=xhtml&amp;start=0" class="ditto_tag" rel="tag">xhtml</a>
			</item>
	</channel>
</rss>