<?xml version="1.0" encoding="iso-8859-1" ?>
<rss version="2.0">
<channel>
<title>NealGrosskopf.com - Geek Speak</title>
<link>http://www.nealgrosskopf.com/tech/</link>
<description>a NG Designs Website...</description>
<language>en-us</language>
<copyright>Copyright &#169; 2008 NealGrosskopf.com</copyright>
<lastBuildDate>Fri, 10 Jul 2009 11:29:58 CST</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>NealGrosskopf.com RSS Generator</generator>
<managingEditor>Neal Grosskopf</managingEditor>
<webMaster>Neal Grosskopf</webMaster>
<image>
<title>NealGrosskopf.com</title>
<url>http://www.nealgrosskopf.com/files/ico/favicon.ico</url>
<link>http://www.nealgrosskopf.com</link>
</image>
<item>
<title>Emulate C#'s AppendFormat Method In Javascript Or Classic ASP</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=54</link>
<description>
<![CDATA[
<p>Let me preface this article with the statement that I am by no means a 'good' C# programmer. I've used it a bit at work (we're currently transitioning to it) so I've seen it here and there. 
I know a fair amount about Classic ASP however, so when I noticed a neat little feature in C#/ASP.NET I wanted to see if I could mimic it in other languages.</p>

<h3>AppendFormat Method</h3>

<p>The method in C# is called AppendFormat. It belongs to the System.text namespace which contains the StringBuilder class and AppendFormat is a method of this. Here's the 
<a href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.appendformat.aspx">MSDN article</a> if you'd like to find out more about it.</p>

<h3>Old School Method</h3>

<p>The neat thing about this method is it's an alternative to concatenation. Concatenation is basically the process of combining text and variables together like so:</p>

<code>
var a = "lorem ipsum dolor"
var b = "adipiscing elit"
document.write(a + " sit amet consectetur " + b)
</code>

<p>I think we're all pretty familiar with the code above. We're also probably familiar with some of the annoyances of the code above such as the fact that every time we combine text with a string variable, we need to start a quotation mark. 
Quotation marks are bothersome because sometimes (or rather often times in my case) we forget to properly close the ending quotation mark resulting in an error. More trouble can ensue when we have to start re-arranging variables and text 
within the concatenated string.</p>

<p>Another problem is I often forget to include the concatenation symbol in between my text and variables. This, if anything, is probably the number one mistake I make.</p>

<h3>Emulation Using Javascript</h3>

<p>As I reviewed my co-workers C# code, I felt that perhaps C# had a good point so I set out to emulate this in other languages.</p>

<p>First of all, below is the syntax we use for this alternative method. We use keyword itentifiers i.e. {NUMBER} to indicate an item should be placed in its spot. That number corresponds with the index of the array items on the right i.e NEAL, GROSSKOPF.
 The neat thing with this is we can easily move {0} arround without having to worry about closing the quotation marks and there is no need to use the concatenation symbol...ever!</p>

<code>
AppendFormat("Lorem ipsum dolor sit {0} {1} amet, consectetur {0} adipiscing {0} elit.", ["NEAL", "GROSSKOPF"])
</code>

<p>Below is the function I wrote to emulate this in Javascript. I pass the function an array, loop through it, and replace the placeholders with the array item in the same index.</p>

<code>
&lt;script type="text/javascript"&gt;
function AppendFormat(input,arr)
{
    for (i = 0; i < arr.length; i++)
    {
		while (input.indexOf("{"+i+"}") != -1)
		{
			input = input.replace("{"+i+"}", arr[i]);
		}
    }
    return input;
}

document.write(AppendFormat("Lorem ipsum dolor sit {0} {1} amet, consectetur {0} adipiscing {0} elit.", ["NEAL", "GROSSKOPF"]));
&lt;/script&gt;
</code>

<h3>Easily Re-Arrange Items</h3>

<p>The great thing about this, is we can easily re-arrange items simply by moving the placeholder around in the text block like so:</p>

<code>
AppendFormat("Lorem ipsum dolor sit {1} {0} amet, consectetur {1} adipiscing {0} elit.", ["NEAL", "GROSSKOPF"]);
</code>

<h3>Classic ASP Variant</h3>

<p>I also wanted to create the same function but in Classic ASP, my language of choice:</p>

<code>
function AppendFormat(input,arr)   
    for i = 0 to ubound(arr)
        input = replace(input,"{" & i & "}",arr(i))
    next   
    AppendFormat = input
end function

response.Write AppendFormat("Lorem ipsum dolor sit {0} {1} amet, consectetur {1} adipiscing {1} elit.", array("NEAL","GROSSKOPF"))
</code>

<p>As you can see, this is pretty much the basic princple that we used for the Javascript version.</p>

<h3>Conclusion</h3>

<p>I'm sure this article isn't as exciting as some of my others, and for all I know, most my readers are much better programmers than myself but I thought it was a cool idea so I wrote about it.</p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=54">View Comments [2]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Thu, 9 Jul 2009 07:03:53 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=54</guid>
<author>Neal Grosskopf</author>

</item>
<item>
<title>How To Create CSS Text/Font Gradients With CSS</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=53</link>
<description>
<![CDATA[
<p>Something that CSS is currently lacking is the ability to add gradients to our text blocks. Currently we can add drop shadows to text or change the color of it but not add gradients. I suspect 
that in the coming years this will be a new property but until then here is a method to do it.</p>

<h3>HTML Setup</h3>

<p>The HTML Setup is pretty simple. Just place an empty SPAN element inside your heading element:</p>

<code>
&lt;h3&gt;&lt;span&gt;&lt;/span&gt;Text Here&lt;/h3&gt;
</code>

<h3>Using JQuery to Automatically Insert SPAN Elements</h3>

<p>I think a few people might find the above code unsightly, so here's a method to leave the empty SPAN element out of your HTML and inject it via JQuery:</p>

<code>
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function(){
	$(&quot;h3&quot;).prepend(&quot;&lt;span&gt;&lt;\/span&gt;&quot;)
});
&lt;/script&gt;
</code>

<h3>CSS Setup</h3>

<p>The most important part of this code is setting the H3 element's position to relative. I'd also recommend setting the line-height to the same height as the font-size used and also reseting the margins back to zero.</p>

<code>
h3
{
font-size: 25px;
line-height: 25px;
margin: 0px;
position: relative; 
}
</code>

<p>Next, we position the empty SPAN element absolute and give it a height and width. Using this SPAN we can overlay various background-images over the H3 element.</p>

<code>
h3 span
{
display: block;
height: 26px;
position: absolute;
width: 100%;
}
</code>

<h3>Gradient Effect</h3>

<p>The first effect I'll demonstrate is a simple gradient. To do this we use a simple <a href="/tech/resources/53/gradient-white.png">white to transparent gradient image</a> and set it as the SPAN element's background-image. We can then 
position the background-image higher or lower depending on how strong we want the effect to be.</p>

<code>
h3 span { background: url(gradient-white.png) repeat-x left 0px; }
</code>

<div class="image-caption" style="width: 490px;">
	<a href="/tech/resources/53/?demo=1"><img src="/tech/resources/53/demo-1.png" alt="SPAN Element Overlay"></a>
	<p>In the example above, the black transparent area represents the SPAN while the black border represents the bounds of the H3 element.</p>
	<h3>Demo</h3>
	<p>When viewing the demo, take your cursor and select the gradient text. This will give you a good understanding of how the gradient works - </p>
	<p><b><a href="/tech/resources/53/?demo=1">View Demo &gt;&gt;</a></b></p>
</div>

<h3>Gradient Effect With Hover</h3>

<p>We can also apply a color change on hover with our gradient. Since the color change happens on the layer <b>behind</b> the gradient there is no additional CSS we must do other than change the H3's color when hovered.</p>

<code>
h3 span { background: url(gradient-white.png) repeat-x left 0px; }
h3:hover { color: #990000; }
</code>

<p><b><a href="/tech/resources/53/?demo=2">View Demo &gt;&gt;</a></b></p>

<h3>Two Tone Effect</h3>

<p>Another effect we can do is apply a two toned text color to our text. To do this we use a white rectangle with it's opacity lowered and then position it over our H3.</p>

<code>
h3 span { background: url(dual-white.png) repeat-x left 0px; }
</code>

<p><b><a href="/tech/resources/53/?demo=3">View Demo &gt;&gt;</a></b></p>

<h3>Sliding Door Effect</h3>

<p>Finally, my last effect uses JQuery to create an animation when the text is hovered. Using a little JQuery we can slide the SPAN's background-image up and down when hovered on
giving it sort of a 'garage door' effect.</p>

<code>
&lt;script type=&quot;text/javascript&quot; src=&quot;http://jqueryjs.googlecode.com/svn/trunk/plugins/backgroundPosition/jquery.backgroundPosition.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function(){
	$(&quot;h3 span&quot;).hover(
		function () {
			$(this).stop().animate({backgroundPosition: &quot;(0px -27px)&quot;}, 400); 
		}, 
		function () {
			$(this).stop().animate({backgroundPosition: &quot;(0px 0px)&quot;}, 400);
		}
	);
});
&lt;/script&gt;
</code>

<p><b><a href="/tech/resources/53/?demo=4">View Demo &gt;&gt;</a></b></p>

<p><b>Got any other effects that could be accomplished using a background-image? Share them below!</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=53">View Comments [1]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 1 Jul 2009 20:04:44 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=53</guid>
<author>Neal Grosskopf</author>
<category>css</category>
</item>
<item>
<title>Firefox 3.5 Set To Be Released Tuesday. Here Are Some Exciting New CSS Features In 3.5</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=52</link>
<description>
<![CDATA[
<div class="image-caption" style="width: 235px; float: right; margin: 0px 0px 20px 20px;">	
	<img src="/tech/resources/52/firefox.jpg" alt="Firefox 3.5">	
	<h3>Firefox 3.5</h3>	
	<p>Firefox 3.5 looks to have plenty of new features for web developers to play with. I'll go over some of new CSS features that are new to 3.5.</p>
</div>

<p>For much of my web career I've been an Internet Explorer stooge but when Firefox 3 came out last summer, I made the switch and never looked back. Firefox is just so heavily oriented to 
web developers and designers that it's hard to rationalize using any other browser. Sure, Opera and Safari have slightly better support but their lack of developer tools make me opt for Firefox.</p>

<p>Firefox 3.5, the latest version of the browser is set to be released this Tuesday. This intermediary release is probably aimed more at developers than end users and that's what excites me the most. After 
reviewing the <a href="https://developer.mozilla.org/En/Firefox_3.5_for_developers">3.5 release notes</a> I thought I'd point out a few of the new features that I'm most excited about.</p>

<h3>@font-face Support</h3>

<p>Since the inception of the web, we've been limited to about a dozen font types. With @font-face we're now able to choose from 1000's if not more. By embedding fonts our sites will be more accessible 
to people with screen readers, and it will also improve our search engine optimization by using pure text rather than images. This will also make our lives easier because we'll be able to change 
font properties via CSS rather than having to open up Photoshop or Fireworks to edit an image file.</p>

<p>Currently browsers using Webkit also support @font-face and Opera 10 will support it. Internet Explorer has it's own proprietary method.</p>

<code>
@font-face
{
font-family: "Bitstream Vera Serif Bold";
src: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");
}

body { font-family: "Bitstream Vera Serif Bold", serif }
</code>

<h3>Box Shadow &amp; Text Shadow</h3>

<p>A personal favorite of mine is the box-shadow property. Creating drop shadows on the web can be pretty painful, especially when the size of the box may vary from page to page. With the 
new box shadow property we won't need to worry about that anymore. Safari also supports box-shadow while Opera and IE do not. Firefox 3.5 will also support text-shadow (with no -mox prefix). This means that Opera, Safari and Firefox 
all support this while IE, again has it's own proprietary method.</p>

<code>
div {  -moz-box-shadow: #000 10px 5px 5px; }
h2 { text-shadow: #000 1px 1px 2px; }
</code>

<h3>CSS Transformations</h3>

<p>Originally introduced by Safari/Webkit we now have the ability to use CSS Transformations. I haven't delved into this much but I have used CSS Transitions a few times on various projects which I wish 
they would have implemented instead.</p>

<h3>New CSS Selectors</h3>

<p>Probably the most important aspect of CSS is the ability to select elements. Firefox 3.5 gives us a few more tools to achieve this. Having used JQuery extensively for the past several months, I've 
found myself using almost all of these to circumvent browser's lack of support. With Firefox 3.5 we'll be able to natively use these selectors (and more):</p>

<code>
/* Zebra Stripes */
tr:nth-child(odd) { background: #fff; }
tr:nth-child(even) { background: #eee }

/* Alternate Method for Zebra Stripes */
tr:nth-of-type(odd) { background: #fff; }
tr:nth-of-type(even) { background: #eee }

/* Last 5 LIs of a List */
li:nth-last-child(-n+5) { color: #ccc; }

/* Alternate Method */
li:nth-last-of-type(5) { color: #ccc; }
</code>

<h3>CSS Media Queries</h3>

<p>Media queries allows web developers to target certain scenarios that end users may have. For instance in the example below I'm adjusting the width of my #content DIV if 
the end user is on a PDA and has a screen size smaller than 300px.</p>

<code>
@media handheld and (max-width: 300px)
{
#content { width: 300px; }
}
</code>

<p>You could also take this a step further and mine for information about your end users by testing the size of elements on your page:</p>

<code>
&lt;style type=&quot;text/css&quot;&gt;
@media handheld and (max-width: 300px)
{
#content { width: 300px; }
}
&lt;/style&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
if ($(#content).width() = "300px")
{
//do something, i.e. email, write to text file etc.
}
&lt;/script&gt;
</code>

<h3>Other New CSS Features</h3>

<p>Here's a list of a few other CSS features I didn't mention above.</p>

<ol>
	<li>opacity (no longer -moz-opacity)</li>
	<li>word-wrap</li>
	<li>-moz-border-image</li>
	<li>-moz-column-rule</li>
	<li>-moz-column-rule-width</li>
	<li>-moz-column-rule-style</li>
	<li>-moz-column-rule-color</li>
</ol>

<h3>Further Reading:</h3>

<ul>
	<li><a href="https://developer.mozilla.org/En/Firefox_3.5_for_developers">Firefox 3.5 for Developers</a></li>
	<li><a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(CSS)">Comparison of Layout Engines (CSS) - Wikipedia</a></li>
	<li><a href="http://www.w3.org/TR/css3-selectors/">CSS 3 Selectors</a></li>
</ul><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=52">View Comments [0]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Sun, 28 Jun 2009 21:22:58 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=52</guid>
<author>Neal Grosskopf</author>

</item>
<item>
<title>YouTube Hacking: How To Retrieve Video Screenshots From YouTube Videos</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=51</link>
<description>
<![CDATA[
<p>It is often useful to display a preview of an embedded YouTube video on your website rather than the long winded HTML object/embed code. Fortunately YouTube provides us with an undocumented way to retrieve video stills.</p>

<p>Each video has three separate stills that you can choose from after you upload the video. YouTube, now also support high definition videos and because of that, provides higher quality stills as well. Below I will run through all the various 
YouTube images that are available for each video.</p>

<h3>The Setup</h3>

<p>Below is a break down of the YouTube URL. For all of my examples I have chosen my new favorite YouTube video <a href="http://www.youtube.com/watch?v=nda_OSWeyn8">Leprechaun in Mobile, Alabama</a>.</p>

<table class="data">
<caption>Breakdown Of URL</caption>
<tr>
	<th>Domain</th>
	<th>Folder</th>
	<th>Video</th>
	<th>Image</th>
</tr>
<tr>
	<td>http://i.ytimg.com</td>
	<td>/vi/</td>
	<td>nda_OSWeyn8</td>
	<td>default.jpg</td>
</tr>
</table>

<h3>The Default YouTube Image</h3>

<p>YouTube's default video image, i.e. the image that the uploader has chosen, can be retrieved by using the default.jpg image. Its dimensions are 120px x 90px and its file size is 3.07KB. You may want to use this image when you want the exact image the 
original uploader intended.</p>


<img src="http://i.ytimg.com/vi/nda_OSWeyn8/default.jpg" alt="default.jpg" class="frame">


<h3>Series Images 0 - 4 </h3>

<p>Next YouTube provides us with images 0.jpg, 1.jpg, 2.jpg &amp; 3.jpg. These 4 images are basically the 4 images the uploader can chose from after uploading a video.</p>

<p>Image 0.jpg is larger, sized at 320px x 240px and its file size is 11.77KB.</p>

<p><img src="http://i.ytimg.com/vi/nda_OSWeyn8/0.jpg" alt="0.jpg" class="frame"></p>

<p>Images 1, 2, 3 are smaller images sized at 130px x 97px.</p>

<p>
<img src="http://i.ytimg.com/vi/nda_OSWeyn8/1.jpg" alt="1.jpg" class="frame inline">
<img src="http://i.ytimg.com/vi/nda_OSWeyn8/2.jpg" alt="2.jpg" class="frame inline">
<img src="http://i.ytimg.com/vi/nda_OSWeyn8/3.jpg" alt="3.jpg" class="frame inline">
</p>

<h3>High Quality Images</h3>

<p>Next, YouTube provides us with what they label 'high quality' images. These are named hq1.jpg, hq2.jpg, hq3.jpg &amp; finally hqdefault.jpg.</p>

<p>Images 1, &amp; 3 are smaller images sized at 130px x 97px. Even those these are prefixed with 'hq' the images appear to be of the same quality that images 1, 2, &amp; 3 were.</p>

<img src="http://i.ytimg.com/vi/nda_OSWeyn8/hq1.jpg" alt="hq1.jpg" class="frame inline">
<img src="http://i.ytimg.com/vi/nda_OSWeyn8/hq3.jpg" alt="hq3.jpg" class="frame inline">

<p>Image 2 is larger and sized at 480px x 360px. Its file size is 14.63KB. I'm not sure why this image is larger because it seems to break the pattern of the other images. It does appear to be the default image so perhaps that has something to do with it.</p>

<img src="http://i.ytimg.com/vi/nda_OSWeyn8/hq2.jpg" alt="hq2.jpg" class="frame">

<p>Finally, the hqdefault.jpg is the largest and highest quality of all the images. It is sized at 480px x 360px. Its file size is 14.63KB. I would recommend using this image as your primary image due to its quality.</p>

<img src="http://i.ytimg.com/vi/nda_OSWeyn8/hqdefault.jpg" alt="hqdefault.jpg" class="frame">

<h3>Conclusion</h3>

<p>You now probably know more than you ever wanted to know about the available images YouTube provides us for each video. Feel free to bookmark this article as you'll probably need to refer back to it someday while working on a project.</p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=51">View Comments [4]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 10 Jun 2009 21:43:51 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=51</guid>
<author>Neal Grosskopf</author>
<category>youtube</category>
</item>
<item>
<title>Quick &amp; Easy Ways To Spice Up Your Web Site's Font Styling</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=50</link>
<description>
<![CDATA[
<p>One of the key elements of a good website design is the styling of the site's font. I think this is an area where many of the more 'mathematically inclined' web developers struggle. To help those out that 
are willing to take it, I'll show you how to take the default Times New Roman 16px font and make your design shine.</p>

<p>By default browsers will apply the following settings to your font out of the box:</p>

<code>
body
{
color: #000000;
font-family: "Times New Roman";
font-size: 16px;
letter-spacing: 0px;
line-height: 18px;
text-align: left;
}
</code>

<p>We're all familiar with the appearance of this font, and often times, are turned off by this font styling because of how common and boring it looks.</p>

<h3>Gray is the New Black</h3>

<p>First lets get rid of that default and obnoxious font color #000000. I recommend you choose a value between #888888 and #333333 for your website's font color. If you need help picking a color I recommend 
using <a href="http://meyerweb.com/eric/tools/color-blend/">Eric Meyer's Color Blend Tool</a>. I would also like to point out that using a color lighter than #888888 will not have enough contrast on a 
white background and will be difficult for your users to read. On the flip side, a color darker than #333333 is starting to get into that loud and obnoxious range again. I personally like to 
choose #555555.</p>

<code>
body
{
color: #555555;
}
</code>

<h3>Times New What?</h3>

<p>Next lets 'can' Times New Roman for a different, less 'plain' font. <i>A side note, Times New Roman is a great font, and there's a time and place for it, but being the browser default font, I tend to shy away from using 
it too often.</i></p>

<p>Font types can also be broke into two different groups. Serif and Sans Serif. Sans serifs fonts do not have the small tails after letters. An example of a sans serif font is <span style="font-family: Arial;">Arial</span>. An example of a serif font is 
<span style="font-family: 'Times New Roman';">Times New Roman</span>. Below is a list of some of the more content-useful fonts to chose from when designing a website. Notice how some of the fonts take up more space than others:</p> 

<h4>Sans Serif</h4>

<ol style="font-size: 20px;">
	<li style="font-family: Arial;">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Arial</li>
	<li style="font-family: Verdana;">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Verdana</li>
	<li style="font-family: Tahoma;">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Tahoma</li>	
	<li style="font-family: 'Trebuchet MS';">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Trebuchet MS</li>
</ol>

<h4>Serif</h4>

<ol style="font-size: 20px;">	
	<li style="font-family: 'Times New Roman';">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Times New Roman</li>
	<li style="font-family: Georgia;">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Georgia</li>
	<li style="font-family: 'Palatino Linotype';">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Palatino Linotype</li>
	<li style="font-family: 'Lucida Sans';">ABCDEFGHIJKLMNOPQRSTUVWXYZ - Lucida Sans</li>	
</ol>

<p>Of the choices above, I find Arial to be the easiest on the eyes. If you want to be a bit edgier you can chose fonts 2-4 which are used a bit less than the others.</p>

<p><b>Need help?</b> Check out my extremely useful <b><a href="/tech/resources/50/font-comparison.asp">Font Comparison Page</a></b> to see which font you like best.</p>
 
<h3>Size Matters</h3>

<p>By default browsers will assign your font a font-size of 16px. While 16px is big enough that most users will find it comfortable to read, 12px is really the internet's de facto font-size. Visit some of your favorite websites and you'll discover that almost all of them
use 12px as the main content's font-size. It's perfectly ok to use other font sizes, but for your main content I'd stick with 12px - 14px.</p>

<code>
body
{
font-size: 12px;
}
</code>

<h3>Give Your Font Some Breathing Room With Line-Height</h3>

<p>Probably the single most easy CSS change you can make to your font, with the biggest impact, is to adjust your line-height. Line-Height is the spacing between the lines of text on your web pages. By default browsers set this to 18px. At 18px you will have about
9px of space between your top and bottom line.</p>

<div class="image-caption" style="width: 545px;">
	<a href="/tech/resources/50/line-height.png"><img src="/tech/resources/50/line-height.png" alt="Line Height Comparison"></a>	
	<h3>Line Height Comparison</h3>	
	<p>The first block of text has the default line-height of 18px while the second block has a line-height of 27px. Notice how the second block of text is easier to read.</p>	
</div>

<h3>Straighten Out With Text-Align: Justify</h3>

<p>My final recommendation is to experiment with the CSS property text-align, specifically with the justify value. By default, browsers will assign the value of text-align: left; to your text. Using the value of 'justify' we can make all of our blocks of text 
have straight edges on the left and right.</p>

<div class="image-caption" style="width: 455px;">
	<a href="/tech/resources/50/text-align.png"><img src="/tech/resources/50/text-align.png" alt="Text Align Comparison"></a>	
	<h3>Text Align Comparison</h3>	
	<p>The first block has text-align: left; while the second block has text-align: justify; I find that the justified text helps reinforce the grid layout in your web design.</p>	
</div>

<h3>Putting It All Together</h3>

<p>Below is a summary of everything I've just went through. Also check out my <a href="/tech/resources/50/results.asp">step by step results page.</a></p>

<code>
body
{
color: #555555;
font-family: Arial;
font-size: 12px;
line-height: 27px;
text-align: justify;
}
</code>

<p><b><a href="/tech/resources/50/results.asp">View the metamorphoses from Times New Roman to my example above. &gt;&gt;</a></b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=50">View Comments [3]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 3 Jun 2009 21:41:27 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=50</guid>
<author>Neal Grosskopf</author>
<category>css</category><category>font</category>
</item>
<item>
<title>Browser Comparison of Available Print Area Width</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=49</link>
<description>
<![CDATA[
<p>This article is a companion article to my "<a href="/tech/thread.asp?pid=43">Browser Comparision of Available Screen Width When Using 1024x768</a>" which I think many people found useful. The other day at work a co-worker complained to me that
a webpage was getting cropped off when printing it. I then had to tinker with the width of a few different elements on the page to get it to fit. After finishing that I began to wonder, what the max-width is that can be used various browsers when printing.</p>

<p>I ran a quick test of all the browsers I had installed to see at what width, would the browser's print preview window crop off my fixed width DIV. Here are the results I found:</p>

<table class="data">
<caption>Browser Comparision of Available Print Area Width</caption>
<tr>
	<th>Browser</th>
	<th>Max-Width</th>
	<th>Default Settings</th>
</tr>
<tr>
	<td>Firefox 3 @ 100%</td>
	<td>686px</td>
	<td>Shrink To Fit</td>
</tr>
<tr>
	<td>Safari 4</td>
	<td>718px</td>
	<td>> 718px Triggers Shrink To Fit</td>
</tr>
<tr>
	<td>Opera 9.5 @ 100%</td>
	<td>730px</td>
	<td>80% & Shrink To Fit</td>
</tr>
<tr>
	<td>IE8 @ 100%</td>
	<td>670px</td>
	<td>Shrink To Fit</td>
</tr>
<tr>
	<td>IE7 @ 100%</td>
	<td>670px</td>
	<td>Shrink To Fit</td>
</tr>
<tr>
	<td>IE6 @ 100%</td>
	<td>670px</td>
	<td>75%</td>
</tr>
</table>

<h4>Notes On My Results</h4>

<p>You'll notice that many browser's default settings are set to 'shrink to fit'. This may solve the problem of extra-wide content when printing most of the time. I also decided, that when given the option, I would set the resize option to 100% to make all my 
browsers equal.</p>

<p>Also when I ran the test, I did not modify the page's margins which I'm sure would have an affect on the results.  Safari also had an interesting feature that triggered shrink to fit when the content grew beyong it's max-width. 
I thought this was a pretty useful feature compared to most the other browsers.</p>

<p>Other results we can see, is Internet Explorer has stayed tried and true throughout it's past three versions sticking with 670px each time as it's max-width. Opera provides the most real-estate at 730px.</p>

<h4>Conclusion</h4>

<p>When writing print stylesheets knowing that the lowest common deneminator is Internet Explorer at 670px will help you when creating print stylesheets.</p>

<h4>Related Articles</h4>

<ul>
	<li><a href="/tech/thread.asp?pid=43">Browser Comparision of Available Screen Width When Using 1024x768</a></li>
	<li><a href="/tech/thread.asp?pid=39">Go Green With CSS Print Stylesheets</a></li>
	<li><a href="/tech/thread.asp?pid=8">Using Media Targeting With CSS With @Media</a></li>
</ul><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=49">View Comments [1]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 26 May 2009 18:35:04 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=49</guid>
<author>Neal Grosskopf</author>
<category>browser comparision</category>
</item>
<item>
<title>Gallery of Yahoo.com's Year Long Home Page Redesign</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=48</link>
<description>
<![CDATA[
<div class="image-caption" style="width: 216px; float: right; margin: 0px 0px 15px 15px;">
	<img src="/tech/resources/48/yahoo_logo.png" alt="Yahoo!" class="frame">
	<h3>Yahoo! Redesign</h3>
	<p>Yahoo! has been in the midst of <a href="http://kara.allthingsd.com/20090214/how-is-yahoos-massive-metro-homepage-redesign-going-it-depends-on-who-you-ask/">redesigning their home page</a> since <a href="http://kara.allthingsd.com/20080917/a-first-look-at-the-new-yahoo-homepage-redesign-apps-rule/">September of 2008</a>. Their last redesign was in August of 2006.</p>
</div>

<p>I've been using Yahoo! since 1996, and over the years I've become quite attached to my beloved Yahoo! even when users started to ditch them for
other websites. So, it's natural for me to get excited when Yahoo! gives me a sneak peak at their new home page (usually located at m.www.yahoo.com).</p>

<p>One reason that I still like Yahoo! is I am primarily a designer...not a developer. As a designer, I'm drawn to websites that have more design elements and style. This is one reason why I prefer Yahoo! 
to Google. I feel that Yahoo! has a bit more personality compared to Google. For more on that see - <a href="http://blog.fawny.org/2009/03/19/google-antidesign/">http://blog.fawny.org/2009/03/19/google-antidesign/</a>. 
Still, I won't deny that Google has a superior search engine.</p>

<p>What confuses me, is I have been randomly getting these 'sneak peaks' since last November. I'm starting to wonder if Yahoo! will ever release their newly improved home page. 
Every time I get a sneak peak I take a screenshot to compare to my last screenshot. Now that I have a couple different screenshots I thought I'd share them with the rest of the world.</p>

<h4>Yahoo! Today</h4>

<p>First, let's check out the current home page of the site, which has been their design since August of 2006.</p>

<a href="/tech/resources/48/yahoo_current.jpg"><img src="/tech/resources/48/yahoo_current_thumb.jpg" alt="Yahoo! Currently" class="frame"></a>

<div class="hr"><hr></div>

<h4>November 2nd, 2008 Yahoo! Redesign</h4>

<p>Here is the first screenshot I have from my collection. The site's main structure is very similar to the current site, but the major difference is the background gradient and the dark blue bar 
on the left of the page. The right hand applications area has also be redesigned.</p>

<a href="/tech/resources/48/yahoo_redesign_11-2-2008.jpg"><img src="/tech/resources/48/yahoo_redesign_11-2-2008_thumb.jpg" alt="November 2nd, 2008 Yahoo! Redesign" class="frame"></a>

<div class="hr"><hr></div>

<h4>April 6th, 2009 Yahoo! Redesign</h4>

<p>Yahoo's next iteration is once again a small evolution from the November design, except they softened the look of the their blue left navigation bar, which I think was a good decision. You'll also notice
  this version of the redesign is much wider than the previous version. I checked my screenshot and it's roughly 1165px wide. This seems like an odd width to choose unless of course, they are using a 
 min-width/max-width layout.</p>
 
<p>Another interesting change in this version is the choice of Times New Roman/Georgia as a main font type. Times New Roman is rarely used since it's usually the browser's default font choice.</p>

<a href="/tech/resources/48/yahoo_redesign_4-6-2009.jpg"><img src="/tech/resources/48/yahoo_redesign_4-6-2009_thumb.jpg" alt="April 6th, 2009 Yahoo! Redesign" class="frame"></a>

<div class="hr"><hr></div>

<h4>May 13th, 2009 Yahoo! Redesign</h4>

<p>Then today, I opened up IE6 to test something out and was once again, given a sneak peak at another iteration of Yahoo's redesigned home page. This version is radically different than April's and November's,
but looks much closer to their current design. They also decided to loose the dark gradient background in favor of a softer gradient. Also, the right hand applications area has been removed in favor of a 'top searches' 
content area. The applications were then moved to the left bar. I think this version will be an easier transition for people favoring their current design.</p>

<a href="/tech/resources/48/yahoo_redesign_5-13-2009.jpg"><img src="/tech/resources/48/yahoo_redesign_5-13-2009_thumb.jpg" alt="May 13th, 2009 Yahoo! Redesign" class="frame"></a>

<h4>Wrap Up</h4>

<p>It's interesting to see the various interations of Yahoo's redesign process. It almost appears they are coming full circle back to their current design with a few modifications.</p>

<p><b>What do you think of Yahoo's redesigned website?</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=48">View Comments [1]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 13 May 2009 22:42:45 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=48</guid>
<author>Neal Grosskopf</author>

</item>
<item>
<title>HTML Vs. BODY Element: What's the Difference?</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=47</link>
<description>
<![CDATA[
<p>I've always been interested in the subtle differences between the HTML and BODY elements when it comes to CSS. Many designers reference the two elements interchangeably in their stylesheets. 
Often times it's perfectly ok to place properties in either one, but there are certain instances where you'll want to chose one over the other.</p>

<h4>Default Rendering of HTML and BODY Elements</h4>

<p>By default, all major browsers assign the BODY element a margin of 8px. We often see this in CSS resets, setting the margin back to 0px. As far as I'm aware there is no other default CSS applied to either elements other than your usual font-size, color etc. 
The HTML element, in comparison, has a margin set to 0px. Also neither of the two elements have padding, which is often seen in CSS resets as well.</p>

<code>
html { margin: 0px; }
body { margin: 8px; }
</code>

<h4>Overflow/Scrollbars</h4>

<p>Another thing I like to place in my stylesheets is some CSS to always display browser scrollbars. I do this because it annoys me when I browse to one page that has a lot of content and then browse to another page that has little content, and
my main content DIV is bouncing back and forth. In order to fix this you need to place 'overflow-y: scroll;' on your HTML element. If this property is assigned to the BODY element, nothing 
happens and it will not work, thus another big difference between the two elements.</p>

<code>
html { overflow-y: scroll; }
</code>

<h4>Scrollbar Colors: HTML or BODY?</h4>

<p>In Internet Explorer the scrollbar color properties need to be applied to the HTML element rather than the BODY element in order to work. Safari has also added scrollbar styling in their recent build, so 
we'll have to see how they implemented this as well.</p>

<code>
html
{
scrollbar-face-color: #000; 
scrollbar-highlight-color: #ccc; 
scrollbar-3dlight-color: #999; 
scrollbar-darkshadow-color: #666; 
scrollbar-shadow-color: #555; 
scrollbar-arrow-color: #fff; 
scrollbar-track-color: #ddd;
}
</code>

<h4>Background Images and Colors</h4>

<p>Another major difference between the HTML element and the BODY element is background-colors and background-images. The BODY element mimics the default behavior of a DIV element. It's 
height relies on the content within it. The HTML element on the other hand, spans the entire viewport regardless of the content within it. If you set a background-image to the BODY element and position it bottom,
it may not have the desired effect you intended, while the HTML element's background-image will fall at the bottom of the screen regardless of the content within it.</p>

<img src="/tech/resources/47/html_vs_body.png" alt="BODY Vs. HTML Element Background Colors">

<h4>In Conclusion</h4>

<p>Probably the biggest take-away from this article would be background-images. I almost always use both the HTML and BODY elements to apply background-images to, and it's good to remember that the BODY element may not always hit the 'bottom' of the viewport.</p>

<p><b>Know of any other differences? Share your thoughts below...</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=47">View Comments [4]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Sun, 10 May 2009 20:02:04 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=47</guid>
<author>Neal Grosskopf</author>
<category>html</category>
</item>
<item>
<title>CSS Template Layouts: A Simpler CSS Layout System, Now Possible With JQuery</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=46</link>
<description>
<![CDATA[
<div class="image-caption" style="width: 235px; float: right; margin: 0px 0px 20px 20px;">	
	<img src="/tech/resources/46/grid-example.png" alt="Grid Example">	
	<h3>Skip To Demos:</h3>
	<ol>
		<li><a href="/tech/resources/46/?demo=1">Basic Template Layout</a></li>
		<li><a href="/tech/resources/46/?demo=2">Reversed Basic Template Layout</a></li>
		<li><a href="/tech/resources/46/?demo=3">2 Columns With Header &amp; Footer</a></li>
		<li><a href="/tech/resources/46/?demo=4">3 Columns With Header &amp; Footer</a></li>
		<li><a href="/tech/resources/46/?demo=5">Easily Re-Arrange Columns</a></li>
		<li><a href="/tech/resources/46/?demo=6">Easily Re-Arrange Rows</a></li>
	</ol>
</div>

<p><b class="highlight">Updated May 6th:</b> For the longest time I've been waiting for browsers to support the CSS Template Layout module. Today, I found out that <a href="http://a.deveria.com/?p=236">Alexis Deveria</a> has given the web community the 
gift we've all been waiting for. Using JQuery and a plugin we can now take full advantage of the <a href="http://www.w3.org/TR/css3-layout/">CSS Template Layout Module</a>.</p>

<p>Historically, we've used containers and floats to create our websites but with this method we may possibly be able to make that method history. With template layouts we 
can finally have <b>source order independence</b> that has plagued the <a href="http://www.sitepoint.com/books/csswrong1/">CSS Display: Table</a>, <a href="http://www.flownet.com/ron/css-rant.html">HTML TABLEs</a> and CSS Float techniques. 
We can also ignore absolute position methods which I've always disliked. Finally the template layout method also handles equal column heights right out of the box.</p>

<h4>Recap: Template Layout Gives Us</h4>

<ul>
	<li>Pure source order independence</li>
	<li>Equal height columns</li>
	<li>No need to overflow containers</li>
	<li>No need for hacks</li>
	<li>Advanced grid layouts </li>
	<li>Easy source arrangement for different media types i.e print, mobile</li>
</ul>

<h4>A Quick Overview</h4>

<p>Template layout works like a grid. We're all familiar with the dozens of CSS libraries that attempt to give designers a grid to work with. I personally despise CSS libraries but that's another 
story. With template layout we can create all of those complex grids that designers dreamed up with HTML TABLEs, but using only CSS and semantic HTML instead.</p>

<h4>Step 1: Importing JQuery and the Plugin</h4>

<p>The very first thing we'll need to do is import JQuery and the JQuery Template Layout Plugin</p>

<code>
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://css-template-layout.googlecode.com/files/jquery.tpl_layout1.1.1.js&quot;&gt;&lt;/script&gt;
</code>

<p>Next we'll need to initialize the plugin using JQuery's document.ready event:</p>

<code>
$(document).ready(function()
{
$.setTemplateLayout()
});
</code>

<h4>HTML Setup</h4>

<p>The HTML setup can be approached in the same fashion we would approach the old float based layout system. For the sake of this tutorial I've named my DIVs a, b, c, d, e rather than header, nav, 
content, aside and footer.</p>

<code>
&lt;div id=&quot;template&quot;&gt;
	&lt;div id=&quot;a&quot;&gt;&lt;/div&gt; 
	&lt;div id=&quot;b&quot;&gt;&lt;/div&gt; 
	&lt;div id=&quot;c&quot;&gt;&lt;/div&gt; 
	&lt;div id=&quot;d&quot;&gt;&lt;/div&gt; 
	&lt;div id=&quot;e&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
</code>

<h4>CSS Setup</h4>

<p>We start like we would with any other layout system by centering our main #template DIV and giving it a width. I chose 1000px simply because it's easier to do math with.</p>

<code>
#template
{
margin: auto;
width: 1000px;
}
</code>

<h4>Position: What?; Think Grid Placeholders</h4>

<p>Next we need to assign each of our child DIVs a position name. Again for the sake of this demo I've given each DIV the same position name as it's ID name:</p>

<code>
#a { position: a; }
#b { position: b; }
#c { position: c; }
#d { position: d; }
#e { position: e; }
</code>

<p>Think of each position name like a variable that will be used to place each DIV in a grid. My code example above would probably look like this in a production environment:</p>

<code>
#header { position: a; }
#nav { position: b; }
#content { position: c; }
#aside { position: d; }
#footer { position: e; }
</code>

<h4>::Slot() Pseudo Class</h4>

<p>Template Layouts introduces a new CSS pseudo class called ::slot(). Think of slots like a content placeholder. Only certain CSS properties can be applied to slots such as background colors and images.</p>

<code>
#template::slot(a) { background: #eee; }
#template::slot(b) { background: #ddd; }
#template::slot(c) { background: #ccc; }
#template::slot(d) { background: #bbb; }
#template::slot(e) { background: #aaa; }
</code>

<h4>Display: Grid:</h4>

<p>Using our placeholder names we can arrange our DIVs in an equal height grid system using the following syntax:</p>

<code>
#template { display: "abcde"; }
</code>

<p><a href="/tech/resources/46/?demo=1" class="b">View demo of this code &gt;&gt;</a></p>

<p>We could also easily re-arrange our DIVs by simply ordering the placeholder names like so:</p>

<code>
#template { display: "edcba"; }
</code>

<p><a href="/tech/resources/46/?demo=2" class="b">View demo of this code &gt;&gt;</a></p>

<p>Note that what we just did is not possible using Sitepoint's <del>evil</del> display: table; method, and is not <i>easily</i> possible using the standard float system. It is possible with absolute positioned elements but
once again we're trying to avoid that.</p>

<h4>Real World Example of Template Layouts</h4>

<p>Until now, I've only shown you the basics of template layouts. I've found that new programming techniques often make little sense until put into a real-world perspective. Lets create a two column template layout:</p>

<code>
#template
{
display:
"aa" /150px
"bc"
"dd"
250px 750px
;
}
</code>

<p><a href="/tech/resources/46/?demo=3" class="b">View demo of this code &gt;&gt;</a></p>

<p>A break down of that code:</p>

<ul>
	<li>Line 4 states that the "a" DIV should occupy 2 columns in our grid row and /150px states that it should have a height of 150px.</li>
	<li>Line 5 states that the "b" DIV should occupy 1 slot in the left row column and "c" should  occupy the right column in row 2.</li>
	<li>Line 6 states that the "d" DIV should occupy 2 columns</li>
	<li>Line 7 states that the first column should be 250px wide and the second column 750px wide</li>
</ul>

<h4>Easy 3 Column Layout With CSS</h4>

<p>We can easily take our <b>same HTML structure</b> and make it a three column layout with the template layout system:</p>

<code>
#template
{
display: 
"aaa" /150px
"bcd"
"eee"
* 500px *
;
}
</code>

<p><a href="/tech/resources/46/?demo=4" class="b">View demo of this code &gt;&gt;</a></p>

<p>A break down of that code:</p>

<ul>
	<li>Line 4 states that the "a" DIV occupies 3 slots in our grid and have a height of 150px; This is our #header.</li>
	<li>Line 5 states that the "b" DIV occupies slot 1, of row 2, the "c" DIV occupies slot 2 of row 2 and finally the "d" DIV occupies slot 3 of row 2.  "b" is our #nav, "c" is our #content and "d" is our #aside.</li>
	<li>Line 6 states that the "e" DIV occupies 3 slows of row 3. This DIV acts as our #footer.</li>
	<li>Line 7 states that both	column 1 and column 3 have a variable width (250px) while the second column has a width of 500px consuming the rest of the available space.</li>
</ul>

<h4>Easily Re-Arrange Columns</h4>

<p>The best thing about this approach is we can quickly re-arrange our content in the grid. This might come in handy when displaying content to different media types such as @print and @handheld. Take 
a look at how easy we could switch our columns around:</p>

<code>
#template
{
display: 
"aaa" /150px
"dcb"
"eee"
* 500px *
;
}
</code>

<p><a href="/tech/resources/46/?demo=5" class="b">View demo of this code &gt;&gt;</a></p>

<h4>Easily Re-Arrange Rows</h4>

<p>If ever needed, we could also flip our #header and #footer DIVs like so:</p>

<code>
#template
{
display: 
"eee" /150px
"dcb"
"aaa"
* 500px *
;
}
</code>

<p><a href="/tech/resources/46/?demo=6" class="b">View demo of this code &gt;&gt;</a></p>

<h4>Argument Against Using This?</h4>

<p>I can think of a few reasons not to use this:</p>

<ul>
	<li>Requires Javascript &amp; JQuery</li>
	<li>Layout not triggered until the DOM is loaded</li>
	<li>Not thoroughly tested in all browsers (IE6 specifically)</li>
	<li>Syntax has a high learning curve at first</li>
	<li>Currently no browsers (that I'm aware of) support this natively</li>
</ul>

<h4>Should You Use This?</h4>

<p>Absolutely! While I'm unsure if this is ready for large &amp; complicated designs I think as a community we should start testing this new approach out which is currently in the working draft stage 
of the W3C spec process.</p>

<p><b>Love it? Hate it? Speak your mind below...</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=46">View Comments [18]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 6 May 2009 22:07:45 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=46</guid>
<author>Neal Grosskopf</author>
<category>css</category><category>css3</category><category>jquery</category>
</item>
<item>
<title>Create a JQuery Content Slider Using Pure CSS</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=45</link>
<description>
<![CDATA[
<p>I've been working with JQuery a lot lately, both at work and at home, although my primary specialty is CSS, usually complex CSS. I have so far created several '<a href="http://route.huebsch.com/">JQuery</a> <a href="/pages/about.asp">Sliders</a>' as 
I like to call them. Then the thought occurred to me, could a JQuery Slider be created using only CSS?</p>

<div class="image-caption" style="width: 550px;">
	<a href="/tech/resources/45/"><img src="/tech/resources/45/slider-example.jpg" alt="Slider Example"></a>
	
	<h3>View Slider Example</h3>
	
	<p>If you want to skip the article and go straight to the final product view my <a href="/tech/resources/45/">CSS Only JQuery Emulation Slider Demo</a>.</p>
	
	<p class="b i">Note: you will need to use Safari in order to view the transition effect and I highly recommend that you do.</p>
</div>

<h4>My Goals Of This Proof Of Concept</h4>

<p>My mission was to create a working example without the aid of JavaScript, using layers in CSS and using CSS3 transitions to give the slider the necessary animation.</p>

<h4>HTML Structure</h4>

<p>The HTML in it's most basic form consists of a container DIV and a simple unordered list. I also used P elements which could probably be removed depending on hardcore you want to be about extra elements. 
I did this because I needed to style the LIs differently than the text contained within the LIs such as floating, width etc.</p>

<code>
&lt;div id=&quot;slider&quot;&gt;
  
	&lt;ul&gt;
		&lt;li&gt;
			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
		&lt;/li&gt; 
		&lt;li&gt;
			&lt;p&gt;Sed ut est. Curabitur molestie. Cras pellentesque.&lt;/p&gt;
		&lt;/li&gt; 
		&lt;li&gt;
			&lt;p&gt;Maecenas consequat consequat lectus.&lt;/p&gt; 
		&lt;/li&gt; 
		&lt;li&gt;
			&lt;p&gt;In vel lorem quis turpis auctor volutpat.&lt;/p&gt;
		&lt;/li&gt;
	&lt;/ul&gt;

&lt;/div&gt;
</code>

<p>I use the following CSS to style the above elements.</p>

<code>
#slider, ul, li { height: 300px; }
#slider, li { position: relative; width: 500px; }

#slider
{
margin: auto;
overflow: hidden;
padding: 10px;
}

li { float: left; }
</code>

<h4>Positioning Our Slider</h4>

<p>Next we need to set our UL which is the container of the slider's LIs. It needs a width set on it which is the <b>width of the LIs X the total number of LIs</b>. If each LI were 500px wide and we had 4 LIs then the total width would be 2000px.
 I should note that you will also most likely have a margin between each of the LIs which this would need to be accounted for in the above.</p>

<code>
ul
{
list-style-type: none;
position: absolute;
left: 0px;
top: 0px;
width: 2000px;
}
</code>

<p>Next we move our UL element left baed on what LI we want to show in our slider. Look at the example below to see how I accomplish this. Each color block represents a LI. The block positioned over the black area represents the current visible LI.</p>

<p><img src="/tech/resources/45/slider-positions.png" alt="Slider Positions"></p>


<h4>Adding Persistence To Our Slider With :Target</h4>

<p>By far the most complicated part of this proof-of-concept is accomplishing all of this without the assistance of variables that JavaScript allows us to use. CSS variables are not yet a true reality (although one could argue that CSS Counters are a form 
of CSS Variables). To overcome this obstacle I used the CSS3 :target pseudo selector. The :target pseudo selector works with URL fragments like below:</p>

<code>
&lt;a href=&quot;#page-anchor&quot;&gt;go to page anchor&lt;/a&gt;
&lt;div id=&quot;page-anchor&quot;&gt;&lt;/div&gt;
</code>

<p>Using CSS we can actually style the page-anchor DIV if our page's URL contains #page-anchor like so: http://www.example.com/page.html#page-anchor.</p>

<code>
#page-anchor:target { background: red; }
</code>


<h4>Using :Target To Mimic Variables &amp; Selectively Show Content</h4>

<p>Since I do not have variables available to use I need to use the URL fragments to selectively show my LEFT and RIGHT arrows. If I didn't do this I wouldn't know which LI slide to move to next and I wouldn't know which slide LI I need to show. 
This would quickly defeat my ul { left: -500px } method. What I did was wrap my entire slider in 4 :target hooks which simulate variables:</p>

<code>
&lt;!-- :target hooks --&gt;
&lt;div id=&quot;a1&quot;&gt;
&lt;div id=&quot;a2&quot;&gt;
&lt;div id=&quot;a3&quot;&gt;
&lt;div id=&quot;a4&quot;&gt;

&lt;!-- 1 --&gt;
&lt;a href=&quot;#a2&quot; class=&quot;up2 default&quot;&gt;2&lt;/a&gt;
&lt;a href=&quot;#a2&quot; class=&quot;up2&quot;&gt;2&lt;/a&gt;
  
&lt;!-- 2 --&gt;
&lt;a href=&quot;#a1&quot; class=&quot;down1&quot;&gt;1&lt;/a&gt;
&lt;a href=&quot;#a3&quot; class=&quot;up3&quot;&gt;3&lt;/a&gt;
  
&lt;!-- 3 --&gt;
&lt;a href=&quot;#a2&quot; class=&quot;down2&quot;&gt;2&lt;/a&gt;
&lt;a href=&quot;#a4&quot; class=&quot;up4&quot;&gt;4&lt;/a&gt;
  
&lt;!-- 4 --&gt;
&lt;a href=&quot;#a3&quot; class=&quot;down3&quot;&gt;3&lt;/a&gt;

&lt;/div&gt; &lt;!-- End #a4 --&gt;
&lt;/div&gt; &lt;!-- End #a3 --&gt;
&lt;/div&gt; &lt;!-- End #a2 --&gt;
&lt;/div&gt; &lt;!-- End #a1 --&gt;
</code>

<h4>Using Our :Target Hooks To Postion Our UL</h4>

<p>I then use the following CSS to move our UL left 0px, -500px etc.</p>

<code>
#a1:target ul { left: 0px; }
#a2:target ul { left: -500px; }
#a3:target ul { left: -1000px; }
#a4:target ul { left: -1500px; }
</code>


<p>I next use these same hooks to hide/show the appropriate LEFT/RIGHT arrows:</p>

<code>
#a1:target .up2,
#a2:target .down1,
#a2:target .up3,
#a3:target .down2,
#a3:target .up4,
#a4:target .down3
{ display: block; }
</code>


<h4>Giving Our Slider Animation</h4>

<p>If you were to test out the demo up to this point you would notice that when you click the LEFT/RIGHT arrows, it would automatically switch to the next slide rather abruptly. To fully achieve our JQuery-like slider we need to use 
<a href="http://webkit.org/blog/138/css-animation/">CSS3 Transitions</a> which was originally proposed by the Webkit team and has since been adopted into canon by the W3C. What this means is, at the moment the animations will only work in Safari, 
but Opera and Firefox will not be far behind to implement this exciting new CSS feature.</p>

<p>To achieve the CSS animation we need to first define what CSS property we want to animate. We can do this by stating '-webkit-transition: left'. 
Next we state the amount of milliseconds we would like the transition to occur over by adding '.3s'. Finally  we add linear to the end stating that it is a linear transition. Here is the fully property statement:</p>

<code>
ul { -webkit-transition: left .3s linear; }
</code>

<h4>Demo</h4>

<p>To view the final product (which I recommend you use Safari which supports CSS Transitions) view my <b><a href="/tech/resources/45/">CSS Only JQuery Slider Emulation Demo &gt;&gt;</a></b></p>

<p><b>Before you comment stating why on earth anybody would ever use this when it can be accomplished so much easier in JavaScript please remember this is just a proof of concept and a test to see if it could be done using only CSS.</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=45">View Comments [6]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 22 Apr 2009 22:09:43 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=45</guid>
<author>Neal Grosskopf</author>
<category>css</category><category>css3</category>
</item>
<item>
<title>My Proposed CSS Property: Intended-Brightness</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=44</link>
<description>
<![CDATA[
<p>Have you ever created a really great looking website design, ideally on a color-corrected LCD monitor only to find it looks terrible on another user's monitor?
 I've noticed several times, designs I have created look extremely washed-out on some of my co-workers factory default, cheap, LCD monitors. Sometimes the users have
 their brightness/contrast/gamma turned up so high that hex colors such as #ececec or #dddddd look almost the same as #ffffff (white). So what could be done to fix this?</p>

<h4>Overlay A DIV?</h4>
 
<p>Originally I thought it could be possible to overlay a DIV, with opacity, over the entire viewport in a futile attempt to make the screen 'darker'. This was futile because the DIV
 essentially makes it impossible to click anything underneath it.</p>
 
<h4>A New CSS Property</h4>

<p>After giving it some thought, I came to the conclusion that we need a new CSS property which I've decided to call 'intended-brightness'. The syntax might look something like this:</p>

<code>
html
{
intended-brightness: 0.5;
}
</code>

<p>Intended-Brightness would take a decimal that could range from 0.0 to 1.0 (much like opacity does). This would allow the designer of the website to design using their native brightness 
and then ensure that the website looks the same on all monitors rather than dark on some and washed-out on others.</p>

<h4>Accessibility?</h4>

<p>Obviously accessibility proponents would complain about this new property because some users (heaven forbid) would want their browser's brightness cranked up to 95%. Because of this, browser vendors 
could create an option like they do for other CSS properties related to browser accessibility such as font-size, color, background-color etc. See below for Firefox's tab regarding these settings:</p>

<p><img src="/tech/resources/44/browser-options.png" alt="Firefox's default styling options"></p>

<h4>CSS Inheritance?</h4>

<p>One issue I'm not sure on yet is whether the property could be inherited by child elements. The property could act like the various 'background' properties where the background-image 
is only set on the current element and not the child elements. The property could also allow inheritance basically allowing child elements to have a different brightness than other elements.</p>

<p>Personally, I think it would be easier, and faster to implement using the non-inheritanced method which is usually the desired effect web developers would want.</p>

<h4>Does This Belong In CSS?</h4>

<p>Of course! CSS already allows the styling of many other features native to the operating system such as form controls, scrollbars, cursors and text-selection colors. Another very similar property 
already present in CSS is opacity which I think further strengthens my case.</p>

<p>So what do you think? Feel free to discuss below -</p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=44">View Comments [7]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 14 Apr 2009 18:41:24 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=44</guid>
<author>Neal Grosskopf</author>
<category>css</category>
</item>
<item>
<title>Browser Comparision of Available Screen Width When Using 1024x768</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=43</link>
<description>
<![CDATA[
<div style="float: right; width: 275px; margin: 0px 0px 20px 20px;" class="image-caption">
	<img src="/tech/resources/43/facebook-scrollbars.png" alt="Horizontal Scrollbars on Facebook">
	<h3>Figure A.</h3>
	<p>Facebook's horizontal scrollbars showing up on a 1024x768 screen resolution. <i>(Note this screenshot was took on my own PC using Firefox)</i></p>
</div>

<p>I was using my parent's computer the other day which is your standard Dell with a LCD monitor set at 1024x768. I decided to log on to Facebook, one of the internet's most popular websites. Upon logging in, 
using Internet Explorer 7, I was greeted with a wonderful horizontal scrollbar. I thought to myself "Facebook, the world's leading social network has horizontal scrollbars?". Sure enough, the Facebook developers failed to check their re-designed 
website in IE7, or possibly, on a 1024x768 monitor.</p>

<p>I wouldn't have minded if a horizontal scrollbar appeared if the design was targeted towards a higher resolution such as 1280x960 but this looked more like blatant oversight on
Facebook's part. Look at how little of a horizontal scrollbar appears - <b>Figure A.</b></p>

<h4>Unnecessary Horizontal Scrollbars = Evil</h4>

<p>Nobody likes horizontal scrollbars (unless of course <a href="http://www.cssleak.com/Category/Horizontal-Scrolling-Websites.html">your entire design relies on it</a>). Horizontal scrollbars are 
annoying because they hide 15-17px of content at the bottom of you page. They are also confusing because the web browser is typically browsed un-directionally, due to limitations of the mouse's 
scroll wheel. When a user has to scroll down and over, this forces the user to abandon the mouse wheel and manipulate the horizontal scroll bar with the mouse's left button, thus wasting time.</p>

<h4>So What Is The Available Screen Width In Various Browsers?</h4>

<p>Had Facebook done their homework they would have realized that a content width of 1024px combined with a vertical scrollbar results in a horizontal scrollbar. Below is the maximum 
width you can use in various browser viewports, showing both with a vertical scrollbar and without:</p>

<table class="data">
<caption>Viewport Maximum Width in Pixels</caption>
<tr class="def">
	<th>&nbsp;</th>
	<th>Without Vertical Scrollbar</th>
	<th>With Vertical Scrollbar</th>
	<th>Scrollbar Width</th>
</tr>
<tr class="alt">
	<td>Safari 3</td>
	<td>1024</td>
	<td>1009</td>
	<td>15</td>
</tr>
<tr class="def">
	<td>Firefox 3</td>
	<td>1024</td>
	<td>1007</td>
	<td>17</td>
</tr>
<tr class="alt">
	<td>Chrome 2 </td>
	<td>1024</td>
	<td>1007</td>
	<td>17</td>
</tr>
<tr class="def">
	<td>Opera 9</td>
	<td>1023</td>
	<td>1006</td>
	<td>17</td>
</tr>
<tr class="alt">
	<td>Internet Explorer 7</td>
	<td>1003</td>
	<td>1003</td>
	<td>17<span class="sup">[1]</span></td>
</tr>
<tr class="def">
	<td>Internet Explorer 6</td>
	<td>1003</td>
	<td>1003</td>
	<td>17<span class="sup">[1]</span></td>
</tr>
</table>

<p><i><span class="sup">[1]</span>IE incorrectly includes the scrollbar width in the element's width, thus the actual scrollbar width is 0px.</i></p>

<h4>So What's My Point?</h4>

<p>By looking at the chart above, we need to pick the lowest value as our maximum width. Seeing that 1003 is the lowest, which is used in Internet Explorer 6 &amp; 7, if you plan to create a design 
for 1024x768, I would advise that you not make it wider than 1003 pixels. I would also advise that you never make your main content DIV an odd width. See 
<a href="http://csscreator.com/node/472#comment-2208">http://csscreator.com/node/472#comment-2208</a> for more on that. My point is, you're better off choosing a width less than 1000px if you want to avoid horizontal scrollbars. 
<b>Remember to always check you design in the early stages of development for your baseline screen resolution.</b></p>

<p>You might also be interested in my article <a href="/tech/thread.asp?pid=12">Always Show Browser Scrollbars</a>.</p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=43">View Comments [5]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 7 Apr 2009 21:26:18 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=43</guid>
<author>Neal Grosskopf</author>

</item>
<item>
<title>Organize Your Stylesheet Madness & Reduce It's File Size With These Tips</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=42</link>
<description>
<![CDATA[
<p>The other day at work, I had some spare time so I decided to take a look at one of our stylesheets from one of our older websites. The stylesheet was currently over 700 lines long, which I don't consider that long and stood at about 13kb, which again I don't find particularly large.</p>

<h4>Shredding The Extra File Size</h4>

<p>After reviewing the CSS file I noticed it lacked organization, and probably the worst of all, it repeated itself...a lot! My top pet peve with stylesheets is when properties are copied 
from one selector to another. Below is one example of what I'm talking about:</p>

<code>
a.ProdNav:link
{
color: #666666; 
font-size: 11px; 
font-family: Arial, Helvetica, sans-serif;
font-weight: 600;
text-decoration: underline;
padding-left: 15px;
padding-right: 15px;
}

a.ProdNav:visited
{ 
color: #666666; 
font-size: 11px; 
font-family: Arial, Helvetica, sans-serif;
font-weight: 600;
text-decoration: underline;
padding-left: 15px;
padding-right: 15px;
}

a.ProdNav:hover
{ 
color: #333333; 
font-size: 11px; 
font-family: Arial, Helvetica, sans-serif;
font-weight: 600;
text-decoration: underline;
padding-left: 15px;
padding-right: 15px;
}
</code>

<p>Notice the <i>Golden Rule</i> in programming which is "don't repeat yourself" is broken here? If you look close enough, the only thing that changes from the three link states is the font color.
 Let's shorten that up a bit to see what it could look like:</p>
 
<code>
a.ProdNav, a.ProdNav:visited
{
color: #666666;
font-weight: 600;
padding: 0px 15px;
text-decoration: underline;
}
a.ProdNav:hover { color: #333333; }
</code>

<p>Ah yes, much better. A full 24 lines shorter and much easier to follow. (Note I also removed some font styling as it was better served on the BODY element). Little things like this can make your stylesheet better organized and also much smaller. 
After removing mistakes like this from the stylesheet, I was able to remove over 200+ lines from it and shred 5KB file in file size.</p>

<h4>Overall Stylesheet Organization & Grouping</h4>

<p>Another area to pay attention to is how you organize your selectors within your stylesheet. Too often, I review other people's CSS files and have no idea where to find something. The first thing you 
should <b>always</b> do is group like-selectors with one another. Below is how I usually choose to organize my stylesheets:</p>

<ol style="list-style-type: upper-roman;">
	<li>Table Of Contents</li>
	<li>CSS Variables</li>
	<li>CSS Image Preload</li>
</ol>
<ol>
	<li>Reset</li>
	<li>Headings</li>
	<li>Anchors</li>
	<li>Form Elements</li>
	<li>General Classes</li>
	<li>Template & Layout</li>
	<li>Print</li>
	<li>Handheld</li>
	<li>Aural</li>
	<li>CSS Diagnostics</li>
</ol>

<h4>CSS Table of Contents</h4>

<p>I recommend a table of contents for stylesheets over 500 lines long, which in most cases, is always my CSS files. I also recommend that you separate your groups of selectors with CSS comments. Numbering them
with the same number you used in your table of contents will make finding the area quicker as well. Below is how I prefer to do this as it makes it stand out more. I also like to place code references in the heading in case I need to quickly refer back.</p>

<code>
/****************************************************************
 1. Reset  -  http://meyerweb.com/eric/tools/css/reset/
****************************************************************/
</code>

<h4>CSS Variables?</h4>

<p>You may have noticed my reference to <a href="http://disruptive-innovations.com/zoo/cssvariables/">CSS Variables</a> and are wondering what the heck this is. It's currently a proposal for CSS, which may never happen but after
the W3C recently adopting CSS Transformations, I think CSS Variables still stands a chance. While you don't need to adhere to the spec, I sometimes like to place common color references at the top of my stylesheet for quick reference:</p>

<code>
/****************************************************************
 II. CSS Variables - Spec: http://disruptive-innovations.com/zoo/cssvariables/
****************************************************************/
/*
@variables {
Text: #555555;

DarkGreen: #669933;

DarkLimeGreen: #7e935a;
MediumLimeGreen: #949f74;
LimeGreen: #adb986;
LightLimeGreen: #ccdb9f;

DarkBrown: #a7917b;
LightBrown: #b69f86;
}
*/
</code>

<h4>Preloading Images In CSS</h4>

<p>I also have a section where I preload :hover state images to be consumed further along in my stylesheet. I've written an article on <a href="/tech/thread.asp?pid=24">CSS image preloading</a> if you want
to read more on this topic. By doing this I avoid the one second flicker that many users experience when hovering over an element with a background image. I like to group these together because I find they can often get lost 
in the overall stylesheet and eventually somebody else will run across the selector, not understand it's purpose and delete it.</p>

<code>
/****************************************************************
 III. CSS Image Preload - http://www.nealgrosskopf.com/tech/thread.asp?pid=24
****************************************************************/
#nav { background: url(/files/images/template/menu_bg-trans.png) no-repeat -9999px -9999px; }
#header { background: url(/files/images/template/helper_sub_bg-trans.png) no-repeat -9999px -9999px; }
#container { background: url(/images/icons/actions/actions_sprite.png) no-repeat -9999px -9999px; }
</code>

<h4>Other Common Sections in CSS Files</h4>

<p>I like to place my CSS reset at the top of the stylesheet so that I can override it further down if need be. I also have a section for heading elements i.e. H1, H2, H3, site-wide anchors, form elements and
also general classes such as .b .u .i .left .right for bold, underline, italic, text-align: left & text-align: right etc. I also include in here styling for blockquotes, images and some other common
non-structure styling.</p>

<p>After that I like to have a grouping for "Template & Layout". Under this heading I like to place structural styling such as DIV sizes and positions. I will also throw in here some font formatting if 
it's specific to that particular DIV. I know some people like to break out the font styling into their own section or even stylesheet (god why does it need it's own stylesheet?)</p>

<p>After that, if I'm feeling ambitious, I'll create sections for @print, @handheld and @aural. I have some stock CSS I use for @print so that usually leaves @handheld and @aural to do for later.</p>

<h4>And Don't Forget...CSS Diagnostics!</h4>

<p>Last but not least, I have my <a href="/tech/thread.asp?pid=17">Diagnostic Styling</a>. I've written an article about this already so feel free to check that out, but in a nutshell <a href="/tech/thread.asp?pid=17">CSS Diagnostics</a>
is CSS that highlights ugly areas of your HTML so that you can quickly fix them. The reason this goes at the end of the stylesheet is that it needs to 'trump' all other selectors that have been set
so far.</p>

<h4>Organize Your CSS Properties...Please!</h4>

<p>Finally the last thing I like to do when cleaning up/developing a stylesheet is alphabetical organizing my CSS properties. Below is a selector with a whole slew of properties which are unorganized:</p>

<code>
.pageIDnest
{
Position: relative;
width: 400px;
height: 15px;
margin-left: 10px;
margin-top: 25px;
line-height: 20px;
color: #ef3e41; 
font-size: 12px; 
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: 700;
text-decoration: none;
border-bottom-color:#cccccc;
border-bottom-style: solid;
border-bottom-width: 1px;
padding-left: 10px;
}
</code>

<p>Now let's sort it and use some CSS shorthand (which I'll explain shortly).</p>

<code>
.pageIDnest
{
border-bottom: 1px solid #cccccc;
color: #ef3e41; 
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px; 
font-weight: 700;
height: 15px;
line-height: 20px;
width: 400px;
margin: 25px 0px 0px 10px;
padding-left: 10px;
position: relative;
text-decoration: none;
</code>

<p>Looks better, doesn't it? You'll notice one property that isn't sorted alphabetically. Did you find it? Width, yes I didn't place width at the end. I do have two exceptions with sorting my properties.
The first one is width & height. The second is position + top,right,bottom,left. I like to group these two sets of properties together since they all have a relationship to one another and I find
myself editing them at the same. You'll also notice that I did not use CSS shorthand for my font properties. I generally avoid using shorthand for the font set of properties as it can be a bit tricky to correctly implement since several of the 
properties share the same values and also need to be the correct order.</p>

<h4>CSS Shorthand</h4>

<p>Finally, use <a href="http://www.dustindiaz.com/css-shorthand/">shorthand CSS</a> whenever possible. It will save you lines of code to sift through and also KB of file size. A few property groups you can use it on are:</p>

<ul>
	<li>Background</li>
	<li>Border</li>
	<li>Font-Family</li>
	<li>List-Style</li>
	<li>Margin</li>
	<li>Outline</li>
	<li>Padding</li>
</ul>

<h4>Conclusions</h4>

<p>Your CSS file doesn't need to be an afterthought after you finished programming your website and adding the markup. It can shine, just like your carefully crafted server-side code does. 
By organizing, grouping, documenting and shortening your CSS file your co-workers will thank you and you will know that you did a good job at the end of the day.</p>

<p><b>Have any secrets to your CSS organizational success? Share them below - </b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=42">View Comments [4]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 31 Mar 2009 21:40:13 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=42</guid>
<author>Neal Grosskopf</author>
<category>css</category><category>organization</category>
</item>
<item>
<title>CSS Drop Caps Without Unnecessary HTML Elements or Classes</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=41</link>
<description>
<![CDATA[
<p>Drop capitals are commonly seen in newspapers or books. They can be identified by looking at the first letter of a paragraph or a page that is usually larger than the rest of the paragraph, bolded and often
times a different font-family.</p>

<p>I've seen many different methods to achieve this effect in HTML and CSS, most of the time the method requires unnecessary elements or classes. I'll give an example of how to do drop caps in CSS without any
classes, and then I'll show you a second method which will require you to place a single class on the parent element.</p>

<h4>Styling Our Drop Cap in CSS Without Classes</h4>

<p>The first option is if you want to style the first P element on every page of your website with a drop cap. The selector below will first use the :first-child pseudo selector to find our first P element
and then it will select the first letter of the P element with the first-letter pseudo selector.</p>

<p>I've added some other visual effects to our drop cap such as a background-color, font-family, text-transform, and a double'd border which is seldom used.</p>

<code>
body p:first-child:first-letter
{
background: #990000;
border: 4px double #ffcc00;
color: #ffffff;
float: left;
font-family: "Times New Roman", Times, serif;
font-size: 3em;
font-weight: bold;
margin: 7px 10px 0px 0px;
padding: 10px;
text-transform: uppercase;
}
</code>

<p><b><a href="/tech/resources/41/">View Demo &gt;&gt;</a></b></p>

<h4>Using A Class</h4>

<p>You may also want to selectively apply a drop cap to other blocks of text on your website. In this case, simply add a class to the paragraph and add this selector to your CSS:</p>

<code>
.dropcap
{
...
}
</code><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=41">View Comments [0]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Wed, 25 Mar 2009 18:41:09 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=41</guid>
<author>Neal Grosskopf</author>
<category>css</category>
</item>
<item>
<title>Simple Function To Return Recordset Results as HTML Table In Classic ASP</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=40</link>
<description>
<![CDATA[
<p>I was recently working on a website for a client and needed a simple method to read the column names and records from a database table and return them as a semantically correct
HTML table. After doing a little searching I found a forum post with the code I was looking for. I've adapted that code and also polished it up a bit for all to consume.</p>

<h4>Recordset Function In ASP</h4>

<p>The function takes any SQL and returns it as an HTML table. The begining part of the function sets up the opening TABLE element and also writes out the column names as TH elements.</p>

<code>
function ReturnHTMLTable(query)

	set rs = cn.Execute(query)
	
	rs.MoveFirst 
	response.Write "&lt;table class=""data"" cols=""" & rs.Fields.Count & """&gt;"
	response.Write "&lt;tr&gt;"
	
	For Each oField In rs.Fields
		response.Write "&lt;th&gt;" & oField.Name & "&lt;/th&gt;"
	Next
	
	response.Write "&lt;/tr&gt;"
</code>

<h4>Looping Through the ASP Recordset</h4>

<p>Next the function loops through the recordset writing out values under the appropriate column name.</p>

<code>
Do While Not rs.EOF
	
		response.Write "&lt;tr&gt;"
		
		For Each oField In rs.Fields
		
			response.Write "&lt;td&gt;"
			
			If IsNull(oField) Then 
				response.Write " "
			Else
				response.Write oField.Value
			End If
			
			response.Write "&lt;/td&gt;"
		
		Next 
		rs.MoveNext
		
		response.Write "&lt;/tr&gt;"
	
	Loop
</code>

<p>Finally it writes out the closing TABLE tag.</p>

<code>
response.Write "&lt;/table&gt;"
</code>

<h4>Putting It All Together</h4>

<p>I've been looking for a simple function like this for a long time so perhaps I'll help a few others out with this. I've mostly used it to show on result pages after a user adds a new item to a 
database via a web form.</p>

<code>
function ReturnHTMLTable(query)

	set rs = cn.Execute(query)
	
	rs.MoveFirst 
	response.Write "&lt;table class=""data"" cols=""" & rs.Fields.Count & """&gt;"
	response.Write "&lt;tr&gt;"
	
	For Each oField In rs.Fields
		response.Write "&lt;th&gt;" & oField.Name & "&lt;/th&gt;"
	Next
	
	response.Write "&lt;/tr&gt;"
	
	Do While Not rs.EOF
	
		response.Write "&lt;tr&gt;"
		
		For Each oField In rs.Fields
		
			response.Write "&lt;td&gt;"
			
			If IsNull(oField) Then 
				response.Write " "
			Else
				response.Write oField.Value
			End If
			
			response.Write "&lt;/td&gt;"
		
		Next 
		rs.MoveNext
		
		response.Write "&lt;/tr&gt;"
	
	Loop
	
	response.Write "&lt;/table&gt;"

end function
</code>

<h4>Using The Function</h4>

<p>The function can be used by selecting the columns you want by passing the SQL to the function like so:</p>

<code>
ReturnHTMLTable("SELECT id, firstname, lastname, datetime FROM mytable")
</code>

<p>You can also show the columns in a different order by changing the order of your columns in your SQL statement.</p>

<h4>Sources</h4>

<ul>
	<li><a href="http://forums.aspfree.com/sql-development-6/how-to-get-the-field-s-name-from-a-table-2529.html">http://forums.aspfree.com/sql-development-6/how-to-get-the-field-s-name-from-a-table-2529.html</a></li>
</ul><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=40">View Comments [2]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 17 Mar 2009 07:03:52 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=40</guid>
<author>Neal Grosskopf</author>
<category>asp</category><category>function</category>
</item>
<item>
<title>Go Green With CSS Print Stylesheets</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=39</link>
<description>
<![CDATA[
<p>Have you ever printed a website only to find out the page prints exactly how it appears on your screen? While this is nice if your intentions were to print a screenshot of the
webpage, it's impractical and wasteful to print the entire page as is.</p>

<h4>Why is not Using Print Stylesheets Wasteful?</h4>

<p>The first reason it is wasteful is you are probably printing areas of your website template that are not actually part of your content area. Examples of these areas  might be
you header, navigation, footer, search box etc. With all these extra non-useful areas of your template printing every time a visitor prints your website, over time it all adds up as extremely wasteful.
 It's wasteful because it requires the end user's printer to print more than needed. It's also wasteful because it often adds an extra page or two to your total pages required to print. If every print job on your site is adding an extra sheet or two of paper, over the course of a year you are probably wasting a lot of paper and killing a lot of trees, especially if you have a highly trafficked website. </p>
 
<p>My theory is if somebody wants to print a literal screenshot of your website they should create a screenshot using either print screen or the utility of their choice. Firefox offers an excellent screenshot
addon called <a href="https://addons.mozilla.org/en-US/firefox/addon/1146">Screengrab!</a> which is very flexible in what you want to grab. Windows 7 will also come with a screenshot utility which
PC users can use. (And yes, Mac users we know you already have this, you can lower your hand now).</p>

<p>So we've already identified that by not using print stylesheets you could be wasting an extra sheet of paper for every print job or ink that never needed to be used, what can you do to help?</p>

<h4>Using CSS Print Stylesheets to 'Go Green'</h4>

<p>I hate the marketing buzzword 'green' probably more than anybody I know. It's too often just a gimmick a company is using in order for them to save money. Few companies care about the environment, but all
companies care about making money (that is the purpose of a company after all), and if they can save money and inadvertently help the environment, they're all of a sudden 'going green'.</p>

<p>First let's remove some useless DIVs from our template to save on ink and paper:</p>

<code>
#header, #nav, #footer { display: none; }
</code>

<h4>Reduce Your Line-Height</h4>

<p>We can also shorten the length of our print job by reducing the line-height we use. I often use a line-height of 2.25em x 12px which is basically double spaced for my screen stylesheet. We could reduce this to 1em to cut down
on the amount of paper needed to print our website:</p>

<code>
#content { line-height: 1em; } 
</code>

<h4>Hide Advertisements &amp; Other Useless Graphics</h4>

<p>Another thing you might consider if it's an option is to hide any images or advertisements via CSS. User won't care to see ads on their print outs and you probably didn't promise your advertiser that 
the ad needed to carry through on print outs either. Also if you can get away with hiding images in the content area, I'd recommend doing this as well.</p>

<code>
img, #ads { display: none; }
</code>

<h4>Go Grayscale With Black Font Colors</h4>

<p>I also like to remove color from all my font when printing. This may not be a green practice but it will probably save people money over a long period of time by removing the need to use color ink to 
print with. You won't be able to get around this when it comes to color images but you could turn all your font styling to black.</p>

<code>
#content * { color: #000000; }
</code>

<h4>Maximize Your Print Area</h4>

<p>Another thing to consider is your main #content DIV. Usually this will be set to some sort of dimension in pixels by default. I've found that fixed width pixels doesn't translate well into print so let's
set our #content DIV to a width of 100%.</p>

<code>
#content { width: 100%; }
</code>

<h4>Putting it all Together</h4>

<code>
@media print {

#header, #nav, #footer, #ads, img { display: none; }
#content { line-height: 1em; width: 100%; }
#content * { color: #000000; }

}
</code>

<h4>Conclusion</h4>

<p>I think print stylesheets should be used on every website, whether you care go green or not. It will help your end users save money on printing costs and will also give you users a more useful printout.</p>

<p><b>Feel free to add any ideas you have on improving print stylesheets in regards to going green in my comments below...</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=39">View Comments [5]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Sun, 8 Mar 2009 16:35:53 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=39</guid>
<author>Neal Grosskopf</author>
<category>css</category>
</item>
<item>
<title>Someone Ripped off My Website's Design! Now What? </title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=38</link>
<description>
<![CDATA[
<p>I was recently rummaging through my Google Analytics reports when I noticed some strange page titles for my website. After further investigation using the "hostnames" report
I was able to determine the domain the traffic was coming from. I then combined the hostname with the pages report to complete the full URL of the external web page using my Google Analytics
tracking code. See below for an example of the report I saw:</p>

<p><img src="/tech/resources/38/design-analytics.jpg" alt="Analytics showing somebody is using my Google Analytics tracking code"></p>

<p>I then proceeded to visit that URL only to find out somebody had borrowed/used/stolen/was inspired by by my nealgrosskopf.com design. I then went to the root of that website to discover that it was
actually a web design company that had done it. <i>I've decided not to link to or give out the name of the company because they were actually pretty nice people</i>. I've actually caught people stealing designs of websites I worked on before but it was always some novice using Microsoft Frontpage, not an actual
web designer getting paid which was the troubling part of this experience. </p>

<p>My first instinct was to leave a mean message via their contact us form but I noticed a phone number and decided to call it. After all, I've always wanted to personally talk to somebody who stole a design
and here was my chance to do so. I ended up talking to a person who wasn't responsible for the stolen design but was very apologetic and understanding which I really appreciated. She asked me if they 
could proceed with using the design, and I said yes, as long as they changed a few elements in the design because I felt they were too similar as is. She also said they could give me credit for the design since
their footer was currently claiming it was designed by them. I agreed that this was probably a good idea on their part.</p>

<h4>Rule #1: Delete Out The Google Analytics Tracking Code</h4>

<p>My main gripe was that they had stolen my Google Analytics tracking code and were polluting my statistics. Being the crazy stats person I am, I absolutely hate it when my stats get messed up so I asked them to remove my tracking codes.
 Every time I've busted somebody for stealing a design, it was because they also stole my Google Analytics tracking code. If you every feel like copying some code from a website at least remove the evidence that you did.</p>

<h4>Side By Side Comparision</h4>

<p>Below is an example of the two designs side by side. You can also click on the image to view it larger. It does appear that they pulled a screen shot of my website into an image editing program and made some
modifications to it. The source code was clearly copied and pasted though as I could see the same IDs, classes and HTML comments still. </p>

<p><a href="/tech/resources/38/design-stolen.jpg"><img src="/tech/resources/38/design-stolen-sm.jpg" class="frame" alt="Side by side comparision of stolen websites"></a></p>

<h4>So What Can You Do If This Happens To You?</h4>

<p>My recommendation from past experiences is don't bother emailing or using an online contact form. I've done this several times in the past and most people just ignore you. If you can find a phone number 
like I was able to, I'd recommend calling and trying to speak with somebody who either worked on it, or who is the team leader of whoever worked on it. On the phone you can have a two way conversation 
rather than long winded back and forth conversations like email produces. I would also advise not to be a jerk to somebody that stole your design. After all "Imitation is the sincerest form of flattery". Somebody
stealing your design really is a testament to your own web design skills and all of us at one time or another have at least borrowed small elements from other websites.</p>

<p>The problem with my example is it went a bit further than borrowing elements from my web design to outright copying and pasting of the source code as well as the design files. If you catch somebody in this 
stage you should contact them and at least get them to ask you for your permission.</p>

<h4>Conclusion</h4>

<p>I've always felt that the web is an open platform, and openness is the central theme behind the internet as a whole. Because of the web's open nature it make borrowing a lot easier than other methods of 
design. I would much rather have a web where a small few steal the source code/design of others than have a web were you can't even view the source code at all. I have to credit a lot of my own skills to viewing other's
source code and learning from it.</p>

<p>If you catch somebody who has stolen your design or source code, try not to get too angry. Also trying contacting them personally as it will probably get you further than if you email them. And remember 
we're all web designers so take it easy on one another.</p>

<p><b>Have you every copied a design/source code before or caught somebody that has? Feel free to discuss your experience below:</b></p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=38">View Comments [10]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Mon, 2 Mar 2009 19:12:21 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=38</guid>
<author>Neal Grosskopf</author>
<category>google</category><category>analytics</category>
</item>
<item>
<title>CSS Horizontal And Vertical Align JQuery Plugin</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=37</link>
<description>
<![CDATA[
<p>I recently read an <a href="http://blog.themeforest.net/tutorials/vertical-centering-with-css/">article</a> showing 5 way to vertically align elements using CSS.
I thought that the author showed some great examples of how to accomplish this. My only complaint is many of the examples were somewhat hacky
or required that you set a height on the DIV you want to vertically align. Also a few of them did not work in IE6 or IE7. I set out to create a solution that did not require the height of the DIV to be known and would work in both IE6 and IE7.</p>

<h4>My JQuery code is based on the following CSS:</h4>

<code>
#content
{
position: absolute;
top: 50%;
height: 300px;
margin-top: -150px;
width: 300px;
margin-left: -150px;
}
</code>

<p>I decided that much of this is redundant and makes too many assumptions about our content. If the amount of content were to grow larger, we would have to update the CSS each time. On most
dynamic websites this is not a feasible solution. Also the margin-top and margin-left were to always be exactly half of the height/width so it seemed silly to have to do that math each time the
width or height were to change.</p>

<h4>Vertical Align JQuery Plugin</h4>

<p>I first decided that I would use JQuery to figure out the height of the DIV and the content within it. I then had to take into consideration that the DIV may have a border or padding so I used
JQuery's .outerHeight() property to get that value. The resulting formula looks like this:</p>

<code>
(Height + (OuterHeight - Height)) / 2
</code>

<p>I took that formula/code and made it so it can be used like a JQuery plugin:</p>

<code>
(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var h = $(this).height();
	var oh = $(this).outerHeight();
	var mt = (h + (oh - h)) / 2;	
	$(this).css("margin-top", "-" + mt + "px");	
	$(this).css("top", "50%");
	$(this).css("position", "absolute");	
	});	
};
})(jQuery);
</code>

<p>This can be called when our DOM is fully loaded like so:</p>

<code>
$(document).ready(function() {
	$("#content").vAlign();
});
</code>

<p>Simple, isn't it?</p>

<h4>Horizontal Align JQuery Plugin</h4>

<p>I also created a similar plugin to horizontally align a DIV. By combining the vertical align and horizontal align plugins we can set a DIV in the exact middle of the viewport.
 I realize that this is usually solved by giving our DIV a width and setting it's margin to 'auto'. The problem was my DIV was already
positioned absolute so setting the margin to 'auto' wasn't working. I therefore used a similar approach to my vertical align solution.</p>

<code>
(function ($) {
$.fn.hAlign = function() {
	return this.each(function(i){
	var w = $(this).width();
	var ow = $(this).outerWidth();	
	var ml = (w + (ow - w)) / 2;	
	$(this).css("margin-left", "-" + ml + "px");
	$(this).css("left", "50%");
	$(this).css("position", "absolute");
	});
};
})(jQuery);
</code>

<h4>Putting It All Together</h4>

<code>
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var h = $(this).height();
	var oh = $(this).outerHeight();
	var mt = (h + (oh - h)) / 2;	
	$(this).css("margin-top", "-" + mt + "px");	
	$(this).css("top", "50%");
	$(this).css("position", "absolute");	
	});	
};
})(jQuery);

(function ($) {
$.fn.hAlign = function() {
	return this.each(function(i){
	var w = $(this).width();
	var ow = $(this).outerWidth();	
	var ml = (w + (ow - w)) / 2;	
	$(this).css("margin-left", "-" + ml + "px");
	$(this).css("left", "50%");
	$(this).css("position", "absolute");
	});
};
})(jQuery);

$(document).ready(function() {
	$("#content").vAlign();
	$("#content").hAlign();
});
&lt;/script&gt;

&lt;style type=&quot;text/css&quot;&gt;
#content { width: 400px; }
&lt;/style&gt;

&lt;div id=&quot;content&quot;&gt;
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu dui eget nulla condimentum gravida. Vivamus erat leo, ultricies quis, gravida a, fringilla eu, urna. Pellentesque a mauris ac nisl semper egestas. Pellentesque ut elit in pede mattis gravida. Donec ac lectus a nisi suscipit placerat. Maecenas quis ipsum. Pellentesque mattis tellus. Suspendisse sollicitudin accumsan tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed metus. Quisque et leo at erat rutrum lobortis. In tempus lectus eget ligula convallis tristique.
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eu dui eget nulla condimentum gravida. Vivamus erat leo, ultricies quis, gravida a, fringilla eu, urna. Pellentesque a mauris ac nisl semper egestas. Pellentesque ut elit in pede mattis gravida. Donec ac lectus a nisi suscipit placerat. Maecenas quis ipsum. Pellentesque mattis tellus. Suspendisse sollicitudin accumsan tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed metus. Quisque et leo at erat rutrum lobortis. In tempus lectus eget ligula convallis tristique.
&lt;/div&gt;
</code>

<p><b><a href="/tech/resources/37/">View Demo &gt;&gt;</a></b></p>

<p>I should point out that the only CSS property you will need to set on the DIV is it's width. If you want your DIV's width to be 100% you can remove this property.</p>

<h4>Sources:</h4>

<ul>
	<li><a href="http://seodenver.com/2008/09/08/simple-vertical-align-plugin-for-jquery/">http://seodenver.com/2008/09/08/simple-vertical-align-plugin-for-jquery/</a></li>
	<li><a href="http://blog.themeforest.net/tutorials/vertical-centering-with-css/">http://blog.themeforest.net/tutorials/vertical-centering-with-css/</a></li>
</ul><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=37">View Comments [9]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 24 Feb 2009 21:57:05 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=37</guid>
<author>Neal Grosskopf</author>
<category>css</category><category>jquery</category>
</item>
<item>
<title>How To Get Total Feedburner Subscribers With JQuery and ASP</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=36</link>
<description>
<![CDATA[
<p>The great thing when you run all your RSS feeds through Feedburner is Feedburner gives you all kinds of statistics on your RSS feed. Without statistics there is no 
way to measure how successful your feed is so this is a great feature that Feedburner offers.</p>

<p>Feedburner also offers these statistics via an RSS feed of their own. We can use this RSS feed with some server-side code and ajax to give future feed subscribers a count of total
current subscribers.</p>

<h4>ASP File Code For Getting Total Feedburner Subscribers</h4>

<p>Using a small amount of ASP we can retrieve the Feedburner RSS feed and get the total users subscribed to our RSS feed. This code could also easily be done in other languages like ASP.NET or PHP.
 If you have yet to migrate your Feedburner account over to a Google account, you'll want to comment out my "objXML.Load" line and use the one before it. Also, the following code should be 
 placed in a separate file and named feedburner.asp.</p>

<code>
function GetFeedStats(rssFile)
	
	Set objXML = Server.CreateObject("Microsoft.XMLDOM")
	objXML.Async = False
	objXML.SetProperty "ServerHTTPRequest", True
	objXML.ResolveExternals = false
	objXML.ValidateOnParse = false
	objXML.preserveWhiteSpace = false	
	'objXML.Load("http://api.feedburner.com/awareness/1.0/GetFeedData?uri="&request.QueryString("url"))
	objXML.Load("https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri="&request.QueryString("url"))
	
	Set objRoot = objXML.documentElement

	Set objItems = objRoot.getElementsByTagName("feed")
	For Each objItem in objItems					
		temp = objItem.selectSingleNode("entry").getAttribute("circulation")
	Next
	
	Set objRoot = Nothing
	Set objItems = Nothing

	GetFeedStats = temp
		
end function
</code>

<h4>Getting The Total Number Of Feedburner Subscribers With JQuery</h4>

<p>Next we use JQuery to get the response stream from our ASP file. The code is placed inside of $(document).ready(function() to ensure that we don't access our #feedburner SPAN until the DOM is fully loaded. 
I pass the URL we are checking on via a query string to our ASP file.</p>

<script type="text/javascript">
$(document).ready(function(){
	
	$.get("feedburner.asp?url=ng-tech", function(data){
		$("#feedburner").text(data);
	});

});
</script>

<h4>Putting It All Together</h4>

<code>
&lt;%
function GetFeedStats(rssFile)
	
	Set objXML = Server.CreateObject("Microsoft.XMLDOM")
	objXML.Async = False
	objXML.SetProperty "ServerHTTPRequest", True
	objXML.ResolveExternals = false
	objXML.ValidateOnParse = false
	objXML.preserveWhiteSpace = false	
	'objXML.Load("http://api.feedburner.com/awareness/1.0/GetFeedData?uri="&amp;request.QueryString("url"))
	objXML.Load("https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri="&amp;request.QueryString("url"))
	
	Set objRoot = objXML.documentElement

	Set objItems = objRoot.getElementsByTagName("feed")
	For Each objItem in objItems					
		temp = objItem.selectSingleNode("entry").getAttribute("circulation")
	Next
	
	Set objRoot = Nothing
	Set objItems = Nothing

	GetFeedStats = temp
		
end function
%&gt;

&lt;script type="text/javascript"&gt;
$(document).ready(function(){
	
	$.get("feedburner.asp?url=ng-tech", function(data){
		$("#feedburner").text(data);
	});

});
&lt;/script&gt;

&lt;span id="feedburner"&gt;&lt;/span&gt;
</code><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=36">View Comments [0]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Sun, 22 Feb 2009 21:05:27 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=36</guid>
<author>Neal Grosskopf</author>
<category>asp</category><category>jquery</category><category>rss</category>
</item>
<item>
<title>How To Get Total Diggs Using JQuery And ASP</title>
<link>http://www.nealgrosskopf.com/tech/thread.asp?pid=35</link>
<description>
<![CDATA[
<p>This is a companion article to my previous article "<a href="/tech/thread.asp?pid=34">How To Get Delicious Bookmark Total Using JQuery And JSON</a>". I recently wanted to add the total number of Diggs and Delicious bookmarks next to my 
"post to..." links at the bottom of my articles. While Digg does offer a free Digg counter that you can embed in your website I was unsatisfied with the styling they automatically applied to it. Really
all I wanted was a text node with a number in it. The solution was to use the <a href="http://apidoc.digg.com/">Digg API</a>.</p>

<p>I first wanted to mimic what I did with my Delicious bookmark total retrieval but didn't have any luck with Diggs JSON API variation so I turned to server side coding to accomplish my task.</p>

<h4>ASP File Code For Getting Total Diggs</h4>

<p>You'll want to place the following code in a separate file called "digg.asp". You'll also need to replace the following with your own domain name "Server.URLEncode("http://www.example.com/")". 
This is how Digg tracks their API usage.</p>

<code>
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Async = False
objXML.SetProperty "ServerHTTPRequest", True
objXML.ResolveExternals = false
objXML.ValidateOnParse = false
objXML.preserveWhiteSpace = false	
objXML.Load("http://services.digg.com/stories/?&appkey=" & Server.URLEncode("http://www.example.com/") & "&type=xml&link=" & request.QueryString("url"))

Set objRoot = objXML.documentElement

Set objItems = objRoot.getElementsByTagName("story")

For Each objItem in objItems					
	temp = objItem.getAttribute("diggs")
Next

Set objRoot = Nothing
Set objItems = Nothing

response.Write(temp)
</code>

<h4>Getting The Total Number Of Diggs With JQuery</h4>

<p>Next we use JQuery to get the response stream from our ASP file. The code is placed inside of $(document).ready(function() to ensure that we don't access our #digg SPAN until the DOM is fully loaded. I pass
the URL we are checking on via a query string to our ASP file.</p>

<code>
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function(){
	$.get(&quot;digg.asp?url=http://www.example.com/&quot;, function(data){
		$(&quot;#digg&quot;).text(data);
	});
});
&lt;/script&gt;

&lt;p&gt;Digg: &lt;span id=&quot;digg&quot;&gt;&lt;/span&gt;&lt;/p&gt;
</code>

<h4>Putting It All Together</h4>

<code>
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Async = False
objXML.SetProperty "ServerHTTPRequest", True
objXML.ResolveExternals = false
objXML.ValidateOnParse = false
objXML.preserveWhiteSpace = false	
objXML.Load("http://services.digg.com/stories/?&appkey=" & Server.URLEncode("http://www.example.com/") & "&type=xml&link=" & request.QueryString("url"))

Set objRoot = objXML.documentElement

Set objItems = objRoot.getElementsByTagName("story")

For Each objItem in objItems					
	temp = objItem.getAttribute("diggs")
Next

Set objRoot = Nothing
Set objItems = Nothing

response.Write(temp)


&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function(){
	$.get(&quot;digg.asp?url=http://www.example.com/&quot;, function(data){
		$(&quot;#digg&quot;).text(data);
	});
});
&lt;/script&gt;

&lt;p&gt;Digg: &lt;span id=&quot;digg&quot;&gt;&lt;/span&gt;&lt;/p&gt;
</code>

<h4>Conclusion</h4>

<p>I realize that not everyone uses classic ASP anymore but the same principles can be easily applied in PHP as well. For an example of this in action check out the source of the page you're
currently on.</p><p><a href="http://www.nealgrosskopf.com/tech/thread.asp?pid=35">View Comments [0]</a><img src='http://www.nealgrosskopf.com/files/xml/beacon/image.asp?e=tech' height='1' width='1' /></p>]]>
</description>
<pubDate>Tue, 17 Feb 2009 22:22:34 CST</pubDate>
<guid>http://www.nealgrosskopf.com/tech/thread.asp?pid=35</guid>
<author>Neal Grosskopf</author>
<category>jquery</category><category>asp</category>
</item>
</channel>
</rss>
