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

<channel>
	<title>Web Cash &#187; css</title>
	<atom:link href="http://www.earn-web-cash.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.earn-web-cash.com</link>
	<description>Writing, Designing, and Making Money Online</description>
	<lastBuildDate>Sun, 04 Dec 2011 22:52:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Marking Up and Styling an Image Gallery</title>
		<link>http://www.earn-web-cash.com/2008/03/25/semantic-markup-image-album/</link>
		<comments>http://www.earn-web-cash.com/2008/03/25/semantic-markup-image-album/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 00:32:36 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Markup]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/25/marking-up-and-styling-an-image-gallery/</guid>
		<description><![CDATA[While working on a new site (Rolling Horde), I decided to include a small image gallery. I randomly display four images from a flickr album in the sidebar. The pictures are presented in the mark-up that flickr creates, and I used the styling that came with the template I was working from. It creates a [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a new site (<a href="http://rolling-horde.net">Rolling Horde</a>), I decided to include a small image gallery.  I randomly display four images from a flickr album in the sidebar.</p>
<p>The pictures are presented in the mark-up that flickr creates, and I used the styling that came with the template I was working from.  It creates a simple two by two square of photos, with a slight gap in between them.</p>
<p>Although I like the way they are presented, I&#8217;m not sure I like the mark-up that flickr creates.  What would be the simplest, semantic way to mark-up and style images in a small album like this?<br />
<span id="more-181"></span></p>
<h4>Semantic Mark-up: An Unordered List</h4>
<p>Flickr places all of the photos in divs.  These are then styled to float next to each other or appear however you like.</p>
<p>In my opinion, the most semantic way to mark-up photos like this would be to create an unordered list.  A photo album is essentially a list of photos.</p>
<p>This could be an ordered list if the photos were intended to be sequential &#8211; like a photo essay or a comic book &#8211; but the average photo album is just a collection of pictures.</p>
<p>The mark-up would look something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>The images would then be displayed in a long, vertical list.</p>
<h4>Styling &#8211; Making the List Inline</h4>
<p>In the end, we&#8217;d like to have the images sit side by side.  Ideally, they&#8217;d form a rectangle of either 2 x 3 pictures, or 3 x 2.</p>
<p>The first thing we want to do, then, is remove the list style type, clear the padding/margins of the list, and make the images appear next to each other.  The last bit we can achieve by giving the list items the &#8220;display: inline&#8221; css declaration.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#images</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#images</span> li <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This would create a simple horizontal list, like this&#8230;</p>
<ul id="images_one">
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
</ul>
<h4>Width: Restricting the Number of Columns</h4>
<p>Notice how the list terminates at the end of its container div and continues on a second line?  </p>
<p>Without a width declaration, the unordered list expands as large as wide as it can.  When that width limit is hit, it starts a second line, and continues until all of the list items have been displayed.</p>
<p>We can use this to our advantage by setting a width declaration.  This allows us to limit the number of images to be displayed in each row.</p>
<p>If our images are 75px square, and we want to display three images across, we can set our width to be about 250px.  The extra space can be used later for paddings and margins &#8211; but the images will appear left justified within the list container.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#images</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#images</span> li <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This would create a list like this&#8230;</p>
<ul id="images_two">
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
</ul>
<h4>Finishing Touches: Padding and Borders</h4>
<p>With the basic structure complete, we can add a few finishing touches.</p>
<p>First, we might we to add a little padding to the images.  This would space them out a few pixels from each other so that they don&#8217;t appear so cramped.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#image</span> img <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Adding this line to the css file would change the image album to this.</p>
<ul id="images_three">
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
</ul>
<p>Finally, a cool effect for images is to add a border around the image.  If you include a padding value for the img tag, the border is placed 2-3 pixels away from the edge of the picture.  It gives a nice framing effect.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#image</span> img <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">thin</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This final change would look something like this.</p>
<ul id="images_four">
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
<li><img src="http://farm4.static.flickr.com/3047/2362739858_c82b4de7c2_s.jpg" /></li>
</ul>
<p>By using an unordered list to mark-up your image collection, you end up with semantically correct and simple to style content.  Much better, in my opinion, than a string of divs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/25/semantic-markup-image-album/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing a WP Plugin: Per-Post CSS and JS</title>
		<link>http://www.earn-web-cash.com/2008/02/17/per-post-css-js/</link>
		<comments>http://www.earn-web-cash.com/2008/02/17/per-post-css-js/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 22:18:52 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/17/per-post-css-js/</guid>
		<description><![CDATA[A few weeks ago, I installed the &#8220;Per Post CSS and JS&#8221; plugin for WordPress. This allows you to add a custom field to your post and include extra .css or .js files to link to that individual page. I only realized today &#8211; while testing something else &#8211; that the plugin had been firing [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I installed the &#8220;Per Post CSS and JS&#8221; plugin for WordPress.  This allows you to add a custom field to your post and include extra .css or .js files to link to that individual page.</p>
<p>I only realized today &#8211; while testing something else &#8211; that the plugin had been firing off warning messages because of an oversight in the code.  Warning messages annoy me, so I decided to fix it up.<br />
<span id="more-124"></span></p>
<h5>Where&#8217;s the Error?</h5>
<p>The plug-in consists of one file &#8211; <a href='http://www.earn-web-cash.com/wp-content/uploads/2008/02/per-post-css.txt' title='Per Post CSS and JS WP Plugin'>per-post-css.php</a>.</p>
<p>Towards the end of the function per_post_css_js, the script loops through any retrieved CSS and JS files.  During these loops, the link tags are added to the head element of the page.</p>
<p>Here&#8217;s the line that deals with CSS stylesheets.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_css</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
  <span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;style type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/css<span style="color: #000099; font-weight: bold;">\&quot;</span> media=<span style="color: #000099; font-weight: bold;">\&quot;</span>screen<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt; @import url(&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$css</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;); &lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice anything potentially wrong here?  What happens if there are <strong>no</strong> custom CSS files attached to your page?</p>
<p>Foreach looks for an array ($array_css).  If a value is passed to foreach that is not an array, it&#8217;ll fire off a warning &#8211; and that&#8217;s just what it did.</p>
<p>The fix is simple enough.  Before attempting to iterate the loop, first check to see that $array_css (and later $array_js) is in fact an array.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_css</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_css</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&lt;style type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/css<span style="color: #000099; font-weight: bold;">\&quot;</span> media=<span style="color: #000099; font-weight: bold;">\&quot;</span>screen<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt; @import url(&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$css</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;); &lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It&#8217;s a minor problem that creates some inconsequential warnings&#8230; but it annoyed me so I fixed it.  If you have display_errors turned off in PHP (which I usually do) you won&#8217;t notice the problem either.</p>
<h5>Per Post CSS and JS Updated Source Code</h5>
<p>In the plug-in file, the homepage is listed as <a href="http://www.flog.co.nz">http://www.flog.co.nz</a>.  Oddly enough, I didn&#8217;t see a reference to the script on the page anymore, although the author still updates the page.</p>
<p>When I searched for a new copy of Per Post CSS and JS, I found a listing in a WP Plugin Directory &#8211; which pointed to an old post on flog.co.nz.  That post and the link to the source code are both dead now.  Perhaps they were cleaned up to make room for new content.</p>
<p>Regardless, I&#8217;m going to re-post the <a href='http://www.earn-web-cash.com/wp-content/uploads/2008/02/per-post-css.txt' title='Per Post CSS and JS WP Plugin'>source code for the Per Post CSS and JS WP Plugin</a> here to keep it available.</p>
<p>Kudos and thanks to the original author, Adam Burmister.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/17/per-post-css-js/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Alternate CSS Styles Using PHP</title>
		<link>http://www.earn-web-cash.com/2008/02/13/alternate-css-styles-php/</link>
		<comments>http://www.earn-web-cash.com/2008/02/13/alternate-css-styles-php/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 04:08:08 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/13/how-to-alternate-css-styles-using-php/</guid>
		<description><![CDATA[There are a lot of situations in which you'd like to alternate CSS styles from one element to the next.  Long tables, for example, look a lot nicer when the background color of the rows is alternated (think: Gmail).

How do we do that?  Some pretty simple PHP can help you accomplish this task and spice up your HTML/CSS.]]></description>
			<content:encoded><![CDATA[<p>There are a lot of situations in which you&#8217;d like to alternate CSS styles from one element to the next.  Long tables, for example, look a lot nicer when the background color of the rows is alternated.</p>
<p>How do we do that?  Some pretty simple PHP can help you accomplish this task and spice up your HTML/CSS.<br />
<span id="more-111"></span></p>
<h5>Look At the HTML/CSS</h5>
<p>Before we start making things dynamic, let&#8217;s look at the basic HTML.</p>
<p>Let&#8217;s say we want to make a list of items &#8211; in a table &#8211; maybe a list of emails.  The end result should be a table with alternating background colors for rows &#8211; white and light blue.</p>
<p>If we were to create this table by hand, it might look something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blue&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>E-mail subject<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>Sender<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;white&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>E-mail subject<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>Sender<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span></pre></div></div>

<p>This assumes that we have a CSS class defined as &#8220;blue&#8221; with a blue background and &#8220;white&#8221; with a white background.</p>
<h5>Adding Some PHP to Assign Classes</h5>
<p>We&#8217;re setting the background color by adding a class declaration to the table row.  The first step in making this dynamic is to use PHP to echo the class.  Like this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php echo 'blue'; ?&gt;</span></span>&quot;&gt;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span> ... <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span></pre></div></div>

<p>We&#8217;ve taken the same table row element from before and replaced &#8220;blue&#8221; with a php snippet that echos the same phrase, &#8220;blue.&#8221;  The end result is the same HTML that we created in the first example.</p>
<h5>Dynamically Choosing the Class</h5>
<p>The final step in making this dynamic is to add a conditional statement to the PHP block.  For example, let&#8217;s say we&#8217;re executing a loop 5 times.  On the odd iterations (1, 3, 5) we&#8217;ll use &#8220;blue&#8221; as the class.  On the even iterations (2, 4), we&#8217;ll use &#8220;white.&#8221;</p>
<p>To test whether or not a number is odd, you can use the modulus (%) operator.  This returns the remainder of a division &#8211; so <code>2 % 3 = 1</code>.  With a little basic math theory, we know that if a number is divided by 2 and has no remainder it&#8217;s even &#8211; but if there&#8217;s a remainder of 1 it&#8217;s odd.</p>
<p>Here&#8217;s what the loop might look like.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   &lt;tr class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;blue&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;white&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&lt;td&gt; ... &lt;/td&gt;&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h5>That If Statement Is Kind of Long&#8230;</h5>
<p>Well, we can shorten that up.  This is a great place to use the obscure and un-readable ternary operator in PHP.  It&#8217;s a shortcut that allows you to write a simple if-statement in one line.</p>
<p>For example&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span> ? <span style="color: #0000ff;">&quot;Yes&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;No&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The ternary operator takes three parts &#8211; the conditional statement (in this case I just wrote true), a value to return if the statement is true (&#8220;Yes&#8221;), and a value to return if the statement is false (&#8220;No&#8221;).  I echo&#8217;ed the result just so you could see what the statement outputs (in this case, &#8220;Yes&#8221;).</p>
<p>We turn our previous if statement into a ternary operator statement and shorten up that code block quite a bit.  Like so&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   &lt;tr class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> ? <span style="color: #0000ff;">&quot;blue&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;white&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&lt;td&gt; ... &lt;/td&gt;&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Creating these table rows is just one example of how you can use PHP to help spice up your HTML.  With this concept, you can dynamically alternate styles based on a bunch of factors.</p>
<p>How else could you use this?</p>
<p>You could alternate the background colors of comments in your blog template.  You could include a bottom-border after every five rows in your table.  You could make a calendar module and display Saturday and Sunday in boldface.</p>
<p>The options are really endless &#8211; so long as you understand the basic principal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/13/alternate-css-styles-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Use Custom Stylesheets on a Per Post Basis in WordPress</title>
		<link>http://www.earn-web-cash.com/2008/02/05/per-post-css-wordpress/</link>
		<comments>http://www.earn-web-cash.com/2008/02/05/per-post-css-wordpress/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 01:31:55 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[stylesheet]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/05/how-to-use-custom-stylesheets-on-a-per-post-basis-in-wordpress/</guid>
		<description><![CDATA[Something I struggled with recently was assigning individual style sheets to posts on this WordPress blog. For example, if I was writing a CSS tutorial I didn&#8217;t want to muck up my general stylesheet with a bunch of styles &#8211; it&#8217;d be nice to write a small stylesheet and attach it only to the specific [...]]]></description>
			<content:encoded><![CDATA[<p>Something I struggled with recently was assigning individual style sheets to posts on this WordPress blog.  For example, if I was writing a CSS tutorial I didn&#8217;t want to muck up my general stylesheet with a bunch of styles &#8211; it&#8217;d be nice to write a small stylesheet and attach it only to the specific post that needs it.</p>
<p>Unfortunately, this isn&#8217;t a built in function of WordPress.  Fortunately, you can add this functionality with a plugin.<br />
<span id="more-100"></span></p>
<h5>Headspace</h5>
<p>I originally accomplished this with the <a href="http://urbangiraffe.com/plugins/headspace/">Headspace plugin</a>.</p>
<p>Headspace is an all in one SEO plugin for WordPress.  It&#8217;s major function is to allow you to add custom titles, tags, and meta descriptions to your WordPress posts.  This should help with your SEO and SERP.</p>
<p>An added bonus is that you can add individual CSS stylesheets and JS scripts to each page.  There&#8217;s an extra field in the writing page where you can add either of these two options.</p>
<p>This part of Headspace worked great.  However, I was having trouble getting the other SEO functions to work.  I was assigning descriptions and titles, but no meta tags were being generated.</p>
<h5>Replacing Headspace</h5>
<p>To fix that problem, I de-activated Headspace and got the <a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/">All In One SEO Pack</a> WordPress Plugin.  It worked great, but that&#8217;s another post altogether.</p>
<p>I didn&#8217;t realize until <strong>after</strong> I had deactivated Headspace that I had also deactivated the custom CSS on a few posts/pages.  I checked the pages and low-and-behold the custom CSS didn&#8217;t exist anymore.</p>
<p>I didn&#8217;t want to re-active Headspace just for this function, so I went off in search of a better solution.</p>
<h5>Per Post CSS and Javascript</h5>
<p>I eventually stumbled on this very simple plugin &#8211; <a href="http://www.flog.co.nz/index.php/journal/per-post-css-js/">Per Post CSS and JS</a>.</p>
<p>It&#8217;s only a few short lines.  It uses the custom fields function of WordPress to add the custom link tags.  You define a CSS or JS field for a post, enter the URL, and the plug-in adds a link tag to the head section of your page.</p>
<p>It&#8217;s quite simple, and if I didn&#8217;t find a suitable script I was going to make one myself.  However, this works perfectly well and I don&#8217;t think I could really expand on it (except maybe creating the CSS and JS fields on the writing screen, instead of using the custom fields) &#8211; so I doubt I&#8217;ll be writing my own plug-in anytime soon.</p>
<p>When it&#8217;s possible, re-use.  Then focus your energy on things you <strong>need</strong> to do yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/05/per-post-css-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use Attribute Selectors to Fine Tune Your CSS</title>
		<link>http://www.earn-web-cash.com/2008/01/31/css-attribute-selectors/</link>
		<comments>http://www.earn-web-cash.com/2008/01/31/css-attribute-selectors/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 00:28:01 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/31/css-attribute-selectors/</guid>
		<description><![CDATA[Here's a quick tip for fine tuning your CSS declarations.  

You can use attribute selectors to style an html element that contains an attribute with the value that you declare.  This allows you to do a bunch of cool stuff - like style different "input" types differently, style anchor tags with titles differently, and et]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick tip for fine tuning your CSS declarations.  </p>
<p>You can use attribute selectors to style an html element that contains an attribute with the value that you declare.  This allows you to do a bunch of cool stuff &#8211; like style different &#8220;input&#8221; types differently, style anchor tags with titles differently, and etc.<br />
<span id="more-89"></span><br />
How does it work?</p>
<p>An attribute selector follows this basic formula&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">&#91;</span>attribute<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;value&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> style information... <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Like an id or class selector, you can use it alone (as in the example above), or attach it to a specific html element.</p>
<p>How can we use it?  Here are a few examples.</p>
<h5>Style Links with Title Elements Differently</h5>
<p>You could use this to give users a hint that an anchor tag or link has a title element.  This way they know to hover over the link and read the tooltip.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #00AA00;">&#91;</span>title<span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">thin</span> <span style="color: #993333;">dotted</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>That declaration gives any anchor tag containing a &#8220;title&#8221; attribute a thin dotted blue underlining.  You may have to tweak it a bit to make sure the normal anchor-underlining doesn&#8217;t interfere with it.</p>
<h5>Style Particular Input Types on Forms</h5>
<p>You can use this to style Submit buttons, Text Inputs, etc. &#8211; independent of other input types.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This simple declaration gives all Submit buttons a blue background color.  Fairly silly, but the point is the declaration &#8211; not the actual styling.  You could do something similar with these declarations&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">input <span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #808080; font-style: italic;">/* style information */</span> <span style="color: #00AA00;">&#125;</span>
input <span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;password&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #808080; font-style: italic;">/* style information */</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<h5>Style Internal Links Different from External Links</h5>
<p>This is a really nifty trick&#8230; but unfortunately it requires a bit of CSS 3.  This will probably invalidate your CSS, and your mileage may vary.</p>
<p>It&#8217;s still interesting to try out.</p>
<p>You can use &#8220;^=&#8221; instead of &#8220;=&#8221; to signal that the browser should match any element with the given attribute that contains the quoted string.  It doesn&#8217;t have to be an exact match.  So you can use &#8220;^=&#8217;mydomain.com&#8217;&#8221; to match any links that point to the domain you&#8217;re working on.</p>
<p>Like so&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #00AA00;">&#91;</span>href<span style="color: #00AA00;">^=</span><span style="color: #ff0000;">&quot;earn-web-cash.com&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #808080; font-style: italic;">/* style information */</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You could use this to given internal links a slightly different color &#8211; some kind of queue to help the user differentiate between internal and external links.</p>
<p>For a longer list of ways to use this neat little trick, check out this post <a href="http://www.search-this.com/2007/11/14/hip-to-be-square/" title="Uses for CSS Attribute Selectors">Hip to Be Square</a>.  There&#8217;s also a list of the different ways to search for values (like ^=) &#8211; which will be valid in CSS 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/31/css-attribute-selectors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Create a 3D Button Using CSS and a Gradient Image</title>
		<link>http://www.earn-web-cash.com/2008/01/28/3d-button-gradient/</link>
		<comments>http://www.earn-web-cash.com/2008/01/28/3d-button-gradient/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 00:30:43 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/28/3d-button-gradient/</guid>
		<description><![CDATA[While I was browsing through <a href="www.dzone.com" title="Developer's Zone">dzone</a> today, I stumbled on this <a href="http://www.dave-woods.co.uk/?p=158">3d button css tutorial by Dave Woods</a>.

Using some simple css and a little color know-how, he shows you how to turn a square button into a pseudo 3-dimensional button.  I'll take it a step further and add a gradient background image to enhance the lighting effect.  Like this...]]></description>
			<content:encoded><![CDATA[<p>While I was browsing through <a href="http://www.dzone.com" title="Developer's Zone">dzone</a> today, I stumbled on this <a href="http://www.dave-woods.co.uk/?p=158">3d button css tutorial by Dave Woods</a>.</p>
<p>Using some simple css and a little color know-how, he shows you how to turn a square button into a pseudo 3-dimensional button.  I&#8217;ll take it a step further and add a gradient background image to enhance the lighting effect.  Like this&#8230;<br />
<span id="more-79"></span><br />
<a class="button" href="http://www.web-cash-com">Web Cash</a></p>
<p>We can build this button up in a couple of steps.  First, we need to make our anchor tag (link) into a block &#8211; with some padding and a background.</p>
<p><a class='button2' href="http://www.earn-web-cash.com">Web Cash</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ab7f20</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.5em</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>That gives us a nice, squarish look&#8230; kind of like a button.  But it definitely looks flat and two dimensional.  The next step we&#8217;re going to take is to add a gradient background.  This will add a nice lighting effect &#8211; giving the button a bit of depth.</p>
<p>To do this, we need a background image.  I made a gradient image in GIMP (read this <a href="http://www.earn-web-cash.com/2008/01/24/how-to-create-a-gradient-background-image-in-gimp/">tutorial to learn how to create a gradient image</a> like this).  Then we need to add the image to the css declaration by changing one line.</p>
<p><a class='button3' href="http://www.earn-web-cash.com">Web Cash</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ab7f20</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">uploads/2008/01/gradient-button.thumbnail.png</span><span style="color: #00AA00;">&#41;</span>
     <span style="color: #993333;">repeat-x</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>Notice that the color (#ab7f20) is the same as the second color in the gradient image.  This gradient is long enough to color the whole area &#8211; but if our button gets too tall, we want it to blend in nicely.</p>
<p>The last thing we need to do is give it some borders &#8211; light on the top and dark on the bottom.  This will give it the illusion of being hit by the light.  It&#8217;ll also accentuate the effect of the gradient background image.</p>
<p><a class="button" href="http://www.web-cash-com">Web Cash</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f6daa3</span> <span style="color: #933;">3px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#724f05</span> <span style="color: #933;">3px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#724f05</span> <span style="color: #933;">3px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f6daa3</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#724f05</span> <span style="color: #933;">3px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f6daa3</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f6daa3</span> <span style="color: #933;">2px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#724f05</span> <span style="color: #933;">3px</span> <span style="color: #993333;">solid</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Notice that the background colors are flipped when you hover over the button.  This gives the illusion that you are actually &#8220;pressing&#8221; the button &#8211; just by flipping the way the lighting hits.</p>
<p>You could also use the special &#8220;inset&#8221; and &#8220;outset&#8221; border types to cut down on that last css declaration.  You lose a little control over the color and light placement, but it gives a pretty decent effect.  Like this&#8230;</p>
<p><a class="button" style="border: #ab7f20 3px outset;" href="http://www.web-cash-com">Web Cash</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ab7f20</span> <span style="color: #933;">3px</span> <span style="color: #993333;">outset</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.button</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ab7f20</span> <span style="color: #933;">3px</span> <span style="color: #993333;">inset</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>And that&#8217;s all there is to it.  Change the colors to your liking, add a custom gradient image, and you&#8217;ve got a nifty little 3 dimensional button.</p>
<p>All it takes is some css.  No need to create a bunch of fancy images, and it&#8217;s easily expandable to accommodate the text inside of your button.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/28/3d-button-gradient/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to Create a Gradient Background Image in GIMP</title>
		<link>http://www.earn-web-cash.com/2008/01/24/how-to-create-a-gradient-background-image-in-gimp/</link>
		<comments>http://www.earn-web-cash.com/2008/01/24/how-to-create-a-gradient-background-image-in-gimp/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 21:59:18 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[GIMP Tutorial]]></category>
		<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Redirected]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[GIMP]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/24/how-to-create-a-gradient-background-image-in-gimp/</guid>
		<description><![CDATA[The other day I wrote about how to add a gradient background to a css tooltip. So I thought it might be a good idea to walk through how to create the actual gradient image. Since I recently switched to Ubuntu Linux, I don&#8217;t use Photoshop anymore. GIMP all the way. So this tutorial will [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/01/gradient.png' title='Sample Gradient Background'><img class="alignright" src='http://www.earn-web-cash.com/wp-content/uploads/2008/01/gradient.thumbnail.png' alt='Sample Gradient Background' /></a>The other day I wrote about how to <a href="http://www.earn-web-cash.com/2008/01/21/tooltip-gradient/" title="Add a gradient background to a tooltip">add a gradient background to a css tooltip</a>.  So I thought it might be a good idea to walk through how to create the actual gradient image.</p>
<p>Since I recently switched to Ubuntu Linux, I don&#8217;t use Photoshop anymore.  GIMP all the way.  So this tutorial will show you briefly how to create a gradient image in GIMP and then use it as the background of an html element.<br />
<span id="more-60"></span></p>
<h5>Create a Blank Image (120px x 120px)</h5>
<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/01/blank-image.jpg' title='Gradient Background Tutorial - Blank Image (Step 1)'><img class="alignright" src='http://www.earn-web-cash.com/wp-content/uploads/2008/01/blank-image.thumbnail.jpg' alt='Gradient Background Tutorial - Blank Image (Step 1)' /></a>First thing &#8211; fire up GIMP and create a new image.  Usually a gradient background image is 1 pixel wide.  For now we&#8217;ll create a bigger image so it&#8217;s easier to see what we&#8217;re doing &#8211; 120 pixels by 120 pixels.  You can crop the image down to a 1 pixel width later.</p>
<h5>Set the Foreground and Background Colors</h5>
<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/01/color-chooser.jpg' title='Gradient Background Tutorial - Color Chooser (Step 2)'><img class="alignright" src='http://www.earn-web-cash.com/wp-content/uploads/2008/01/color-chooser.thumbnail.jpg' alt='Gradient Background Tutorial - Color Chooser (Step 2)' /></a>When you create a gradient, you need to set two colors &#8211; the beginning color (usually the foreground) and the ending color (usually the background color).  To change these colors, click on the square swatch of the foreground color in your toolbar (see the circled area in the screenshot to the right).</p>
<p>This should bring up a box titled, &#8220;Change Foreground Color.&#8221;  Pick a dark color &#8211; I used #981313.  Then, click on the Background Color Swatch (the one right behind the Foreground color).  Change the background color to a lighter version of your foreground color &#8211; I used #f17b7b.</p>
<h5>Select the Gradient Tool</h5>
<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/01/gradient-tool.jpg' title='Gradient Background Tutorial - Gradient Tool (Step 3)'><img class="alignright" src='http://www.earn-web-cash.com/wp-content/uploads/2008/01/gradient-tool.thumbnail.jpg' alt='Gradient Background Tutorial - Gradient Tool (Step 3)' /></a>Now that you&#8217;ve chosen the two colors, you&#8217;re ready to create the gradient.  Click on the &#8220;Gradient&#8221; tool &#8211; it&#8217;s the square that fades from black to light gray.  See the screenshot to the right.  There are a bunch of options you could customize, but for a standard gradient background image you&#8217;re better off leaving them alone.</p>
<h5>Draw the Gradient!  Then Crop Away</h5>
<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/01/dragging-gradient.jpg' title='Gradient Background Tutorial - Drawing the Gradient (Step 4)'><img class="alignright" src='http://www.earn-web-cash.com/wp-content/uploads/2008/01/dragging-gradient.thumbnail.jpg' alt='Gradient Background Tutorial - Drawing the Gradient (Step 4)' /></a>Now you can actually create the gradient by clicking and dragging on your image canvas.  Position the tool at the top border of your canvas (if you look in the bottom left, it&#8217;ll tell you when you&#8217;re over pixel &#8220;0&#8243;).  Hold down the Control button to force GIMP to draw a straight line, and drag the cursor down to the bottom pixel of your canvas.</p>
<p>Let go.  Voila!  You&#8217;ve got a nice gradient image created.</p>
<p>You could use it as-is in your css stylesheet, but it&#8217;s usually a good idea to trim your picture to 1px wide.  The browser can simply repeat the image across the entire width of the element &#8211; so making it wider than 1 px is simply wasting bandwidth.  Go ahead and crop the image now, and in the future make your gradient images 1 px wide by whatever height you want.</p>
<p>Now, let&#8217;s write the css to use this as a background image for an html element.</p>
<pre><code>.gradient {
  background: #f17b7b url(images/gradient.png)
    repeat-x top; }</code></pre>
<p>There&#8217;s four pieces to this shorthand css declaration.</p>
<ul>
<li><code>#f17b7b</code> sets the background color.  This is the same as the bottom color in our gradient, so that if the container is taller than the gradient image it seems to blend smoothly.</li>
<li><code>url(images/gradient.png)</code> sets our gradient image as the background image.  Make sure you change the path to where-ever you uploaded your gradient image.</li>
<li><code>repeat-x</code> tells the browser to repeat the image left-to-right for the entire width of the container.  This is what makes our 1-pixel background image &#8220;stretch&#8221; across the entire width.</li>
<li><code>top</code> simply tells the background image to align itself to the top edge of the container.  Not always necessary, but your better safe than sorry.</li>
</ul>
<p>And that&#8217;s all there is to it.  Create an html element with class <code>gradient</code> and it should have your lovely gradient background.</p>
<p>So get to it.  Start drawing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/24/how-to-create-a-gradient-background-image-in-gimp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Check Your Websites Appearance in Other Browsers with Browsershots</title>
		<link>http://www.earn-web-cash.com/2008/01/23/website-in-browsers/</link>
		<comments>http://www.earn-web-cash.com/2008/01/23/website-in-browsers/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 22:55:11 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/23/website-in-browsers/</guid>
		<description><![CDATA[One of the most frustrating aspects of web design is trying to make your website look good in every browser. If you use some advanced css techniques, you never know how an older browser or a different platform is going to handle it. You can test how your site displays in a few browsers &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most frustrating aspects of web design is trying to make your website look good in every browser.  If you use some advanced css techniques, you never know how an older browser or a different platform is going to handle it.</p>
<p>You can test how your site displays in a few browsers &#8211; for example, I often check mine out in Windows IE, Ubuntu Firefox, and Ubuntu Opera.  But how am I going to check it on Mac browsers like Safari?<br />
<span id="more-58"></span><br />
Enter <a href="http://www.browsershots.com" title="Site to check your page in different browsers">Browsershots</a>.</p>
<p>The premise is very simple.  You check off a list of browsers and platforms, enter your website&#8217;s url, and click submit.  Then the servers open your site, take a screenshot, and upload the display to Browsershots.</p>
<p><a href='http://www.earn-web-cash.com/wp-content/uploads/2008/01/teachbabel-msie55.jpg' title='Browsershots Screenshot of Babel'><img src='http://www.earn-web-cash.com/wp-content/uploads/2008/01/teachbabel-msie55.thumbnail.jpg' alt='Browsershots Screenshot of Babel' / class="alignright"></a>You can then view the screenshots and see how your website appeared in those browsers.  You can check out some <a href="http://browsershots.org/http://www.teachbabel.com/">sample displays</a> for an <a href="http://www.teachbabel.com">education related website</a> that I created.</p>
<p>Your options are pretty extensive.  At the moment you can choose from 36 Linux browsers, 12 Windows browsers, and 4 Mac OS browsers.</p>
<p>After you submit your request, you need to wait until your website comes up in the queue.  Each server (factory, as they call it at Browsershots) has its own queue.  A lot of the servers will be done in a couple of minutes, but some queues can be one to two hours long.</p>
<p>One of the downsides to the site is that your request will expire in 30 minutes.  The completed screenshots will stay up there, but if you have any requests left in the queue they will be canceled.</p>
<p>You can refresh your request by clicking a button, but if you get stuck in a 90 minute queue you&#8217;ll have to remember to refresh your request several times.</p>
<p>All in all, very useful tool.  I plan to use it to test out any future design projects.  So the next time you want to see how a foreign browser would display your site, head over to <a href="http://www.browsershots.com">Browsershots</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/23/website-in-browsers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Add a Gradient Background to a CSS Tooltip</title>
		<link>http://www.earn-web-cash.com/2008/01/21/tooltip-gradient/</link>
		<comments>http://www.earn-web-cash.com/2008/01/21/tooltip-gradient/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 02:13:18 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[tooltip]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/21/tooltip-gradient/</guid>
		<description><![CDATA[In an earlier post, we learned how to create a tooltipKind of like this boring, gray tooltip. using CSS. I walked you through the mechanics of creating the tooltip and left the actual css styling up to you. Today, we&#8217;ll take a look at how to make this tooltip look a bit nicer &#8211; using [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a href="http://www.earn-web-cash.com/2008/01/19/create-css-tooltips/">earlier post</a>, we learned how to create a <a class="tooltip">tooltip<span>Kind of like this boring, gray tooltip.</span></a> using CSS.  I walked you through the mechanics of creating the tooltip and left the actual css styling up to you.</p>

<p>Today, we&#8217;ll take a look at how to make this tooltip look a bit nicer &#8211; using a gradient background and some extra styling.</p>
<span id="more-56"></span>
<p>To review, here&#8217;s the basic styling to create the tooltip.  Refer to the <a href="http://www.earn-web-cash.com/2008/01/19/create-css-tooltips/">original post for an explanation of the CSS/HTML</a>.</p>

<pre><code>a.info span {
    display: none; }

a.info:hover {
    position: relative; }

a.info:hover span {
    display: block;
    position: absolute;
    top: 0;
    left: 0; }
</code></pre>

<p>In order to make this look a bit nicer, kind of like <a class="tooltip">this tooltip<span class="gradient">This tooltip has a gradient background, some bold-face font, and a nice border on top and bottom.</span></a>, we&#8217;re going have to add some more style to <code>a.info:hover span</code>.</p>

<p>First, let&#8217;s change the colors a bit, add a nicer border, add some padding, and move the tooltip down about one line.</p>

<pre><code>a.info hover span {
   top: 1.5em;
   padding: 1em;
   border-top: 3px solid #d58700;
   border-bottom: 3px solid #d58700;
   border-left: none;
   border-right: none;
   color: white;
   background: #516898; }</code></pre>

<p>Adding that styling would leave us with <a class="tooltip">this tooltip<span class="gradient" style="background: #516898;">This looks a lot nicer, but we still need a gradient background.</span></a>.</p>

<p>I created a <a href="http://www.earn-web-cash.com/wp-content/themes/webcash/images/tooltip-gradient.png" alt="Gradient image for the background of the tooltip">gradient image</a> in GIMP.  You should be able to do this in your favorite image editing program.</p>

<p>I made the gradient image 120px tall.  I figured that&#8217;s high enough for the average tooltip, and longer ones will be covered by the standard background color.  This background color should be the same as the bottom color of the gradient.  That way when the gradient ends&#8230; it blends in nicely.</p>

<p>To add the gradient, we&#8217;ll change one line in the css declaration for <code>a.info:hover span</code> &#8211; the <code>background</code> line.</p>

<pre><code>background: #516898 url
  (images/tooltip-gradient.png) repeat-x top;</code></pre>

<p>Now we&#8217;ve got our <a class="tooltip">final tooltip<span class="gradient">This should be nicely styled.  Looks good to me anyway.</span></a>.</p>

<p>You&#8217;ll notice a few things in the <code>background</code> declaration &#8211; and these hold true for any time you use a gradient background.  I included a color &#8211; which is equal to the bottom end of the gradient.  This way it can blend in if the tooltip becomes longer than the gradient image.</p>

<p>I included <code>repeat-x</code> &#8211; which means that the gradient image will be repeated every 1 px along the x-axis.  This let&#8217;s you expand the image to the full width of the block, but only have to load a nicely small 1px wide image.  I also included <code>top</code> to make sure that the gradient appears all the way to the top of the tooltip&#8217;s box.</p>

<p>Well there you have it.  Once you get the mechanics of the tooltip down, it&#8217;s pretty simple to add extra styling like a gradient background image.  All you need to do is create your own gradient and tailor the colors to your own needs.</p>

<p>Happy tool-tipping.</p>]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/21/tooltip-gradient/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Create Tooltips You Can Style with CSS</title>
		<link>http://www.earn-web-cash.com/2008/01/19/create-css-tooltips/</link>
		<comments>http://www.earn-web-cash.com/2008/01/19/create-css-tooltips/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 22:07:48 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[tooltip]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/19/how-to-create-tooltips-you-can-style-with-css/</guid>
		<description><![CDATA[Hover your mouse over this link to Web Cash. Notice the tooltip? You can achieve a tooltip like that on any anchor text by defining a &#8220;title&#8221; attribute. However, it will also be bland, yellow, and un-styled. You can&#8217;t control the size of the box, style of the font, or the general appearance of the [...]]]></description>
			<content:encoded><![CDATA[<p>Hover your mouse over this <a href="http://www.earn-web-cash.com" title="This link will take you to the front page of Web Cash">link to Web Cash</a>.  Notice the tooltip?</p>

<p>You can achieve a tooltip like that on any anchor text by defining a &#8220;title&#8221; attribute.  However, it will also be bland, yellow, and un-styled.  You can&#8217;t control the size of the box, style of the font, or the general appearance of the tooltip at all.</p>

<p>But there&#8217;s a better way.  This tutorial will show you how to create custom tooltips using simple, valid HTML and CSS.  Once you&#8217;ve created the basic tooltip, you can style it to your heart&#8217;s content.</p>
<span id="more-44"></span>
<p>Before diving into the code, we should take a look at the CSS/HTML mechanics that we&#8217;ll need to build this thing.  If you feel confident that you know everything&#8230; then feel free to skip ahead.  Otherwise, read along.</p>

<p>First, let&#8217;s take a look at our goal.  We need to&#8230;</p>
<ul>
	<li>Create a box to hold the tooltip.</li>
	<li>Make the box invisible.</li>
	<li>Make the box visible once we mouse over our target text.</li>
	<li>Make the box appear &#8220;above&#8221; the page, instead of inline with the page.</li>
</ul>

<h5>Now It&#8217;s Here, Now It&#8217;s Not &#8211; Pseudo Classes</h5>

<p>In order to make our box appear and disappear, we need to use a little html/css magic called pseudo-classes.  Without these, we&#8217;d have to use javascript to detect when we mouse-over the target text.</p>

<p>Anchors (&lt;a&gt;) tags have a few built in pseudo classes &#8211; a:visited, a:active, and a:hover.  This allows you to style different types of anchors differently.  For example, an anchor tag will usually change color when you hover over it.</p>

<p>We&#8217;re going to use this to make our box appear and disappear.  The box will initially be invisible.  Then, using the a:hover pseudo-class, when we hover over the anchor tag the box will become visible.</p>

<h5>Creating a Box &#8211; Holding the Tooltip</h5>

<p>In order to display our tooltip and make it appear and re-appear, we need to create a container for it.  Then we need to position it.</p>

<p>What&#8217;s the natural container tag?  A <code>&lt;div&gt;</code>.  Unfortunately, Internet Explorer doesn&#8217;t like the <code>&lt;div&gt;</code> tag, so we&#8217;ll use a <code>&lt;span&gt;</code> tag instead.  To hell with semantics.  It&#8217;s still valid html.</p>

<p>Initially, this <code>&lt;span&gt;</code> is going to be styled with <code>display:none</code>.  Then, when the a:hover becomes active, it will switch to <code>display:block</code>.</p>

<p>We also need to position the span so that it appears &#8220;above&#8221; the rest of the page.  We&#8217;ll need two css attributes to do this.  First, we&#8217;ll give the anchor a <code>position:relative</code> declaration.  Then, we give our span a <code>position:absolute</code> declaration.</p>

<p>This will make the tooltip hover above the rest of the page &#8211; and it&#8217;s position will be based on the relative position of the anchor text.</p>

<h5>Building the HTML and CSS</h5>

<p>Now that we know the basic building blocks, let&#8217;s look at the actual markup.</p>

<p>Here&#8217;s the HTML you would use to create the tooltip.</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Here’s some more sample text.  This 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'info'</span>&gt;</span>anchor<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>CSS tooltip.  We 
  can style this!<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span> has a css-based tooltip
  that we can style to our liking.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></pre></div></div>




<p>There&#8217;s three basic elements here.  The regular text &#8211; enclosed in a p tag.  Our target text is enclosed in an anchor tag with class &#8220;info.&#8221;  The actual tooltip is in a <code>&lt;span&gt;</code> tag <strong>inside</strong> the anchor tag.</p>

<p>Now, let&#8217;s look at the css necessary to make the tooltip magic work.  This is the <strong>barebones</strong> version &#8211; we&#8217;ll style it a bit later.</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.info</span> span <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.info</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.info</span><span style="color: #3333ff;">:hover </span>span <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>




<p>This sets up what we discussed before.  The tooltip <code>&lt;span&gt;</code> is initially invisible.  Since it&#8217;s inside the anchor tag, we can use the <code>a.info:hover span</code> declaration to style the <code>&lt;span&gt;</code> differently when the anchor is hovered over &#8211; and then we make the <code>&lt;span&gt;</code> appear.</p>

<p>Voila!  Tooltip.</p>

<p>Mouse over <a class="basic-info">this text<span>This is the barebones tooltip.</span></a> to see what we&#8217;ve built so far.</p>

<p>At this point, you&#8217;ll probably see a blur of text appearing on top of some other text.  Not very readable&#8230; but that&#8217;s because we haven&#8217;t styled it yet.</p>

<p>Mouse over <a class="tooltip">this text<span>Now this has a bit of styling.</span></a> to see a slightly styled tooltip.</p>

<p>We added a few things here &#8211; I styled the basic a.info so that it had a different color and no text-decoration.  Then I styled the span with a bunch of stuff &#8211; background color, border, text color, width, and padding.</p>

<p>I also used <code>position:top</code> to offset it 1.5em from the top-left of our anchor, and <code>position:left</code> to offset it 1.5em from the top-left of our anchor.</p>

<p>Here&#8217;s the new css&#8230;</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.tooltip</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.info</span> span <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.info</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
a<span style="color: #6666ff;">.info</span><span style="color: #3333ff;">:hover </span>span <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eeeeee</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">thin</span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12em</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.5em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>




<p>And that&#8217;s about all there is to it.  With the html and css you built in this tutorial, you&#8217;ve got the mechanics needed to build your own tooltip.</p>

<p>It&#8217;s up to you to style it according to your site&#8217;s theme and make it pretty.  You could add a gradient background, style the font for some extra spacing and/or size, set the width to the way you want, and more.</p>]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/19/create-css-tooltips/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

