<?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; anchor</title>
	<atom:link href="http://www.earn-web-cash.com/tag/anchor/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>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>Five Non-Traditional Ways to Use Tooltips</title>
		<link>http://www.earn-web-cash.com/2008/01/20/five-ways-tooltips/</link>
		<comments>http://www.earn-web-cash.com/2008/01/20/five-ways-tooltips/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 12:01:53 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Sundry Musings]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[tooltip]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/01/20/five-ways-tooltips/</guid>
		<description><![CDATA[In standard HTML, tooltips seem to be reserved for anchor tags &#8211; i.e. links. They get the all-powerful &#8220;title&#8221; attribute which is turned into a tooltip. There are plenty of other times that you&#8217;d want to use a tooltip, though. If you&#8217;re wondering how, check out this previous post on how to create a custom [...]]]></description>
			<content:encoded><![CDATA[<p>In standard HTML, tooltips seem to be reserved for anchor tags &#8211; i.e. links.  They get the all-powerful &#8220;title&#8221; attribute which is turned into a tooltip.</p>
<p>There are plenty of other times that you&#8217;d want to use a tooltip, though.  If you&#8217;re wondering how, check out this previous post on <a href="http://www.earn-web-cash.com/2008/01/19/create-css-tooltips/">how to create a custom tooltip with css</a>.</p>
<p>Otherwise, read on for some thoughts on <em>when</em> to use these tooltips.<br />
<span id="more-47"></span></p>
<h5>5. Definitions of Words</h5>
<p>One interesting way to use custom tooltips is to show the definition of a word.  This would be great for educational sites that aim to teach their users about a given subject.  Rather than link to a new page with information on a word, just include a brief explanation in a tooltip.</p>
<p>Likewise, this could be used on coding tutorial sites to pop-up information on built-in functions and such.  Hmm&#8230; do I smell a useful WordPress plug-in?</p>
<h5>4. Movie/Book/Television Spoilers</h5>
<p>Do you write about movies, books, or tv shows?  Well, I don&#8217;t.  But if you did&#8230; you might want to share spoilers and other information with your users.</p>
<p>The problem is that not all users <em>want</em> to have the ending spoiled for them.  I saw a similar thing used in a forum &#8211; all spoilers had to be wrapped in a bb-code tag that made them invisible until you moused-over them.</p>
<p>This way users can choose whether or not to learn the ending of the story.  If you leave it out on the screen, they might read it by accident and blame you for ruining the whole thing.</p>
<h5>3. Citations and Source Quotes</h5>
<p>Do you find yourself quoting other sources often?  Maybe your blog is a bit on the literary or academic side?</p>
<p>You could use these tooltips to contain footnoting and citation information.  Rather than clicking a link to go to the bottom of the screen (i.e. Wikipedia style), have the information pop-up on a tooltip.</p>
<p>I know that when I&#8217;m reading a book I&#8217;m far more likely to pay attention to footnotes that are on the same page than footnotes at the end of the chapter or book.  Convenience is key.</p>
<h5>2.  Puzzle or Logic Game Tips</h5>
<p>Do you have some kind of puzzle, quiz, or game on your website?  People love a challenge&#8230; but they hate a game that&#8217;s too hard.</p>
<p>The solution, of course, is to offer the user hints.  These can&#8217;t be readily visible, though, or it&#8217;ll spoil the game.</p>
<p>With the tooltip, the user can easily mouse-over some text that says &#8220;First Tip,&#8221; to get a little hint without opening up a new window.  Convenient indeed.</p>
<h5>1.  Instructions and Information for Forms</h5>
<p>I&#8217;m not a big fan of extra text hanging out on a form telling a user what to do.  It seems to get in the way and detract from the look of the form.</p>
<p>Instead, use a tooltip over the label (or add a &#8220;?&#8221; for the tooltip) to tell the user what to enter in a field.  That way you can include lots of information &#8211; so much that you might find it to be over-simplifying &#8211; and the user won&#8217;t have to read this &#8220;help&#8221; unless they actually need it.</p>
<p>You help the confused users without turning off the savvy ones.</p>
<h5>What Else?</h5>
<p>I&#8217;m sure there are dozens of other ways to use custom tooltips.  Got some ideas?</p>
<p>Then leave a comment.  I&#8217;d love to hear how you&#8217;d use them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/01/20/five-ways-tooltips/feed/</wfw:commentRss>
		<slash:comments>2</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>

