<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Couch &#187; CSS</title>
	<atom:link href="http://www.codecouch.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codecouch.com</link>
	<description>The ramblings of two code monkeys</description>
	<lastBuildDate>Thu, 19 Nov 2009 15:47:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How do you vertically centre content using CSS?</title>
		<link>http://www.codecouch.com/2008/10/how-do-you-vertically-centre-content-using-css/</link>
		<comments>http://www.codecouch.com/2008/10/how-do-you-vertically-centre-content-using-css/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 13:12:07 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=201</guid>
		<description><![CDATA[Find out how to do vertical centring (vertical alignment) of content using just CSS (and some div elements).]]></description>
			<content:encoded><![CDATA[<p>How do you vertical centre some content using CSS (and some extra div elements)? This is the same simple layout that used to be achieved using a table and valign attribute. This solution doesn&#8217;t require a table at all (but it does require some extra div elements &#8211; as per the markup below).</p>
<p>With the following markup:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;"><span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;verticalCenteringOuter&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;moduleA&quot;</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;verticalCenteringMiddle&quot;</span><span class="kw2">&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;verticalCenteringInner&quot;</span><span class="kw2">&gt;</span></span>
			<span class="sc2"><span class="kw2">&lt;b&gt;</span></span>Some vertical aligned content here<span class="sc2"><span class="kw2">&lt;/b&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></pre></div></div></div>

<p>Using the following CSS:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re0">#moduleA</span> <span class="br0">&#123;</span>
	<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">300px</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringOuter</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> table<span class="sy0">;</span>
	<span class="kw1">overflow</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringMiddle</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">table-cell</span><span class="sy0">;</span>
	<span class="kw1">vertical-align</span><span class="sy0">:</span> <span class="kw2">middle</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&nbsp;
&lt;!--<span class="br0">&#91;</span>if IE<span class="br0">&#93;</span><span class="sy0">&gt;</span>
&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re1">.verticalCenteringOuter</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">relative</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringMiddle</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">absolute</span><span class="sy0">;</span>
	<span class="kw1">top</span><span class="sy0">:</span> <span class="re3"><span class="nu0">50</span>%</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringInner</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">relative</span><span class="sy0">;</span>
	<span class="kw1">top</span><span class="sy0">:</span> -<span class="re3"><span class="nu0">50</span>%</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&lt;!<span class="br0">&#91;</span>endif<span class="br0">&#93;</span>--<span class="sy0">&gt;</span></pre></div></div></div>

<p>Full credit on this to <a href="http://www.jakpsatweb.cz/css/css-vertical-center-solution.html">Yuhů (www.jakpsatweb.cz)</a>. Thanks for the inspiration on this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/how-do-you-vertically-centre-content-using-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create rollovers without using Javascript</title>
		<link>http://www.codecouch.com/2008/10/create-rollovers-without-using-javascript/</link>
		<comments>http://www.codecouch.com/2008/10/create-rollovers-without-using-javascript/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 13:11:10 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front-end]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=174</guid>
		<description><![CDATA[Using just CSS, you can do simple (and more complex) rollovers... no javascript required. This post shows how to apply this technique to your own pages with ease - whether it's a colour change or a more complex image swap.]]></description>
			<content:encoded><![CDATA[<p>You can make use of the <b>:hover</b> pseudo class on the anchor tag to change the anchor&#8217;s style attributes. Typically you see this on sites that underline anchors when you mouse over them (when you hover over them). The CSS code to do this simple underlining can look like this:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span> <span class="kw1">text-decoration</span><span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span> <span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span> <span class="kw1">text-decoration</span><span class="sy0">:</span> <span class="kw2">underline</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></div></div></div>

<p>We could extend this to change the background and forground colour of the link to make it appear a little more &#8220;box-like&#8221; using something like this CSS code:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span> <span class="re3">5px</span> <span class="re3">10px</span><span class="sy0">;</span>
	<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#FFFFFF</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span>
	<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#CCCCCC</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>If you wanted to have a background image on the anchor, then you could change the background-image when you hovered over the anchor. The CSS code might look like this:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span> <span class="re3">5px</span> <span class="re3">10px</span><span class="sy0">;</span>
	<span class="kw1">background</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">img/anchor_off<span class="re1">.gif</span></span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#FFFFFF</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span>
	<span class="kw1">background</span><span class="sy0">:</span> <span class="re0">#CCCCCC</span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">img/anchor_hovered<span class="re1">.gif</span></span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>This technique does suffer from a flaw, however. You will invariably see a flickering as you roll over the anchor for the first time due to the browser having to request the second image (assuming the file isn&#8217;t already in the browser cache).</p>
<p>This problem can be fixed by using the same image for both the normal and hover state of the anchor &#8211; just reposition the background image on hover. This is presented very well over at <a href="http://www.alistapart.com/articles/sprites/">A List Apart</a> where Dave Shea introduces the concept of CSS Sprites. The image below (195px wide, 30px high in size) shows how you might set this up:</p>
<p><img src="http://www.codecouch.com/wp-content/uploads/2008/10/cssbuttonbackground.gif" alt="" title="Anchor background sprites" width="195" height="30" /></p>
<p>The image above shows both states of the anchor&#8230; the initial state at the &#8220;left top&#8221; and the hovered state &#8220;100px&#8221; from the left of the image. The following CSS code shows how you can reposition the background image to show a different image on hover &#8211; without the flicker:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span> <span class="re3">5px</span> <span class="re3">10px</span><span class="sy0">;</span>
	<span class="kw1">width</span><span class="sy0">:</span> <span class="re3">95px</span><span class="sy0">;</span>
	<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">30px</span><span class="sy0">;</span>
	<span class="kw1">overflow</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
	<span class="kw1">background</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">img/anchor_background<span class="re1">.gif</span></span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#FFFFFF</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span>
	<span class="kw1">background-position</span><span class="sy0">:</span> <span class="re3">100px</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#CCCCCC</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>You may have to deal with all the anchor pseudo classes to get the effect consistent in all browsers, and be sure to define them in the correct order&#8230; :link, :visited, :hover, :active.</p>
<p>Finally, Internet Explorer only supports pseudo classes on the anchor element. All other browsers support pseudo classes on all elements. You could use this technique on non-anchor elements, but would be forced to introduce some javascript to support Internet Explorer. A good working example of this is the popular <a href="http://www.alistapart.com/articles/dropdowns">Suckerfish dropdowns</a> CSS menu solution that uses :hover on the list item element and attaches some javascript for Internet Explorer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/create-rollovers-without-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use “clearfix” CSS to clear floats without markup</title>
		<link>http://www.codecouch.com/2008/10/how-to-use-clearfix-css-to-clear-floats-without-markup/</link>
		<comments>http://www.codecouch.com/2008/10/how-to-use-clearfix-css-to-clear-floats-without-markup/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 21:43:19 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front-end]]></category>
		<category><![CDATA[HTML/XHTML]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=165</guid>
		<description><![CDATA[Here we extended the normal rules for clearfix and provide a complete CSS solution to clearing floated elements (ensuring that a parent element inherits it's floated child element's height). A complete clearfix redux.]]></description>
			<content:encoded><![CDATA[<p>When an element is floated, it is taken out of the normal flow of the document. As a result, the element takes up no height (in the normal flow) &#8211; and any wrapping parent element will not automatically resize to accommodate the height of the floated element. Here is some sample HTML that shows this in it&#8217;s simple form:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;">...
<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;parent&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;background-color:#F00;&quot;</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;child&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;float: left;&quot;</span><span class="kw2">&gt;</span></span>Floated element<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
...</pre></div></div></div>

<p>Given the child element is floated, it doesn&#8217;t affect the height of the parent element &#8211; and so the parent element remains with no height (and the red background colour is never shown).</p>
<p>The <a href="http://www.w3.org/TR/CSS2/visuren.html#floats">W3 describe floating an element</a> and the use of a &#8220;clearing element&#8221; (a block level element with the <b>clear</b> CSS property set). This is not acceptable for all layouts. It would be nicer if all this could be carried out using CSS &#8211; providing a separation of content and layout into the bargain.</p>
<p>Rather than attempt to merely re-word much of what is already online, you can read about how the CSS for this works in more detail at <a href="http://www.positioniseverything.net/easyclearing.html">Position is Everything</a>. Whilst their implementation is slightly different to the one presented below, their description is excellent (and they are credited with bringing together all the threads to make this solution usable).</p>
<p>The <b>clearfix</b> solution below is our current &#8220;best practise&#8221; effort to date. We have switched from using the typical &#8220;.&#8221; to using a space &#8221; &#8221; in the <b>content</b> rule due to <a href="http://perishablepress.com/press/2008/02/05/lessons-learned-concerning-the-clearfix-css-hack/">reports of some layout issues in Firefox</a>.</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re1">.clearfix</span><span class="re2">:after</span> <span class="br0">&#123;</span>
	<span class="kw1">clear</span><span class="sy0">:</span> <span class="kw2">both</span><span class="sy0">;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">content</span><span class="sy0">:</span> <span class="st0">&quot; &quot;</span><span class="sy0">;</span>
	<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">0px</span><span class="sy0">;</span>
	<span class="kw1">visibility</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.clearfix</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> inline-<span class="kw2">block</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="coMULTI">/* Hide these rules from IE-mac \*/</span>
* html <span class="re1">.clearfix</span> <span class="br0">&#123;</span>
	<span class="kw1">height</span><span class="sy0">:</span> <span class="re3"><span class="nu0">1</span>%</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.clearfix</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
li<span class="re1">.clearfix</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">list-item</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="coMULTI">/* End hide from IE-mac */</span>
&lt;/style<span class="sy0">&gt;</span></pre></div></div></div>

<p>We extended the normal rules to include setting the correct display (list-item) for use on list items (as a direct result of some problems with floated lists). If you don&#8217;t care about IE-mac support (don&#8217;t forget that <a href="http://www.codecouch.com/2005/12/microsoft-finally-retires-ie-5-for-the-mac/">Microsoft finally retired IE 5 for the Mac</a>) then you can avoid using the &#8220;commented backslash hack&#8221; all together.</p>
<p>Going back to our original HTML code, we can place the <b>clearfix</b> class on the parent element to ensure that it inherits the height of it&#8217;s floating child elements (and the red background will now show):</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;">...
<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;clearfix&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;parent&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;background-color:#F00;&quot;</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;child&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;float: left;&quot;</span><span class="kw2">&gt;</span></span>Floated element<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
...</pre></div></div></div>

<p>You can read more about the <b>clearfix</b> solution all over the place, including:</p>
<ul>
<li><a href="http://www.positioniseverything.net/easyclearing.html">Position is Everything</a></li>
<li><a href="http://www.456bereastreet.com/archive/200603/new_clearing_method_needed_for_ie7/">456 Berea Street</a></li>
<li><a href="http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/">Sitepoint</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/how-to-use-clearfix-css-to-clear-floats-without-markup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get consistent font sizes across all browsers</title>
		<link>http://www.codecouch.com/2007/04/how-to-get-consistent-font-sizes-across-all-browsers/</link>
		<comments>http://www.codecouch.com/2007/04/how-to-get-consistent-font-sizes-across-all-browsers/#comments</comments>
		<pubDate>Wed, 18 Apr 2007 12:58:17 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Browsers]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=136</guid>
		<description><![CDATA[Whether you specify your element's font size in pixels, points or ems, you can be confident that text will look the same across browsers on Mac and Windows with this simple set of CSS rules.]]></description>
			<content:encoded><![CDATA[<p>Here is an un-sourced quote that I picked up from the internet:</p>
<blockquote><p>Macs render text at a screen resolution of 72 pixels per inch (ppi) &#8230; Windows renders type at a notional screen resolution of 96 ppi&#8230; the difference between 96 ppi and 72 ppi (24 pixels) makes the fonts on a Web page look 33 percent larger when viewed on a Windows machine.</p>
</blockquote>
<p>To compensate, there are some very simple CSS rules that you can use to essentially &#8220;reset&#8221; the text size to be consistent across both Mac and Windows.</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
   html<span class="sy0">&gt;</span>body <span class="br0">&#123;</span> <span class="kw1">font-size</span><span class="sy0">:</span> <span class="re3">16px</span><span class="sy0">;</span> <span class="br0">&#125;</span>
   body <span class="br0">&#123;</span> <span class="kw1">font-size</span><span class="sy0">:</span> <span class="re3"><span class="nu0">100</span>%</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&nbsp;
&lt;!--<span class="br0">&#91;</span>if IE <span class="nu0">7</span><span class="br0">&#93;</span><span class="sy0">&gt;</span>
&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
   html<span class="sy0">&gt;</span>body <span class="br0">&#123;</span> <span class="kw1">font-size</span><span class="sy0">:</span> <span class="re3"><span class="nu0">100</span>%</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&lt;!<span class="br0">&#91;</span>endif<span class="br0">&#93;</span>--<span class="sy0">&gt;</span></pre></div></div></div>

<p>Initially the <b>html&gt;body</b> definition is applied to all browsers that understand the child selector CSS. This will result in setting the font-size on Opera, Firefox, Netscape, IE7, Safari (and other &#8220;modern&#8221; browsers). It will not be applied to older versions of IE &#8211; they will ignore this definition.</p>
<p>Next, the <b>body</b> definition is set for all browsers that didn&#8217;t understand the initial definition. Because this definition has lower specificity than the initial definition, it is ignored by the likes of Opera, Firefox, Netscape, IE7 and Safari&#8230; but older versions of IE will get this font-size definition.</p>
<p>Finally a conditional comment (which is specific to Windows IE) delivers an override to the initial style by setting the font-size back from a fixed pixel value to a scaleable value for all &#8220;new&#8221; versions of IE&#8230; specifically IE7. It needs to be <b>html&gt;body</b> to ensure it doesn&#8217;t have a lower specificity than the initial definition.</p>
<p>Now, whether you specify your element&#8217;s font size in pixels, points or ems, you can be confident that text will look the same across browsers on Mac and Windows.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2007/04/how-to-get-consistent-font-sizes-across-all-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
