<?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>K-Squared Ramblings &#187; w3c</title>
	<atom:link href="http://www.hyperborea.org/journal/tag/w3c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hyperborea.org/journal</link>
	<description>Sci-fi, comics, humor, photos...it&#039;s all fair game.</description>
	<lastBuildDate>Sat, 21 Nov 2009 07:49:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='www.hyperborea.org' port='80' path='/journal/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Creating CSS Buttons</title>
		<link>http://www.hyperborea.org/journal/archives/2004/06/25/creating-css-buttons/</link>
		<comments>http://www.hyperborea.org/journal/archives/2004/06/25/creating-css-buttons/#comments</comments>
		<pubDate>Sat, 26 Jun 2004 00:15:23 +0000</pubDate>
		<dc:creator>Kelson</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[w3c]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.hyperborea.org/journal/archives/2004/06/25/creating-css-buttons/</guid>
		<description><![CDATA[Several months ago, I went on a minor site optimizing kick. One thing I decided to do was replace the validation labels with something smaller, less obtrusive, and directly on the page.  I tried to duplicate the look of the classic antipixel-style buttons (like the ones you see on the sidebar here) by splitting [...]]]></description>
			<content:encoded><![CDATA[<p>Several months ago, I went on a minor site optimizing kick. One thing I decided to do was replace the validation labels with something smaller, less obtrusive, and directly on the page.  I tried to duplicate the look of the classic <a href="http://gtmcknight.com/buttons/">antipixel-style buttons</a> (like the ones you see on the sidebar here) by splitting a link into two &lt;span&gt; elements, but had so much trouble getting borders and height to match up correctly that I wrote it off completely.</p>
<p>After a while I came back to it, and started with very simple buttons like this:</p>
<p><img src="http://www.hyperborea.org/journal/images/cssbuttons-round1.gif" alt="How the first CSS badges should look" /></p>
<p>Your browser shows this as:</p>
<p><a href="#" style="font: 9pt Arial, Helvetica, sans-serif; border: 1px #000 solid; color: #000; background: #fc6; padding: 2pt; text-decoration: none;">Valid XHTML</a> <a href="#" style="font: 9pt Arial, Helvetica, sans-serif; border: 1px #000 solid; color: #000; background: #adb; padding: 2pt; text-decoration: none;">XFN Friendly</a></p>
<p>Here&#8217;s the CSS and HTML used for this version: <span id="more-390"></span></p>
<p><code>a.w3c, a.nw3 {font: 9pt Arial, Helvetica, sans-serif; border: 1px #000 solid; padding: 2pt; text-decoration: none;}</code><br />
<code>a.w3c:link, a.w3c:visited {color: #000; background: #fc6;}</code><br />
<code>a.w3c:hover, a.w3c:active {background: #fec;}</code><br />
<code>a.nw3:link, a.nw3:visited {color: #000; background: #adb;}</code><br />
<code>a.nw3:hover, a.nw3:active {background: #cfe;}</code></p>
<p><code>&lt;a class="w3c" href="#"&gt;Valid XHTML&lt;/a&gt; &lt;a class="nw3" href="#"&gt;XFN Friendly&lt;/a&gt;</code></p>
<p>Of course, Netscape 4 had problems with this, because it dislikes putting borders or padding on inline elements &#8212; like links. Not only does it push them onto separate lines, but they&#8217;re no longer clickable!  What I ended up doing was separating out the border and padding rules and putting them in an <code>@media screen</code> section to hide them.  So on Netscape 4 it looked like this:</p>
<p><img src="http://www.hyperborea.org/journal/images/cssbuttons-round1-ns4workaround.gif" alt="[Badges in Netscape 4 with border removed]" /></p>
<p>Earlier this month, I found <a href="http://meyerweb.com/eric/css/examples/plat-buttons.html">Eric Meyer&#8217;s take</a> on the same problem: using CSS to imitate those buttons so that visitors don&#8217;t have to download an extra 15 images just for footnotes. He was trying for as exact a match as possible, and the result looks great &#8211; in Mozilla, Opera, Safari or Konqueror.  But the margins aren&#8217;t quite right in IE, and unlike Eric, my site isn&#8217;t a showcase of what CSS can do.</p>
<p>I ended up using his idea of putting a single &lt;span&gt; tag inside the link &#8212; that&#8217;s all you really need to divide it into two regions &#8212; and using two classes to simplify using the same styles for different types of buttons.  Since I&#8217;d already abandoned the idea of an <em>exact</em> match, I didn&#8217;t worry about getting the fonts and spacing exactly right, and since I was using these in a horizontal row, I didn&#8217;t have to worry about specifying widths.   It looked pretty good, at least on <abbr title="Mozilla, Opera, and Safari">MOS</abbr>:</p>
<p><img src="http://www.hyperborea.org/journal/images/cssbuttons-round2.gif" alt="[Round 2 of badges, incorporating ideas from Meyerweb]" /></p>
<p>I still had problems in Internet Explorer, though.  It adds the padding together, even though it shouldn&#8217;t mess with the line height on an inline element, so it ended up with an extra line of background color around the left section:</p>
<p><img src="http://www.hyperborea.org/journal/images/cssbuttons-round2-iebug.gif" alt="[Badges with ugly marginsdue to IE bug]" /></p>
<p>Since I wasn&#8217;t trying to match exactly, I decided to just remove all the vertical padding, leaving something much narrower than the originals, but much cleaner than what I could get otherwise:</p>
<p><img src="http://www.hyperborea.org/journal/images/cssbuttons-round2-final.gif" alt="[Final version of CSS Badges]" /></p>
<p>Your browser shows:<br />
<a href="#" style="font: 8pt Arial, Helvetica, sans-serif; color: #000; background: #fc6; padding: 0 .5em 0 0; border: 1px #000 solid; text-decoration: none;"><span style="background: #fff; color: #06c; border-right: 1px solid #000; margin: 0 0.1em 0 0; padding: 0 0.5em;">W3C</span> Valid XHTML</a> <a href="#" style="font: 8pt Arial, Helvetica, sans-serif; color: #000; background: #ccc; padding: 0 .5em 0 0; border: 1px #000 solid; text-decoration: none;"><span style="background: #093; color: #fff; border-right: 1px solid #000; margin: 0 0.1em 0 0; padding: 0 0.5em;">XFN</span> Friendly</a></p>
<p><code>&lt;a class="btn w3c" href="#"&gt;&lt;span&gt;W3C&lt;/span&gt; Valid XHTML&lt;/a&gt; &lt;a class="btn fea" href="#"&gt;&lt;span&gt;XFN&lt;/span&gt; Friendly&lt;/a&gt;</code></p>
<p><code>a.btn {font: 8pt Arial, Helvetica, sans-serif; padding: 0 .5em 0 0; border: 1px #000 solid; text-decoration: none;}</code><br />
<code>a.btn span {border-right: 1px solid #000; margin: 0 0.1em 0 0; padding: 0 0.5em;}</code><br />
<code>a.w3c:link, a.w3c:visited {color: #000; background: #fc6;}</code><br />
<code>a.w3c:hover, a.w3c:active {background: #fec;}</code><br />
<code>a.w3c span {background: #fff; color: #06c;}</code><br />
<code>a.fea:link, a.fea:visited {color: #000; background: #ccc;}</code><br />
<code>a.fea:hover, a.fea:active {background: #bed;}</code><br />
<code>a.fea span {background: #093; color: #fff;}</code></p>
<p>This works well in modern versions of IE, Mozilla, Netscape, Opera, Safari and Konqueror.  IE5 gets the colors right, but doesn&#8217;t show the borders.  Netscape 4, interestingly, doesn&#8217;t recognize multiple classes.  It thinks &#8220;btn w3c&#8221; is a single class with a space in the middle, so its freak-out over borders and padding is no longer a problem.  It just ends up looking like a normal text link. It&#8217;s not great, but at least it works, and at this point that&#8217;s all I want for NS4.</p>
<p>There&#8217;s one more problem, and that&#8217;s one of accessibility.  The WAI and Section 508 guidelines both suggest you avoid putting links next to each other with no separation, because a screen reader might not make it clear to a blind web surfer that the links are separate.  I haven&#8217;t come to a final decision on this one, but what I&#8217;ve got on some pages is just separating them with ordinary bullets:</p>
<p><a href="#" style="font: 8pt Arial, Helvetica, sans-serif; color: #000; background: #fc6; padding: 0 .5em 0 0; border: 1px #000 solid; text-decoration: none;"><span style="background: #fff; color: #06c; border-right: 1px solid #000; margin: 0 0.1em 0 0; padding: 0 0.5em;">W3C</span> Valid XHTML</a> &#183; <a href="#" style="font: 8pt Arial, Helvetica, sans-serif; color: #000; background: #ccc; padding: 0 .5em 0 0; border: 1px #000 solid; text-decoration: none;"><span style="background: #093; color: #fff; border-right: 1px solid #000; margin: 0 0.1em 0 0; padding: 0 0.5em;">XFN</span> Friendly</a></p>
<hr /><small>Copyright &copy; 2009 Kelson Vibber and/or Katherine Foreman.<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. Permission granted to Planet Antispam and LiveJournal syndication feed ksquaredramblin.  If this content is not in your news reader or one of the sites listed above, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint: bc1c453a98ff79bab5c4fca2d890469d (38.107.191.90) )</small> <a href="http://www.hudson-family.co.uk/extremecorticate.php?source=673"></a>]]></content:encoded>
			<wfw:commentRss>http://www.hyperborea.org/journal/archives/2004/06/25/creating-css-buttons/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
