<?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>Todd Huss &#187; CSS</title>
	<atom:link href="http://gabrito.com/post/category/technical/css/feed" rel="self" type="application/rss+xml" />
	<link>http://gabrito.com</link>
	<description>Anecdotes on Technology Leadership, Ruby, Java, Scala, Cloud Computing, Open-Source, SEO, and Design</description>
	<lastBuildDate>Thu, 08 Dec 2011 00:21:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Ajax enabling crusty legacy webapps with Prototype</title>
		<link>http://gabrito.com/post/ajax-enabling-crusty-legacy-webapps-with-prototype</link>
		<comments>http://gabrito.com/post/ajax-enabling-crusty-legacy-webapps-with-prototype#comments</comments>
		<pubDate>Sun, 26 Nov 2006 19:35:18 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/ajax-enabling-crusty-legacy-webapps-with-prototype</guid>
		<description><![CDATA[With all of the hype around Ajax it&#8217;s easy to think you might need an MVC framework with baked in Ajax support like Rails ActionPack or JBoss Seam to make Ajax easy. However, libraries like Prototype (which is what Rails &#8230; <a href="http://gabrito.com/post/ajax-enabling-crusty-legacy-webapps-with-prototype">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With all of the hype around Ajax it&#8217;s easy to think you might need an MVC framework with baked in Ajax support like <a href="http://www.rubyonrails.org/">Rails ActionPack</a> or <a href="http://www.jboss.com/products/seam">JBoss Seam</a> to make Ajax easy. However, libraries like <a href="http://prototype.conio.net/">Prototype</a> (which is what Rails uses) make it so easy that it&#8217;s a snap to Ajax enable even the crustiest legacy web application!</p>
<p>Let&#8217;s take a look at what it takes to put a simple unordered list on a page with a refresh button to refresh the list without doing and page reload and then we&#8217;ll spruce it up a bit:<br />
<span id="more-162"></span><br />
1. First we&#8217;ll need a URL that should return the content of the list and say we&#8217;re working in a crusty old CGI environment so we&#8217;ll call it <strong>/cgi-bin/friends_online.cgi</strong> and say it returns the list of your friends that are online:</p>
<pre>&lt;ul&gt;
&lt;li&gt;Mr Bigglesworth&lt;/li&gt;
&lt;li&gt;Austin Powers&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>2. Now on the page where we want to include the list of our friends that are online we&#8217;ll need to include <a href="http://prototype.conio.net/dist/prototype-1.4.0.js">prototype.js</a> in the head section of the page:</p>
<pre>&lt;script src="/js/prototype.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p><!--adsense--></p>
<p>3. Let&#8217;s look at how simple this can be:</p>
<pre>&lt;div id="friends_online"&gt;
... friends online ...
&lt;/div&gt;
&lt;a href="javascript:var x=new Ajax.Updater('friends_online','/cgi-bin/friends_online.cgi')"&gt;Refresh&lt;/a&gt;</pre>
<p>When you hit the refresh button the contents of the friends_online div will be replaced with the output from friends_online.cgi, it&#8217;s that easy! Now let&#8217;s spruce it up a bit.</p>
<p>4. Since we&#8217;re not concerned with server load in this example we&#8217;ll populate the dynamic list using Ajax the first time the page loads as well. While we&#8217;re at it let&#8217;s also hide the <strong>Refresh</strong> button and <strong>friends_online</strong> div while the refresh is happening and <a href="http://www.sanbaldo.com/wordpress/1/ajax_gif/">display an animated loading gif</a>. Here&#8217;s what that would look like:</p>
<pre>&lt;div id="friends_online"&gt;&lt;/div&gt;
&lt;img id="loading" src="loading.gif" alt="Loading"/&gt;
&lt;a id="refresh" href="javascript:friendsOnline()"&gt;Refresh&lt;/a&gt;

&lt;script type="text/javascript"&gt;
function friendsOnline() {
	$('friends_online').style.display = 'none';
	$('refresh').style.display = 'none';
	$('loading').style.display = 'inline';
	new Ajax.Updater('friends_online', '/cgi-bin/friends_online.cgi', {
		parameters: 'key=value&amp;key2=value2',
		method: 'get',
		onComplete: function () {
			$('friends_online').style.display = 'block';
			$('refresh').style.display = 'inline';
			$('loading').style.display = 'none';
		}
	});
}
Event.observe(window, 'load', friendsOnline, false); // This calls friendsOnline on page load
&lt;/script&gt;</pre>
<p>I put in the parameters just to illustrate how to pass parameters with the URL. If I were to take this one step further I&#8217;d put the Javascript into a separate .js file and use <a href="http://wiki.script.aculo.us/scriptaculous/show/CombinationEffectsDemo">Script.aculo.us Effects.js BlindUp and BlindDown</a> to animate hiding and un-hiding the <strong>friends_online</strong> div. Hopefully you can see how much power Prototype gives you and how easy it can be to Ajax enable a legacy web application!</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/ajax-enabling-crusty-legacy-webapps-with-prototype/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deferring ad loading on your pages to avoid unnecessary outages</title>
		<link>http://gabrito.com/post/deferring-ad-loading-on-your-pages-to-avoid-unnecessary-outages</link>
		<comments>http://gabrito.com/post/deferring-ad-loading-on-your-pages-to-avoid-unnecessary-outages#comments</comments>
		<pubDate>Wed, 04 Oct 2006 03:49:30 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/deferring-ad-loading-on-your-pages-to-avoid-unnecessary-outages</guid>
		<description><![CDATA[At GreatSchools we&#8217;ve had 3rd party ad server outages or slowness effectively make our site unusable as users browsers waited for certain ads to render before rendering the rest of the page. I had originally thought just specifying height and &#8230; <a href="http://gabrito.com/post/deferring-ad-loading-on-your-pages-to-avoid-unnecessary-outages">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.greatschools.net">GreatSchools</a> we&#8217;ve had 3rd party ad server outages or slowness effectively make our site unusable as users browsers waited for certain ads to render before rendering the rest of the page. I had originally thought just specifying height and width of the div element around the ad would be enough for the browser to move on given a slow ad load but in my tests with various ad servers that turned out not to be the case. After some research I discovered that the trick that some sites (such as <a href="http://digg.com">Digg.com</a>) employ is called source ordered content where you put the content in the order you&#8217;d really like it in (be it for SEO or for deferring ad calls) and then using CSS or Javascript to move it to the proper place.<br />
<span id="more-156"></span><br />
In this particular case I needed the ads to be called at the end of the page so that the browser would always render the full XHTML page to the user right away so that slow loading ads didn&#8217;t delay the rendering of the page.</p>
<p>To address this I wrote a simple javascript solution. Here&#8217;s how it works: </p>
<p><!--adsense--></p>
<p>1. I put my <a target="_blank" href="http://gabrito.com/files/deferredcontent.js">deferredcontent.js</a> code that I wrote in the head tag<br />
<strong style="font-size:.9em">&lt;script type=&#8221;text/javascript&#8221; src=&#8221;/js/deferredcontent.js&#8221;&gt;&lt;/script&gt;</strong><br />
2. I added an <strong style="font-size:.9em">onload=&#8221;relocateDeferredContent();&#8221;</strong> to the body tag<br />
3. I put an empty div tag where I ultimately wanted the content to end up. E.g <strong style="font-size:.9em">&lt;div id=&#8221;adleaderboard&#8221;&gt;&lt;/div&gt;</strong><br />
4. I put the deferred content in a display:none div just before the closing body tag at the very end of the page and put each block of code I wanted to relocate in a div with an id of defer-IDFROMSTEP3<br />
<strong style="font-size:.9em"><br />
&lt;div style=&#8221;display:none&#8221;&gt;<br />
&lt;div id=&#8221;defer-adleaderboard&#8221;&gt;<br />
[Ad code goes here]<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
</strong></p>
<p>If you want to see it in action you can see it on this <a target="_blank" href="http://www.greatschools.net/city/San_Francisco/CA">San Francisco schools</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/deferring-ad-loading-on-your-pages-to-avoid-unnecessary-outages/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using image tags (for style elements) in HTML is bad design</title>
		<link>http://gabrito.com/post/using-image-tags-in-html-is-bad-design</link>
		<comments>http://gabrito.com/post/using-image-tags-in-html-is-bad-design#comments</comments>
		<pubDate>Tue, 11 Apr 2006 15:56:37 +0000</pubDate>
		<dc:creator>Todd Huss</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Search Engine Optimization]]></category>

		<guid isPermaLink="false">http://gabrito.com/post/using-image-tags-in-html-is-bad-design</guid>
		<description><![CDATA[Update 4/11/06: I&#8217;ve received some criticism on this post from people who assumed I was saying you should never use image tags in HTML. My bad for the misleading title, I&#8217;ve added to the title in parens to be more &#8230; <a href="http://gabrito.com/post/using-image-tags-in-html-is-bad-design">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Update 4/11/06:</strong> I&#8217;ve received <a href="http://weblog.halogenlabs.com/?p=489">some criticism</a> on this post from people who assumed I was saying you should never use image tags in HTML. My bad for the misleading title, I&#8217;ve added to the title in parens to be more concise! For those that didn&#8217;t read the whole post, in the last paragraph I say that it&#8217;s <strong>fine to use HTML image tags for content</strong>, I just think it&#8217;s bad design to use image tags for style elements. Anyhow, thanks for all the feedback (postive and negative) and here&#8217;s the original post:</p>
<p>CSS offers us a lot of power to style and decorate our pages with images, however, replacing text with an image is one gap not well addressed by CSS such that you often see sites doing: </p>
<p><strong>&lt;a href=&#8221;/&#8221;&gt;&lt;img alt=&#8221;Home&#8221; src=&#8221;home.gif&#8221;/&gt;&lt;/a&gt;</strong> </p>
<p>which is obviously bad for 2 reasons:<br />
<span id="more-127"></span><br />
1. It violates the separation of content and design by including a design element in your HTML<br />
2. Your SEO will suffer because image alt tags don&#8217;t carry as much weight as real text</p>
<p>As a result a number of people have come up with <a href="http://www.mezzoblue.com/tests/revised-image-replacement/">clever image replacement techniques in CSS</a>. It began in 2003 with the <a href="http://www.stopdesign.com/also/articles/replace_text/">Fahrner Image Replacement technique (or Classic FIR)</a>, however, the technique I currently favor is the <a href="http://phark.typepad.com/phark/2003/08/accessible_imag.html">Mike Rundle&#8217;s Phark revised method</a> which:</p>
<p><!--adsense--></p>
<p>1. Works well cross browser (but be sure to test in IE 5 for possible issues if you&#8217;re still supporting it)<br />
2. Works with a <a href="http://www.freedomscientific.com/fs_products/software_jaws.asp">screen reader such as JAWS</a> for accessibility<br />
3. Works well for SEO (many techniques style the text with display:none which likely won&#8217;t work with the next generation of crawlers such as Google&#8217;s new Mozilla based crawler)</p>
<p>Taking the example above, the correct approach would be as follows:</p>
<p><strong>&lt;a id=&#8221;home&#8221; href=&#8221;/&#8221;&gt;Home&lt;/a&gt;</strong></p>
<p>Then apply the Phark revised method via CSS:</p>
<p><strong>#home {<br />
&#160;	display: block;<br />
&#160;	text-indent: -9000px;<br />
&#160;	background: url(/images/home.gif) no-repeat;<br />
&#160;	height: 25px;<br />
&#160;	width: 100px;<br />
}</strong>	</p>
<p>Here&#8217;s the result: </p>
<p><a style="display: block; text-indent: -9000px;background: url(http://gabrito.com/files/home.gif) no-repeat;height: 25px;width: 100px;" href="/">About Us</a></p>
<p>Now we&#8217;ve replaced the text with an image yet still kept the separation of content and design clean. I stated that it&#8217;s bad design to use image tags in your HTML but I&#8217;d like to qualify that, it&#8217;s fine if your &#8220;content&#8221; is an image such as a product photograph in a web catalog, a graph, or a headshot in your user profile. Also I think it&#8217;s fine to bail on image replacement if you start wasting a lot of time in CSS layout land, it&#8217;s just good to start with the clean text based approach first and use it until it becomes impractical.</p>
]]></content:encoded>
			<wfw:commentRss>http://gabrito.com/post/using-image-tags-in-html-is-bad-design/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

