<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Gravityeffect's Weblog</title>
	<atom:link href="http://gravityeffect.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gravityeffect.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sun, 10 Aug 2008 16:19:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gravityeffect.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Gravityeffect's Weblog</title>
		<link>http://gravityeffect.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gravityeffect.wordpress.com/osd.xml" title="Gravityeffect&#039;s Weblog" />
	<atom:link rel='hub' href='http://gravityeffect.wordpress.com/?pushpress=hub'/>
		<item>
		<title>CSS and round corners: Boxes with curves</title>
		<link>http://gravityeffect.wordpress.com/2008/08/10/css-and-round-corners-boxes-with-curves/</link>
		<comments>http://gravityeffect.wordpress.com/2008/08/10/css-and-round-corners-boxes-with-curves/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:19:42 +0000</pubDate>
		<dc:creator>gravityeffect</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://gravityeffect.wordpress.com/?p=22</guid>
		<description><![CDATA[One of the main reasons for having to use images on any web page is to create curves and round corners. It&#8217;s currently impossible to create any kind of curved shapes using just HTML, so images need to be used. Putting these images into the HTML document with a table layout can create a large [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=22&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the main reasons for having to use images on any web page is to create curves and round corners. It&#8217;s currently impossible to create any kind of curved shapes using just <acronym title="Hypertext Markup Language">HTML</acronym>, so images need to be used. Putting these images into the <acronym title="Hypertext Markup Language">HTML</acronym> document with a table layout can create a large amount of superfluous code.</p>
<p>Using the power of <acronym title="Cascading Stylesheets">CSS</acronym> we&#8217;ll create the following box with round corners, <strong>without an <code>&lt;img&gt;</code> tag in sight</strong>:</p>
<div class="bl3">
<div class="br">
<div class="tl">
<div class="tr2">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
<div class="tr2">
<h2>How it works</h2>
<p>The above box is basically a normal box with an orange background colour and four corner images superimposed on top. All these images have been called up through <acronym title="Cascading Stylesheets">CSS</acronym> commands. So, we start off with:</p>
<p><code>&lt;div class="bl"&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit&lt;/div&gt;</code></p>
<p>We&#8217;ve used <code>class="bl"</code> as we&#8217;re going to assign our bottom left corner to this <code>&lt;div&gt;</code> through a <acronym title="Cascading Stylesheets">CSS</acronym> command. As a rule, <strong>you can only assign one background image to an <acronym title="Hypertext Markup Language">HTML</acronym> tag</strong> with <acronym title="Cascading Stylesheets">CSS</acronym>, so this is the only image we&#8217;ll assign to this <code>&lt;div&gt;</code>. We&#8217;ll use this image <img src="http://www.webcredible.co.uk/i/bl.gif" alt="Bottom-left curve" /> and call it bl.gif, and then place it in the bottom-left corner with this <acronym title="Cascading Stylesheets">CSS</acronym> command:</p>
<p><code>.bl {background: url(bl.gif) 0 100% no-repeat; width: 20em}</code></p>
<p>The <acronym title="Cascading Stylesheets">CSS</acronym> background command is broken up into three sections: the image <acronym title="Uniform Resource Locator">URL</acronym>, its position, and a repeat command. We also inserted a width <acronym title="Cascading Stylesheets">CSS</acronym> command so the box doesn&#8217;t cover the whole width of the screen. Let&#8217;s examine the <strong>three background commands</strong> in turn:</p>
<ol>
<li><strong>Image <acronym title="Uniform Resource Locator">URL</acronym></strong> &#8211; Remember, the image is being called up through the <acronym title="Cascading Stylesheets">CSS</acronym> so the path to the image is from the <acronym title="Cascading Stylesheets">CSS</acronym> document and not the <acronym title="Hypertext Markup Language">HTML</acronym> document.</li>
<li><strong>Image position</strong> &#8211; In this example, we&#8217;ve used the command <code>0 100%</code> in our <acronym title="Cascading Stylesheets">CSS</acronym> rule. The first number represents the distance from the left edge of the <code>&lt;div&gt;</code> and the second number the distance from the top edge. In this instance % was used, but a different distance value such as em or px could have been used instead. If this command was left out then the default value, <code>0 0</code> would be used and the image would be placed in the top-left corner.</li>
<li><strong>Repeat command</strong> &#8211; Obviously we don&#8217;t want this image to repeat, so we inserted the <code>no-repeat</code> <acronym title="Cascading Stylesheets">CSS</acronym> command. If we wanted to, we could have used <code>repeat-x</code>, to repeat the image horizontally, <code>repeat-y</code>, to repeat it vertically, and <code>repeat</code> to repeat it both horizontally and vertically. If this command was left out then the default value, <code>repeat</code> would be used.</li>
</ol>
<p>It <strong>doesn&#8217;t matter in which order these three <acronym title="Cascading Stylesheets">CSS</acronym> background commands are placed</strong>. Our box with curves now looks like:</p>
<div class="bl">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
<h2>Bottom right curve</h2>
<p>Next, we&#8217;ll stick in that bottom-right curve. As previously mentioned, we can only assign one background image to each <code>&lt;div&gt;</code> in the <acronym title="Cascading Stylesheets">CSS</acronym> so we&#8217;ll need to insert a new <code>&lt;div&gt;</code>:</p>
<p><code> &lt;div class="bl"&gt;<strong>&lt;div class="br"&gt;</strong><br />
Lorem ipsum dolor sit amet consectetur adipisicing elit<br />
<strong>&lt;/div&gt;</strong>&lt;/div&gt; </code></p>
<p>Naming our bottom-right image (<img src="http://www.webcredible.co.uk/i/br.gif" alt="Bottom-right curve" />), br.gif, we&#8217;ll insert a new <acronym title="Cascading Stylesheets">CSS</acronym> rule:</p>
<p><code>.br {background: url(br.gif) 100% 100% no-repeat}</code></p>
<p>This <acronym title="Cascading Stylesheets">CSS</acronym> rule is essentially the same as our last one, but now we&#8217;ve changed the position from the left to 100%, where previously it was 0%. Our box now looks like:</p>
<div class="bl">
<div class="br">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
</div>
<div class="br"></div>
<div class="br">
<h2>Top curves</h2>
<p>To make our top curves we&#8217;ll need two new images, <img src="http://www.webcredible.co.uk/i/tl.gif" alt="Top-left curve" /> and <img src="http://www.webcredible.co.uk/i/tr.gif" alt="Top-right curve" />, which we&#8217;ll call tl.gif and tr.gif. We&#8217;ll then need to create <strong>two new <code>&lt;div&gt;</code>s</strong> for them:</p>
<p><code> &lt;div class="bl"&gt;&lt;div class="br"&gt;<strong>&lt;div class="tl"&gt;&lt;div class="tr"&gt;</strong><br />
Lorem ipsum dolor sit amet consectetur adipisicing elit<br />
<strong>&lt;/div&gt;&lt;/div&gt;</strong>&lt;/div&gt;&lt;/div&gt; </code></p>
<p>And our new <acronym title="Cascading Stylesheets">CSS</acronym> rules:</p>
<p><code> .tl {background: url(tl.gif) 0 0 no-repeat}<br />
.tr {background: url(tr.gif) 100% 0 no-repeat} </code></p>
<p>Giving us:</p>
<div class="bl">
<div class="br">
<div class="tl">
<div class="tr">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
</div>
</div>
</div>
<h2>Background colour</h2>
<p>We&#8217;ll now insert our orange background colour into the box, so as to achieve the whole round corners effects. The <strong>background colour must always be assigned to the very first <acronym title="Cascading Stylesheets">CSS</acronym> rule</strong>. This is because each <acronym title="Cascading Stylesheets">CSS</acronym> background rule is essentially a layer on top of the previous one. So, in this example we have a layering order of br.gif, bl.gif, tl.gif and then tr.gif. In this example the images don&#8217;t overlap so we don&#8217;t really notice this layering effect.</p>
<p>A background colour by default covers the entire <code>&lt;div&gt;</code> and will layer on top of any other previously assigned background images and/or colours. Therefore, if we place the orange colour in any <code>&lt;div&gt;</code> other than the first it will be placed on top of the preceding images and will essentially cause them to disappear. Therefore, we must place our orange background colour (#e68200) in the very first <acronym title="Cascading Stylesheets">CSS</acronym> rule:</p>
<p><code>.bl {background: url(bl.gif) 0 100% no-repeat <strong>#e68200;</strong> width: 20em}</code></p>
<p>As before, it doesn&#8217;t matter where we place this colour command within the <acronym title="Cascading Stylesheets">CSS</acronym> background rule. Our box now looks like:</p>
<div class="bl3">
<div class="br">
<div class="tl">
<div class="tr">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
</div>
</div>
</div>
<h2>Padding</h2>
<p>Padding is needed to prevent the text from overlapping on to the images, which are 10px by 10px in size. Therefore we need 10px worth of padding on the text. But to which <code>&lt;div&gt;</code> should we assign the padding <acronym title="Cascading Stylesheets">CSS</acronym> rule? Does it matter? Well, yes it does. Whichever element we assign padding to, each of the <strong>inside elements will inherit that padding</strong>. If we were to assign padding to the very first <code>&lt;div&gt;</code>, <code>&lt;div class=""bl"&gt;</code>, we&#8217;d get the following:</p>
<div class="bl2">
<div class="br">
<div class="tl">
<div class="tr">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
</div>
</div>
</div>
<p>To get this padding working properly, we need to assign it to the very last <code>&lt;div&gt;</code>, <code>&lt;div class="bl"&gt;</code>:</p>
<p><code>.tr {background: url(tr.gif) 100% 0 no-repeat; <strong>padding:10px</strong>}</code></p>
<div class="bl3">
<div class="br">
<div class="tl">
<div class="tr2">Lorem ipsum dolor sit amet consectetur adipisicing elit</div>
</div>
</div>
</div>
<h2>Internet Explorer issues</h2>
<p>You may have noticed the bottom corners were called up before the top two corners. If we were to do this the other way round, that is call up the top corners first, some parts of the orange background colour sneak out under the bottom curves causing a rather unsightly effect. Switch the order of the <code>&lt;div&gt;</code>s around and see for yourself.</p>
<p>Another issue in Internet Explorer is that the background colour of the box sometimes overlap on to the element below, again causing a highly unsightly effect. This can be simply solved by <strong>placing a tiny placeholder beneath our box</strong> with round corners. Immediately after the fourth closing <code>&lt;/div&gt;</code>, insert the following <acronym title="Hypertext Markup Language">HTML</acronym>:</p>
<p><code>&lt;div class="clear"&gt;&amp;nbsp;&lt;/div&gt;</code></p>
<p>And assign it this <acronym title="Cascading Stylesheets">CSS</acronym> rule:</p>
<p><code>.clear {font-size: 1px; height: 1px}</code></p>
<h2>The final code</h2>
<p>Our finished <acronym title="Hypertext Markup Language">HTML</acronym> now looks like:</p>
<p><code>&lt;div class="bl"&gt;&lt;div class="br"&gt;&lt;div class="tl"&gt;&lt;div class="tr"&gt;<br />
Lorem ipsum dolor sit amet consectetur adipisicing elit<br />
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;<br />
&lt;div class="clear"&gt;&amp;nbsp;&lt;/div&gt;</code></p>
<p>And the <acronym title="Cascading Stylesheets">CSS</acronym> that makes it all happen:</p>
<p><code> .bl {background: url(bl.gif) 0 100% no-repeat #e68200; width: 20em}<br />
.br {background: url(br.gif) 100% 100% no-repeat}<br />
.tl {background: url(tl.gif) 0 0 no-repeat}<br />
.tr {background: url(tr.gif) 100% 0 no-repeat; padding:10px}<br />
.clear {font-size: 1px; height: 1px} </code></p>
<div id="credit">
<p>This article was written by Trenton Moss. Trenton&#8217;s crazy about web usability and accessibility &#8211; so crazy that he founded Webcredible, an industry-leading <a href="http://www.webcredible.co.uk/">user experience consultancy</a><sup class="printOnly">8</sup>, helping to make the Internet a better place for everyone. He&#8217;s very good at running <a href="http://www.webcredible.co.uk/services/css-training-fund.shtml"><acronym title="Cascading Stylesheets">CSS</acronym> training</a><sup class="printOnly">6</sup> and spends much of his time working on the world&#8217;s most <a href="http://www.webcredible.co.uk/services/accessible-cms.shtml">accessible <acronym title="Content management system">CMS</acronym></a><sup class="printOnly">9</sup>.</div>
</div>
</div>
</div>
</div>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gravityeffect.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gravityeffect.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gravityeffect.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gravityeffect.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gravityeffect.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gravityeffect.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gravityeffect.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gravityeffect.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gravityeffect.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gravityeffect.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=22&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gravityeffect.wordpress.com/2008/08/10/css-and-round-corners-boxes-with-curves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a1b1b4c9bee44fe06b17fc55492bc4c0?s=96&#38;d=identicon" medium="image">
			<media:title type="html">gravityeffect</media:title>
		</media:content>

		<media:content url="http://www.webcredible.co.uk/i/bl.gif" medium="image">
			<media:title type="html">Bottom-left curve</media:title>
		</media:content>

		<media:content url="http://www.webcredible.co.uk/i/br.gif" medium="image">
			<media:title type="html">Bottom-right curve</media:title>
		</media:content>

		<media:content url="http://www.webcredible.co.uk/i/tl.gif" medium="image">
			<media:title type="html">Top-left curve</media:title>
		</media:content>

		<media:content url="http://www.webcredible.co.uk/i/tr.gif" medium="image">
			<media:title type="html">Top-right curve</media:title>
		</media:content>
	</item>
		<item>
		<title>CSS hacks &amp; browser detection</title>
		<link>http://gravityeffect.wordpress.com/2008/08/10/css-hacks-browser-detection/</link>
		<comments>http://gravityeffect.wordpress.com/2008/08/10/css-hacks-browser-detection/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:16:38 +0000</pubDate>
		<dc:creator>gravityeffect</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://gravityeffect.wordpress.com/?p=19</guid>
		<description><![CDATA[More and more web developers are ditching tables and coming round to the idea of using CSS to control the layout of their site. With the many benefits of using CSS, such as quicker download time, improved accessibility and easier site management, why not? The problem with CSS Historically the main problem with using CSS [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=19&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>More and more web developers are ditching tables and coming round to the idea of using <acronym title="Cascading Stylesheets">CSS</acronym> to control the layout of their site. With the many benefits of using <acronym title="Cascading Stylesheets">CSS</acronym>, such as quicker download time, improved accessibility and easier site management, why not?</p>
<h2>The problem with <acronym title="Cascading Stylesheets">CSS</acronym></h2>
<p>Historically the main problem with using <acronym title="Cascading Stylesheets">CSS</acronym> has been lack of browser support. This is no longer the case as version 5 browsers, which all have good support for <acronym title="Cascading Stylesheets">CSS</acronym>, now account for over 99% of browsers in use.</p>
<p>Instead, the problem is that <strong>browsers can sometimes interpret <acronym title="Cascading Stylesheets">CSS</acronym> commands in different ways</strong>, causing developers to throw their arms up in the air and switch back to pixel-perfect table layouts. Fear not though, as you learn more about <acronym title="Cascading Stylesheets">CSS</acronym> you&#8217;ll gradually start to understand the different browser interpretations and realise that there aren&#8217;t really that many.</p>
<h2>How browser detection using <acronym title="Cascading Stylesheets">CSS</acronym> hacks works</h2>
<p>The way browser detection using <acronym title="Cascading Stylesheets">CSS</acronym> hacks works is to send one <acronym title="Cascading Stylesheets">CSS</acronym> rule to the browser(s) you&#8217;re trying to trick, and then send a second <acronym title="Cascading Stylesheets">CSS</acronym> rule to the other browsers, overriding this first command. If you have two <acronym title="Cascading Stylesheets">CSS</acronym> rules with identical selectors then <strong>the second <acronym title="Cascading Stylesheets">CSS</acronym> rule will always take precedence</strong>.</p>
<p>Say for example you wanted the space between your header area and the content to have a gap of 25px in Internet Explorer, or <acronym title="Internet Explorer">IE</acronym> as it&#8217;s affectionately known. This gap looks good in <acronym title="Internet Explorer">IE</acronym> but in Firefox, Opera and Safari the gap is huge and a 10px gap looks far better. To achieve this <strong>perfect look in all these browsers</strong> you would need the following two <acronym title="Cascading Stylesheets">CSS</acronym> rules:</p>
<p><code> #header {margin-bottom: 25px;}<br />
#header {margin-bottom: 10px;} </code></p>
<p>The <strong>first command is intended for <acronym title="Internet Explorer">IE</acronym>, the second for all other browsers</strong>. How does this work? Well, it won&#8217;t at the moment because <em>all</em> browsers can understand <em>both</em> <acronym title="Cascading Stylesheets">CSS</acronym> rules so will use the second <acronym title="Cascading Stylesheets">CSS</acronym> rule because it comes after the first one.</p>
<p>By inserting a <acronym title="Cascading Stylesheets">CSS</acronym> hack we can perform our browser detection by hiding the second <acronym title="Cascading Stylesheets">CSS</acronym> rule from <acronym title="Internet Explorer">IE</acronym>. This means that <acronym title="Internet Explorer">IE</acronym> won&#8217;t even know it exists and will therefore use the first <acronym title="Cascading Stylesheets">CSS</acronym> rule. How do we do this? Read on and find out!</p>
<h2>Browser detection for Internet Explorer</h2>
<p>To send different <acronym title="Cascading Stylesheets">CSS</acronym> rules to <acronym title="Internet Explorer">IE</acronym>, we can use the <strong>child selector command</strong> which <acronym title="Internet Explorer">IE</acronym> can&#8217;t understand. The child selector command involves two elements, one of which is the child of the other. So, <code>html&gt;body</code> refers to the child, <code>body</code>, contained within the parent, <code>html</code>.</p>
<p>Using the example of the header margin, our <acronym title="Cascading Stylesheets">CSS</acronym> command would be:</p>
<p><code> #header {margin-bottom: 3em;}<br />
<strong>html&gt;body</strong> #header {margin-bottom: 1em;} </code></p>
<p><acronym title="Internet Explorer">IE</acronym> can&#8217;t understand the second <acronym title="Cascading Stylesheets">CSS</acronym> rule due to the <code>html&gt;body</code> <acronym title="Cascading Stylesheets">CSS</acronym> command so will ignore it and use the first rule. All other browsers will use the second rule.</p>
<h2>Browser detection for Internet Explorer 5</h2>
<p>It may seem strange at first to send different <acronym title="Cascading Stylesheets">CSS</acronym> rules to different versions of a browser, but in the case of <acronym title="Internet Explorer">IE</acronym>5 it&#8217;s very necessary. This is due to <acronym title="Internet Explorer">IE</acronym>5&#8242;s misinterpretation of the box model. When specifying the width of an element in <acronym title="Cascading Stylesheets">CSS</acronym>, padding and borders aren&#8217;t included in this value. <acronym title="Internet Explorer">IE</acronym>5 however, incoporates these values into the width value causing <strong>element widths to become smaller in this browser</strong>.</p>
<p>The following <acronym title="Cascading Stylesheets">CSS</acronym> rule would result in a width of 10em for all browsers, except <acronym title="Internet Explorer">IE</acronym>5 which would give it a width of just 5em (<acronym title="Internet Explorer">IE</acronym>5 would incorporate two sets of padding and border, on both the left and right, when calculating the width):</p>
<p><code>#header {padding: 2em; border: 0.5em; width: 10em;}</code></p>
<p>The <strong>solution to this problem</strong>? Perform browser detection and send a different <acronym title="Cascading Stylesheets">CSS</acronym> rule to <acronym title="Internet Explorer">IE</acronym>5:</p>
<p><code> #header {padding: 2em; border: 0.5em; <strong>width: 15em; width/**/:/**/ 10em;</strong>} </code></p>
<p><acronym title="Internet Explorer">IE</acronym>5 will use the first width value of 15em, 5em of which will be taken up by the two sets of padding and border (one each for the left and for the right). This would ultimately give the element a width of 10em in <acronym title="Internet Explorer">IE</acronym>5.</p>
<p>The 15em value will then be <strong>overridden by the second width value of 10em by all browsers except <acronym title="Internet Explorer">IE</acronym>5</strong>, which for some reason can&#8217;t understand <acronym title="Cascading Stylesheets">CSS</acronym> commands with empty comment tags either side of the colons. It doesn&#8217;t look pretty but it does work!</p>
<h2>Browser detection for Internet Explorer on the Mac</h2>
<p>Quite simply, <acronym title="Internet Explorer">IE</acronym> on the Mac does strange things with <acronym title="Cascading Stylesheets">CSS</acronym>. The browser&#8217;s become somewhat obsolete as Microsoft aren&#8217;t going to be bringing out an updated version. As such, many web developers code their <acronym title="Cascading Stylesheets">CSS</acronym>-driven sites so that the site works in <acronym title="Internet Explorer">IE</acronym>/Mac, although it <strong>may not offer the same level of advanced functionality or design</strong>. Provided <acronym title="Internet Explorer">IE</acronym>/Mac users can access all areas of the site this is seen as a suitable way of doing things.</p>
<p>To hide a command using the <a href="http://www.sam-i-am.com/work/sandbox/css/mac_ie5_hack.html"><acronym title="Internet Explorer">IE</acronym>/Mac <acronym title="Cascading Stylesheets">CSS</acronym> hack</a><sup class="printOnly">2</sup> is simple, and involves wrapping a set of dashes and stars around as many <acronym title="Cascading Stylesheets">CSS</acronym> rules as you like:</p>
<p><code> <strong>/* Hide from IE-Mac \*/</strong><br />
#header {margin-bottom: 3em;}<br />
#footer {margin-top: 1.5em;}<br />
/* End hide */ </code></p>
<p><acronym title="Internet Explorer">IE</acronym>/Mac will simply ignore all these commands. This <acronym title="Cascading Stylesheets">CSS</acronym> hack can actually be quite useful if there&#8217;s a certain area of the site not working properly in <acronym title="Internet Explorer">IE</acronym>/Mac. If that section isn&#8217;t fundamental to being able to use the site, you can simply hide it from <acronym title="Internet Explorer">IE</acronym>/Mac like so:</p>
<p><code> #noiemac {display: none}</p>
<p>/* Hide from IE-Mac \*/<br />
#noiemac {display: block;}<br />
/* End hide */ </code></p>
<p>The first <acronym title="Cascading Stylesheets">CSS</acronym> rule hides the entire section assigned the noiemac id (i.e. <code>&lt;div id="noiemac"&gt;</code>). The second <acronym title="Cascading Stylesheets">CSS</acronym> rule, which <acronym title="Internet Explorer">IE</acronym>/Mac can&#8217;t see, displays this section.</p>
<h2>Browser detection for <acronym title="Internet Explorer">IE</acronym> 4 and Netscape 4</h2>
<p>Version 4 browsers have limited and somewhat erratic support for <acronym title="Cascading Stylesheets">CSS</acronym>. Making a <acronym title="Cascading Stylesheets">CSS</acronym> layout in these browsers, whose market share has now slipped well below 1%, can be extremely challenging. It&#8217;s become common practice nowadays to completely hide the <acronym title="Cascading Stylesheets">CSS</acronym> file from version 4 and earlier browsers. This can be achieved using the @import directive to call up the <acronym title="Cascading Stylesheets">CSS</acronym> document:</p>
<p><code>&lt;style type="text/css"&gt;@import "styles.css";&lt;/style&gt;</code></p>
<p><strong>Version 4 (and earlier) browsers will display a non-styled version of the site</strong> as they can&#8217;t understand this @import directive.</p>
<h2>Checking your site in the different browsers</h2>
<p>At the time of writing, the major Internet browsers include <acronym title="Internet Explorer">IE</acronym>5, <acronym title="Internet Explorer">IE</acronym>6, Firefox, Opera and Safari. (Check out <a href="http://www.thecounter.com/stats/">TheCounter.com</a><sup class="printOnly">3</sup> for up-to-date browser statistics.) You can download all these browsers, and a number of more obscure ones, at the <a href="http://browsers.evolt.org/">Evolt browser archive</a><sup class="printOnly">4</sup>.</p>
<p>Ideally you should check your site in all these browsers, on <strong>both <acronym title="Personal Computer">PC</acronym> and Mac</strong> (except <acronym title="Internet Explorer">IE</acronym>6 and Safari, which are only available on <acronym title="Personal Computer">PC</acronym> and Mac respectively). If you don&#8217;t have access to a Mac you can get a screenshot of your site on Safari by running it through Dan Vine&#8217;s <a href="http://www.danvine.com/icapture/">iCapture</a><sup class="printOnly">5</sup> or you can pay to use <a href="http://www.browsercam.com/">Browsercam</a><sup class="printOnly">6</sup> which offers a more extensive screen capturing service.</p>
<h2>Conclusion</h2>
<p>On the whole, modern browsers have very good support for <acronym title="Cascading Stylesheets">CSS</acronym> &#8211; certainly good enough for you to be using <acronym title="Cascading Stylesheets">CSS</acronym> to control layout and presentation. Sometimes however, certain page elements will appear differently in different browsers. Don&#8217;t worry too much if you don&#8217;t know the reason why &#8211; if you can fix it up with these <acronym title="Cascading Stylesheets">CSS</acronym> hacks then your web pages should look great across all browsers!</p>
<div id="credit">
<p>This article was written by Trenton Moss. Trenton&#8217;s crazy about web usability and accessibility &#8211; so crazy that he founded Webcredible, an industry-leading <a href="http://www.webcredible.co.uk/">user experience consultancy</a><sup class="printOnly">7</sup>, helping to make the Internet a better place for everyone. He&#8217;s very good at running <a href="http://www.webcredible.co.uk/services/css-training-fund.shtml"><acronym title="Cascading Stylesheets">CSS</acronym> training</a><sup class="printOnly">8</sup> and spends much of his time working on the world&#8217;s most <a href="http://www.webcredible.co.uk/services/accessible-cms.shtml">accessible <acronym title="Content management system">CMS</acronym></a><sup class="printOnly">9</sup>.</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gravityeffect.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gravityeffect.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gravityeffect.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gravityeffect.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gravityeffect.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gravityeffect.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gravityeffect.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gravityeffect.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gravityeffect.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gravityeffect.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=19&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gravityeffect.wordpress.com/2008/08/10/css-hacks-browser-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a1b1b4c9bee44fe06b17fc55492bc4c0?s=96&#38;d=identicon" medium="image">
			<media:title type="html">gravityeffect</media:title>
		</media:content>
	</item>
		<item>
		<title>Ten more CSS tricks you may not know</title>
		<link>http://gravityeffect.wordpress.com/2008/08/10/ten-more-css-tricks-you-may-not-know/</link>
		<comments>http://gravityeffect.wordpress.com/2008/08/10/ten-more-css-tricks-you-may-not-know/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:13:33 +0000</pubDate>
		<dc:creator>gravityeffect</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://gravityeffect.wordpress.com/?p=16</guid>
		<description><![CDATA[1. Block vs. inline level elements Our article, Ten CSS tricks you may not know1 has proven to be such a success that we decided it was time to offer you ten more CSS tricks that you may not know. Nearly all HTML elements are either block or inline elements. The characteristics of block elements [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=16&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>1. Block vs. inline level elements</h2>
<p>Our article, Ten CSS tricks you may not know1 has proven to be such a success that we decided it was time to offer you ten more CSS tricks that you may not know.</p>
<p>Nearly all <acronym title="Hypertext Markup Language">HTML</acronym> elements are either block or inline elements. The <strong>characteristics of block elements</strong> include:</p>
<ul>
<li>Always begin on a new line</li>
<li>Height, line-height and top and bottom margins can be manipulated</li>
<li>Width defaults to 100% of their containing element, unless a width is specified</li>
</ul>
<p>Examples of block elements include <code>&lt;div&gt;</code>, <code>&lt;p&gt;</code>, <code>&lt;h1&gt;</code>, <code>&lt;form&gt;</code>, <code>&lt;ul&gt;</code> and <code>&lt;li&gt;</code>. <strong>Inline elements</strong> on the other hand have the <strong>opposite characteristics</strong>:</p>
<ul>
<li>Begin on the same line</li>
<li>Height, line-height and top and bottom margins can&#8217;t be changed</li>
<li>Width is as long as the text/image and can&#8217;t be manipulated</li>
</ul>
<p>Examples of inline elements include <code>&lt;span&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;label&gt;</code>, <code>&lt;input&gt;</code>, <code>&lt;img&gt;</code>, <code>&lt;strong&gt;</code> and <code>&lt;em&gt;</code>.</p>
<p>To change an element&#8217;s status you can use <code>display: inline</code> or <code>display: block</code>. But what&#8217;s the point of changing an element from being block to inline, or vice-versa? Well, at first it may seem like you might hardly ever use this, but in actual fact this is a very powerful technique, which you can use any time you want to:</p>
<ul>
<li>Have an inline element start on a new line</li>
<li>Have a block element start on the same line</li>
<li>Control the width of an inline element (particularly useful for navigation links)</li>
<li>Manipulate the height of an inline element</li>
<li>Set a background colour as wide as the text for block elements, without having to specify a width</li>
</ul>
<h2>2. Another box model hack alternative</h2>
<p>The <a href="http://tantek.com/CSS/Examples/boxmodelhack.html">box model hack</a><sup class="printOnly">2</sup> is used to fix a rendering problem in pre-<acronym title="Internet Explorer">IE</acronym> 6 browsers on <acronym title="Personal Computer">PC</acronym>, where by the border and padding are <em>included</em> in the width of an element, as opposed to <em>added on</em>. A number of <acronym title="Cascading Stylesheets">CSS</acronym>-based solutions have been put forward to remedy this, so here&#8217;s another one which we really like:</p>
<p><code>padding: 2em;<br />
border: 1em solid green;<br />
width: 20em;<br />
width/**/:/**/ 14em; </code></p>
<p>The first width command is read by all browsers; the second by all browsers <em>except</em> <acronym title="Internet Explorer">IE</acronym>5.x on <acronym title="Personal Computer">PC</acronym>. Because the <strong>second command comes second it takes precedence over the first</strong> &#8211; any command that comes second will always override a preceding command. So, how does all this work?</p>
<p>By placing empty comment tags (/**/) before the colons, <acronym title="Internet Explorer">IE</acronym>5.0 will ignore the command. Likewise, by placing these empty comment tags after the colon, <acronym title="Internet Explorer">IE</acronym>5.5 will ignore the command. By using these two rules in conjunction with each other, we can hide the command from all of <acronym title="Internet Explorer">IE</acronym>5.x.</p>
<h2>3. Minimum width for a page</h2>
<p>A very handy <acronym title="Cascading Stylesheets">CSS</acronym> command that exists is the <code>min-width</code> command, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page.</p>
<p>Unfortunately, <acronym title="Internet Explorer">IE</acronym> doesn&#8217;t understand this command, so we&#8217;ll need to come up with a new way of making this work in this browser. First, we&#8217;ll insert a <code>&lt;div&gt;</code> under the <code>&lt;body&gt;</code> tag, as we <strong>can&#8217;t assign a minimum width to the <code>&lt;body&gt;</code></strong>:</p>
<p><code> &lt;body&gt;<br />
&lt;div id="container"&gt; </code></p>
<p>Next we create our <acronym title="Cascading Stylesheets">CSS</acronym> commands, so as to create a minimum width of 600px:</p>
<p><code> #container<br />
{<br />
min-width: 600px;<br />
width:expression(document.body.clientWidth &lt; 600? "600px": "auto" );<br />
} </code></p>
<p>The first command is the regular minimum width command; the second is a short JavaScript command that only <acronym title="Internet Explorer">IE</acronym> understands. Do note though, this command will cause your <acronym title="Cascading Stylesheets">CSS</acronym> document to invalidate so you may prefer to insert it into the head of each <acronym title="Hypertext Markup Language">HTML</acronym> document to get round this.</p>
<p>You might also want to combine this minimum width with a maximum width:</p>
<p><code> #container<br />
{<br />
min-width: 600px;<br />
max-width: 1200px;<br />
width:expression(document.body.clientWidth &lt; 600? "600px" : document.body.clientWidth &gt; 1200? "1200px" : "auto");<br />
} </code></p>
<h2>4. <acronym title="Internet Explorer">IE</acronym> and width &amp; height issues</h2>
<p><acronym title="Internet Explorer">IE</acronym> has a rather strange way of doing things. It doesn&#8217;t understand the <code>min-width</code> and <code>min-height</code> commands, but instead interprets <code>width</code> and <code>height</code> as <code>min-width</code> and <code>min-height</code> &#8211; go figure!</p>
<p>This can cause problems, because we may need boxes to be resizable should more text need to go in them or should the user resize text. If we only use the <code>width</code> and <code>height</code> commands on a box then non-<acronym title="Internet Explorer">IE</acronym> browsers won&#8217;t allow the box to resize. If we only use the <code>min-width</code> and <code>min-height</code> commands though then we can&#8217;t control the width or height in <acronym title="Internet Explorer">IE</acronym>!</p>
<p>This can be especially problematic when using <strong>background images</strong>. If you&#8217;re using a background image that&#8217;s 80px wide and 35px high, then you&#8217;ll want to make sure that the default size for a box using this image is exactly 80 x 35px. However, if users resize the text then the box size will need to expand gracefully.</p>
<p>To <strong>resolve this problem</strong>, you can use the following code for a box with <code>class="box"</code>:</p>
<p><code> .box<br />
{<br />
width: 80px;<br />
height: 35px;<br />
}</p>
<p>html&gt;body .box<br />
{<br />
width: auto;<br />
height: auto;<br />
min-width: 80px;<br />
min-height: 35px;<br />
} </code></p>
<p>All browsers will read through the first <acronym title="Cascading Stylesheets">CSS</acronym> rule but <acronym title="Internet Explorer">IE</acronym> will ignore the second rule because it makes use of the <a href="http://meyerweb.com/eric/articles/webrev/200006b.html">child selector command</a><sup class="printOnly">3</sup>. Non-<acronym title="Internet Explorer">IE</acronym> browsers will read through the second one and will override the values from the first rule because this <acronym title="Cascading Stylesheets">CSS</acronym> rule is more specific, and <strong><acronym title="Cascading Stylesheets">CSS</acronym> rules that are more specific always override those that are less specific</strong>.</p>
<h2>5. Text-transform command</h2>
<p>One of the lesser known, but really useful <acronym title="Cascading Stylesheets">CSS</acronym> commands is the <code>text-transform</code> command. Three of the more common values for this rule are: <code>text-transform: uppercase</code>, <code>text-transform: lowercase</code> and <code>text-transform: capitalize</code>. The first rule turns all characters into capital letters, the second turns them all into small letters, and the third makes the first letter of each word capitals.</p>
<p>This command is incredibly useful to help <strong>ensure consistency in style across an entire website</strong>, particularly if there a number of content editors. Say for example your style guide dictates that words in headings must always begin with capital letters. To ensure that this is always the case, use <code>text-transform: capitalize</code>. Even if site editors forget about the capitalisation, their mistake won&#8217;t show up on the website.</p>
<p>It&#8217;s also preferable to <strong>use <code>text-transform: uppercase</code> to capitalise words</strong>, as screen readers may pronounce shorter words in capital letters as acronyms. A great example of this is ‘CONTACT US’, which is pronounced as ‘contact U S’ by some screen readers.</p>
<h2>6. Disappearing text or images in <acronym title="Internet Explorer">IE</acronym>?</h2>
<p><acronym title="Internet Explorer">IE</acronym> has a very strange bug where text or background images sometimes disappears from sight. These items are still actually there, and if you highlight everything on screen or hit refresh they&#8217;ll often re-appear. Kind of strange, huh?</p>
<p>This problem mostly occurs on background images and on text next to a floated element. To <strong>remedy the problem</strong>, simply insert <code>position: relative</code> into the CSS command for the disappearing element, and for some bizarre reason that&#8217;ll usually fix the problem. If this doesn&#8217;t work (it sometimes doesn&#8217;t), assign a width to the offending element in the CSS and that should fix the problem.</p>
<h2>7. Invisible text</h2>
<p>Sometime you may actually want to make text invisible. Invisible text can be especially <strong>useful for screen reader users</strong>, perhaps to assign a label to a form item or insert a heading ahead of a section. Don&#8217;t want to change the visual appearance by inserting these? Make them invisible and no one using a visual browser knows that they&#8217;re there.</p>
<p>You may also want to make text invisible if using a <strong>print or handheld <acronym title="Cascading Stylesheets">CSS</acronym></strong> file, as some information may not need to be displayed on either of these mediums (see below for more on this).</p>
<p>To make text invisible you can use <code>display: none</code> &#8211; easy! This works fine for hiding text from handhelds (if <acronym title="Cascading Stylesheets">CSS</acronym> is supported) and printed web pages, but isn&#8217;t so great for many screen readers. Screen readers are now becoming too clever for their own good, and some will actually ignore the any text that has the rule <code>display: none</code> assigned to it.</p>
<p>For screen readers users therefore, a new approach is needed: <code>position: absolute; left: -9000px</code>. This basically takes the text and positions it 9000px to the left of the left edge of the screen, essentially making it invisible.</p>
<h2>8. <acronym title="Cascading Stylesheets">CSS</acronym> document for handhelds</h2>
<p>A separate <acronym title="Cascading Stylesheets">CSS</acronym> document can be created for <acronym title="Personal Digital Assistant">PDA</acronym>s and mobile phones, and only activated when one of these devices is being used to access your site. More and more websites are creating separate <a href="http://www.alistapart.com/articles/goingtoprint/"><acronym title="Cascading Stylesheets">CSS</acronym> documents for printing</a><sup class="printOnly">4</sup>, so web pages automatically become print-friendly when users choose to print them. You can also do the same for handheld devices.</p>
<p>The following command is used to call up the <acronym title="Cascading Stylesheets">CSS</acronym> document for handhelds:</p>
<p><code> &lt;link type="text/css" rel="stylesheet" href="handheldstyle.css" <strong>media="handheld"</strong> /&gt; </code></p>
<p><acronym title="Cascading Stylesheets">CSS</acronym> commands in the handheld <acronym title="Cascading Stylesheets">CSS</acronym> file override any equivalent commands in the main <acronym title="Cascading Stylesheets">CSS</acronym> document. So, what commands should you place in this file?</p>
<p>Ideally, you want handheld web users to <strong>avoid having to scroll across</strong>. To test this, open up your website in a regular browser window and resize it to 150px in width. Then, open up your main <acronym title="Cascading Stylesheets">CSS</acronym> file and insert some new commands at the very bottom of the document. The commands you place here should adjust the layout of the website so that it doesn&#8217;t require horizontal scrolling at a 150px width. Then, open up a new document, cut and paste these new commands over, and save it as handheldstyle.css (or whatever name you want to give it).</p>
<p>What your website offers to handheld web users should be quite different to what it offers on traditional web browsers, as the user experience is quite different. For further information, a book such as <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0470844469/ref=pd_ecc_rvi_3/026-2336786-5677265">Handheld Usability</a><sup class="printOnly">5</sup> is a great read.</p>
<h2>9. 3-d push button effect</h2>
<p>Back in the early days of the web, 3-d buttons that appeared to become pushed in when moused over were all the rage. At that time, this could only be achieved through images and JavaScript, but now with the advent of <acronym title="Cascading Stylesheets">CSS</acronym> we can go all retro and re-create this effect:</p>
<p><a class="example" title="example" href="http://www.webcredible.co.uk/user-friendly-resources/css/more-css-tricks.shtml#">Example link</a><sup class="printOnly">6</sup></p>
<p>The <strong>main <acronym title="Cascading Stylesheets">CSS</acronym> commands</strong> you&#8217;ll need are:</p>
<p><code> a 				{<br />
display: block;<br />
border: 1px solid;<br />
border-color: #aaa #000 #000 #aaa;<br />
width: 8em;<br />
background: #fc0;<br />
}</p>
<p>a:hover<br />
{<br />
position: relative;<br />
top: 1px;<br />
left: 1px;<br />
border-color: #000 #aaa #aaa #000;<br />
} </code></p>
<p>Aside from these commands, you can insert any other commands to achieve the desired presentation effect &#8211; the only limit is your imagination!</p>
<h2>10. Same navigation code on every page</h2>
<p>Most websites highlight the navigation item of the user&#8217;s location in the website, to help users orientate themselves. This is a fundamental requirement for basic usability, but can be a pain as you&#8217;ll need to tweak the <acronym title="Hypertext Markup Language">HTML</acronym> code behind the navigation for each and every page. So can we have the best of both worlds? Is it possible to have the <strong>navigation highlighted on every page, without having to tweak the <acronym title="Hypertext Markup Language">HTML</acronym> code</strong> on each and every page? Of course it is&#8230;</p>
<p>First of all, you&#8217;ll need to assign a class to each navigation item:</p>
<p><code> &lt;ul&gt;<br />
&lt;li&gt;&lt;a href="#" <strong>class="home"</strong>&gt;Home&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#" <strong>class="about"</strong>&gt;About us&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#" <strong>class="contact"</strong>&gt;Contact us&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
</code></p>
<p>You&#8217;ll then need to <strong>insert an <code>id</code> into the <code>&lt;body&gt;</code></strong> tag. The <code>id</code> should be representative of where users are in the site and should change when users move to a different site section. When in ‘Home’ it should read <code>&lt;body id="home"&gt;</code>, in ‘About Us’ it should be <code>&lt;body id="about"&gt;</code> and in ‘Contact Us’ <code>&lt;body id="contact"&gt;</code>.</p>
<p>Next, you create a new <acronym title="Cascading Stylesheets">CSS</acronym> rule:</p>
<p><code> #home .home, #about .about, #contact .contact<br />
{<br />
<em>commands for highlighted navigation go here</em><br />
} </code></p>
<p>This basically creates a rule that only takes effect when <code>class="home"</code> is contained within <code>id="home"</code>, and when <code>class="about"</code> is in <code>id="about"</code> and <code>class="contact"</code> is in <code>id="contact"</code>. These situations will only occur when the user is in the appropriate site section, seamlessly creating our highlighted navigation item.</p>
<div id="credit">
<p>This article was written by Trenton Moss. Trenton&#8217;s crazy about web usability and accessibility &#8211; so crazy that he founded Webcredible, an industry-leading <a href="http://www.webcredible.co.uk/">user experience consultancy</a><sup class="printOnly">7</sup>, helping to make the Internet a better place for everyone. He&#8217;s very good at running <a href="http://www.webcredible.co.uk/services/css-training-fund.shtml"><acronym title="Cascading Stylesheets">CSS</acronym> training</a><sup class="printOnly">8</sup> and spends much of his time working on the world&#8217;s most <a href="http://www.webcredible.co.uk/services/accessible-cms.shtml">accessible <acronym title="Content management system">CMS</acronym></a><sup class="printOnly">9</sup>.</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gravityeffect.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gravityeffect.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gravityeffect.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gravityeffect.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gravityeffect.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gravityeffect.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gravityeffect.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gravityeffect.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gravityeffect.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gravityeffect.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=16&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gravityeffect.wordpress.com/2008/08/10/ten-more-css-tricks-you-may-not-know/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a1b1b4c9bee44fe06b17fc55492bc4c0?s=96&#38;d=identicon" medium="image">
			<media:title type="html">gravityeffect</media:title>
		</media:content>
	</item>
		<item>
		<title>New CSS commands for Internet Explorer 7</title>
		<link>http://gravityeffect.wordpress.com/2008/08/10/new-css-commands-for-internet-explorer-7/</link>
		<comments>http://gravityeffect.wordpress.com/2008/08/10/new-css-commands-for-internet-explorer-7/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:05:02 +0000</pubDate>
		<dc:creator>gravityeffect</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://gravityeffect.wordpress.com/?p=11</guid>
		<description><![CDATA[There are a small handful of new CSS commands that you can now use for Internet Explorer 7. Well, they&#8217;re not really new &#8211; most other browsers have supported them for a long time and IE is only just catching up. These new commands basically give you more control over HTML elements and eliminate the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=11&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are a small handful of new <acronym title="Cascading Stylesheets">CSS</acronym> commands that you can now use for Internet Explorer 7. Well, they&#8217;re not really new &#8211; most other browsers have supported them for a long time and <acronym title="Internet Explorer">IE</acronym> is only just catching up. These new commands basically give you more control over <acronym title="Hypertext Markup Language">HTML</acronym> elements and <strong>eliminate the need to use classes</strong> or ids in a lot of instances.</p>
<p>Once <acronym title="Internet Explorer">IE</acronym>6 becomes outdated you&#8217;ll be able to use the commands outlined in this article. Actually, that&#8217;s not strictly true &#8211; provided that your website doesn&#8217;t rely on these commands and is still legible in <acronym title="Internet Explorer">IE</acronym>6 and before then there&#8217;s no problem using them.</p>
<h2>Child selector</h2>
<p>Despite Internet Explorer 6 not supporting the <acronym title="Cascading Stylesheets">CSS</acronym> child selector, it&#8217;s actually been used a lot as a way of hiding <acronym title="Cascading Stylesheets">CSS</acronym> commands from Internet Explorer. This is no longer possible as <acronym title="Internet Explorer">IE</acronym>7 now understands the child selector. So, what is the child selector? Well, imagine the following <acronym title="Hypertext Markup Language">HTML</acronym> structure:</p>
<p><code>&lt;div&gt;&lt;p&gt;&lt;span&gt;Text goes here&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</code></p>
<p>In the above example, the <code>&lt;p&gt;</code> is a child of the <code>&lt;div&gt;</code> and the <code>&lt;span&gt;</code> is a grandchild of the <code>&lt;div&gt;</code>. We can make the text in the <code>&lt;span&gt;</code> red by using the following <acronym title="Cascading Stylesheets">CSS</acronym> rule:</p>
<p><code>div span {color: red;}</code></p>
<p>This basically means that the contents of the <code>&lt;span&gt;</code> will be red, provided that the <code>&lt;span&gt;</code> is nested within a <code>&lt;div&gt;</code>. That <code>&lt;span&gt;</code> could be a child, grandchild, great-grandchild etc. of the <code>&lt;div&gt;</code>.</p>
<p>If we were however to use the following <acronym title="Cascading Stylesheets">CSS</acronym> code:</p>
<p><code>div<strong>&gt;</strong>span {color: red;}</code></p>
<p>&#8230;Then the text within our <code>&lt;span&gt;</code> wouldn&#8217;t turn red. This is because we&#8217;ve inserted the child selector between the <code>div</code> and <code>span</code> (the greater than sign), which basically means that our <strong><code>span</code> has to be a child of a <code>div</code></strong>. In the above example, the <code>&lt;span&gt;</code> is a grandchild of the <code>&lt;div&gt;</code>.</p>
<p>So, by using the child selector, we can <strong>assign rules to any <acronym title="Hypertext Markup Language">HTML</acronym> element that&#8217;s a child</strong> (and not a grandchild) of another element. Let&#8217;s say for example we want a top margin to be assigned to the first <code>&lt;div&gt;</code> in our body, but not to any others. Without the child selector we would be forced to assign a class or id to this <code>&lt;div&gt;</code> and reference that class or id in our <acronym title="Cascading Stylesheets">CSS</acronym> command. Now though, we can reference this <code>&lt;div&gt;</code>, and only this <code>&lt;div&gt;</code>, without the need for a class or id through the <acronym title="Cascading Stylesheets">CSS</acronym>:</p>
<p><code>body&gt;div {margin-top: 10px;}</code></p>
<h2>Using the child selector to hide commands from <acronym title="Internet Explorer">IE</acronym></h2>
<p>Historically, the child selector has been used to hide <acronym title="Cascading Stylesheets">CSS</acronym> commands from <acronym title="Internet Explorer">IE</acronym>. Simply by <strong>placing <code>html&gt;body</code> in front of any <acronym title="Cascading Stylesheets">CSS</acronym> command</strong> <acronym title="Internet Explorer">IE</acronym> will ignore it:</p>
<p><code>html&gt;body .foo {<em><acronym title="Cascading Stylesheets">CSS</acronym> commands go here</em>;}</code></p>
<p>This works because <code>&lt;body&gt;</code> is always a child of <code>&lt;html&gt;</code> &#8211; it can of course never be a grandchild or great-grandchild of <code>&lt;html&gt;</code>.</p>
<p>Now that <acronym title="Internet Explorer">IE</acronym>7 understands the child selector, you have to insert an empty comment tag in directly after the greater than sign. <acronym title="Internet Explorer">IE</acronym>7 will then not understand this selector (who knows why!?) and will therefore totally ignore this <acronym title="Cascading Stylesheets">CSS</acronym> command:</p>
<p><code>html&gt;<strong>/**/</strong>body .foo {<em><acronym title="Cascading Stylesheets">CSS</acronym> commands go here</em>;}</code></p>
<h2>Adjacent selector</h2>
<p>The adjacent selector is another extremely useful <acronym title="Cascading Stylesheets">CSS</acronym> selector that up until now Internet Explorer hasn&#8217;t understood. Fortunately, <acronym title="Internet Explorer">IE</acronym>7 does understand it. The adjacent selector basically allows you to <strong>reference an <acronym title="Hypertext Markup Language">HTML</acronym> element that&#8217;s adjacent to another element</strong>:</p>
<p><code>blockquote+p {margin-top: 0;}</code></p>
<p>The above <acronym title="Cascading Stylesheets">CSS</acronym> code basically says that any paragraph that&#8217;s preceded by a quote shouldn&#8217;t have a top margin. This is useful as you may always wish to cite the person making the quote in a paragraph after the quote and may want to get rid of the space between the paragraph and quote.</p>
<p>Another great example of when you may use the adjacent selector is in <strong>horizontal lists</strong>. Often, you may want to format the first item slightly differently to the other items in the list. So, if you wanted to assign a left border to each navigation item except for the first, you could use this <acronym title="Cascading Stylesheets">CSS</acronym> code:</p>
<p><code>li+li {border-left: 1px solid black;}</code></p>
<p>This basically means that any <code>&lt;li&gt;</code> that follows another <code>&lt;li&gt;</code> (i.e. all of them except the first) should have a left hand border.</p>
<h2>First-child pseudo class</h2>
<p>Although there are still a number of <a href="http://www.westciv.com/style_master/academy/css_tutorial/selectors/p_class_selectors.html">pseudo classes</a><sup class="printOnly">8</sup> <acronym title="Internet Explorer">IE</acronym>7 doesn&#8217;t understand, the first-child pseudo class is one that it does now support. Again, this is a good news as this allows us to <strong>format the first <acronym title="Hypertext Markup Language">HTML</acronym> element differently</strong> in any given section without having to assign it a class or id. So, for example, say you wanted the first paragraph in the content area to never have a top margin, you could use this <acronym title="Cascading Stylesheets">CSS</acronym> command:</p>
<p><code>#content p:first-child {margin-top: 0;}</code></p>
<h2>Conclusion</h2>
<p>Internet Explorer 7 is certainly an improvement on Internet Explorer 6, in terms of <acronym title="Cascading Stylesheets">CSS</acronym>. A very large number of <acronym title="Cascading Stylesheets">CSS</acronym> bugs have been fixed and <acronym title="Internet Explorer">IE</acronym>7 now supports more <acronym title="Cascading Stylesheets">CSS</acronym> commands. There&#8217;s still a very long way to go though and there remains a large number of <acronym title="Cascading Stylesheets">CSS</acronym> commands <acronym title="Internet Explorer">IE</acronym> still doesn&#8217;t understand &#8211; let&#8217;s hope it catches up soon!</p>
<div id="credit">
<p>This article was written by Trenton Moss. Trenton&#8217;s crazy about web usability and accessibility &#8211; so crazy that he founded Webcredible, an industry-leading <a href="http://www.webcredible.co.uk/">user experience consultancy</a><sup class="printOnly">9</sup>, helping to make the Internet a better place for everyone. He&#8217;s very good at running <a href="http://www.webcredible.co.uk/services/css-training-fund.shtml"><acronym title="Cascading Stylesheets">CSS</acronym> training</a><sup class="printOnly">6</sup> and spends much of his time working on the world&#8217;s most <a href="http://www.webcredible.co.uk/services/accessible-cms.shtml">accessible <acronym title="Content management system">CMS</acronym></a><sup class="printOnly">10</sup>.</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gravityeffect.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gravityeffect.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gravityeffect.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gravityeffect.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gravityeffect.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gravityeffect.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gravityeffect.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gravityeffect.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gravityeffect.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gravityeffect.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=11&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gravityeffect.wordpress.com/2008/08/10/new-css-commands-for-internet-explorer-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a1b1b4c9bee44fe06b17fc55492bc4c0?s=96&#38;d=identicon" medium="image">
			<media:title type="html">gravityeffect</media:title>
		</media:content>
	</item>
		<item>
		<title>WHY CSS</title>
		<link>http://gravityeffect.wordpress.com/2008/08/10/why-css/</link>
		<comments>http://gravityeffect.wordpress.com/2008/08/10/why-css/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 15:57:34 +0000</pubDate>
		<dc:creator>gravityeffect</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://gravityeffect.wordpress.com/?p=5</guid>
		<description><![CDATA[There are many benefits to use style sheets, we believe that once you read the following key features (taken from W3C&#8217;s CSS reference), you will clearly realize that CSS is simply a must for any serious webmaster. CSS is based on a set of design principles : Forward and backward compatibility. CSS 2.1 user agents will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=5&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many <strong class="Blue3">benefits to use style sheets</strong>, we believe that once you read the following key features (taken from W3C&#8217;s CSS reference), you will clearly realize that <strong class="Red3">CSS is simply a must</strong> for any serious webmaster.</p>
<p>CSS is based on a set of design principles :</p>
<div>
<ul>
<li><strong>Forward and backward compatibility</strong>. CSS 2.1 user agents will be able to understand CSS1 style sheets. CSS1 user agents will be able to read CSS 2.1 style sheets and discard parts they don&#8217;t understand. Also, user agents with no CSS support will be able to display style-enhanced documents. Of course, the stylistic enhancements made possible by CSS will not be rendered, but all content will be presented.</li>
<li><strong>Complementary to structured documents</strong>. Style sheets complement structured documents (e.g., HTML and XML applications), providing stylistic information for the marked-up text. It should be easy to change the style sheet with little or no impact on the markup.</li>
<li><strong>Vendor, platform, and device independence</strong>. Style sheets enable documents to remain vendor, platform, and device independent. Style sheets themselves are also vendor and platform independent, but CSS 2.1 allows you to target a style sheet for a group of devices (e.g., printers).</li>
</ul>
<ul>
<li><strong>Maintainability</strong>. By pointing to style sheets from documents, webmasters can simplify site maintenance and retain consistent look and feel throughout the site. For example, if the organization&#8217;s background color changes, only one file needs to be changed.</li>
<li><strong>Simplicity</strong>. CSS is a simple style language which is human readable and writable. The CSS properties are kept independent of each other to the largest extent possible and there is generally only one way to achieve a certain effect.</li>
<li><strong>Network performance</strong>. CSS provides for compact encodings of how to present content. Compared to images or audio files, which are often used by authors to achieve certain rendering effects, style sheets most often decrease the content size. Also, fewer network connections have to be opened which further increases network performance.</li>
<li><strong>Flexibility</strong>. CSS can be applied to content in several ways. The key feature is the ability to cascade style information specified in the default (user agent) style sheet, user style sheets, linked style sheets, the document head, and in attributes for the elements forming the document body.</li>
<li><strong>Richness</strong>. Providing authors with a rich set of rendering effects increases the richness of the Web as a medium of expression. Designers have been longing for functionality commonly found in desktop publishing and slide-show applications. Some of the requested rendering effects conflict with device independence, but CSS 2.1 goes a long way toward granting designers their requests.</li>
<li><strong>Alternative language bindings</strong>. The set of CSS properties described in this specification form a consistent formatting model for visual and aural presentations. This formatting model can be accessed through the CSS language, but bindings to other languages are also possible. For example, a JavaScript program may dynamically change the value of a certain element&#8217;s <a href="http://www.highdots.com/css-editor/css_tutorial/color-background/color.html">&#8216;color&#8217;</a> property.</li>
<li> <strong>Accessibility</strong>. Several CSS features will make the Web more accessible to users with disabilities:
<ul>
<li>Properties to control font appearance allow authors to eliminate inaccessible bit-mapped text images.</li>
<li>Positioning properties allow authors to eliminate mark-up tricks (e.g., invisible images) to force layout.</li>
<li>The semantics of <tt>!important</tt> rules mean that users with particular presentation requirements can override the author&#8217;s style sheets.</li>
<li>The &#8216;inherit&#8217; value for all properties improves cascading generality and allows for easier and more consistent style tuning.</li>
<li>Improved media support, including media groups and the braille, embossed, and tty media types, will allow users and authors to tailor pages to those devices.</li>
</ul>
</li>
</ul>
</div>
<div><span class="Blue3">Note :</span> This article was taken from W3C&#8217;s CSS reference. W3C hold full copyright on this document.</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gravityeffect.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gravityeffect.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gravityeffect.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gravityeffect.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gravityeffect.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gravityeffect.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gravityeffect.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gravityeffect.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gravityeffect.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gravityeffect.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gravityeffect.wordpress.com&amp;blog=4470047&amp;post=5&amp;subd=gravityeffect&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gravityeffect.wordpress.com/2008/08/10/why-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a1b1b4c9bee44fe06b17fc55492bc4c0?s=96&#38;d=identicon" medium="image">
			<media:title type="html">gravityeffect</media:title>
		</media:content>
	</item>
	</channel>
</rss>
