<?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>Kilian Valkhof &#187; CSS &amp; (X)HTML</title>
	<atom:link href="http://kilianvalkhof.com/category/css-xhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://kilianvalkhof.com</link>
	<description></description>
	<lastBuildDate>Thu, 10 Nov 2011 12:42:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Book review: How pleasure works</title>
		<link>http://kilianvalkhof.com/2010/css-xhtml/book-review-how-pleasure-works/</link>
		<comments>http://kilianvalkhof.com/2010/css-xhtml/book-review-how-pleasure-works/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 08:00:09 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=785</guid>
		<description><![CDATA[<blockquote><p>Bloom argues that all people are essentialist. They perceive humans, animals and objects to have an innate essence. </p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/book-review-how-pleasure-works/">Book review: How pleasure works</a></p>
]]></description>
			<content:encoded><![CDATA[<p>A while ago, <a href="http://twitter.com/taphangum">Tapha</a> e-mailed me asking if I wanted to write a <em>blurb</em> for <a href="http://blurb.fm/">Blurb.fm</a>. I took him up on the challenge, and wrote a review of &#8220;How pleasure works&#8221;, by Paul Bloom, a book I just finished. I am re-publishing it here on my blog.<span id="more-785"></span></p>
<p>As a sidenote, you should really sign up for <a href="http://blurb.fm/">Blurb.fm</a>. I don&#8217;t read enough books. I really want to, but I just don&#8217;t make the time. Blurb.fm is a great way to still get the general gist of interesting non-fiction books, ranging from inspirational biographies to neuro-pop-science books such as &#8220;how we decide&#8221; (Jonah Lehrer, highly recommended!). No, I&#8217;m not getting paid to say this ;) (though feel free to Flattr if you like this). Now without further ado, the review:</p>
<h2>How pleasure works</h2>
<p>“How pleasure works” is a book about religion, cannibalism, fake vomit, virgins, family guy and pornography for monkeys. Not things you would immediately associate with pleasure. And yet the author, Paul Bloom, manages to weave these topics and accompanying stories into an intricate pattern of, indeed, how pleasure works.</p>
<p> Humans are unique in the way they feel pleasure. What other species has teenagers that enjoy cutting themselves with razors, adults that enjoy spending evening after evening in front of the television more than socially interacting with others, or individuals that would pay tens of thousands of dollars for a tape deck used by J.F. Kennedy? Humans, when it comes to pleasure, are pretty unique.</p>
<p>Paul Bloom is a professor of Psychology and cognitive science at Yale university. He researches how children and adults understand the world, language, fiction and art. This research is often used as starting points for different parts of “How Pleasure Works”.</p>
<h3>Essentialists</h3>
<p>Bloom argues that all people are essentialist. They perceive humans, animals and objects to have an innate essence. Or as Bloom himself says, the idea that things &#8220;have an underlying reality or true nature&#8221;, and that it is this true nature that really matters. To support this notion, Bloom describes research he did with very young children. The kids were first shown a picture of a tiger, and then a picture of the same tiger, made to look like a lion. They were told that this happened (the tiger now looked like a lion) and were subsequently asked if the tiger was still a tiger, or if it had become a lion. Of course, the children insisted that once a tiger, always a tiger. But while this feels logical to us, it means there is something more to the tiger than it&#8217;s mere outside. There is something inside the tiger that makes it, inherently, a tiger. Why do humans do this?</p>
<p>As it turns out, this essentialism helped our ancestors make sense of the world. It helped them categorize the world into friend and foe, deadly and edible. Our illogical sources of pleasure, Bloom argues, are side effects of this essentialism. Side effects, because pleasures didn&#8217;t evolve as a biological adaption to the world. Quite often, you would make better decisions if pleasure wasn&#8217;t involved. However, pleasures evolved in us as a byproduct of other, actually useful traits.</p>
<p>Take for example pornography. No biologist could argue with a straight face that pornography is useful for the proliferation of our species. In fact it might very well be detrimental, because without it we would undoubtedly spent more time with lovers of flesh and blood. However, the pleasure we derive from watching pornography comes from another source: the urge to look at &#8220;attractive naked people&#8221;, causing us to want sex.</p>
<h3>What does it mean to be &#8220;adaptive&#8221;?</h3>
<p>It is this realization that returns and returns in &#8216;How pleasure works&#8217;. Why do we enjoy books, movies, gaming art or even daydreaming so much? Bloom says, &#8220;Surely we would be better off pursuing more adaptive activities&#8221;. It&#8217;s just that, retreating into imagined worlds, the pleasure is almost as real as the real thing. &#8220;Reality Lite&#8221;, as Bloom calls it. Our ability to imagine things, and think of them as having essences, both adaptive advantages, make perceiving pleasure above and beyond merely pleasure derived from sensory stimulating activities possible.</p>
<p>Art is a prime example of the way this works. Art can be visually stimulating. It can be pretty. But much of the pleasure we get from art is &#8220;rooted in an appreciation of the human history underlying it&#8217;s creation&#8221;. In other words, it&#8217;s essence. The books opens with an anecdote about Van Meegeren being arrested for selling a Vermeer (A historical treasure!) to the Nazi leader Herman Goering. After six weeks in prison, Van Meegeren confessed. Not to selling a Vermeer, but to making and selling a fake. Upon hearing this, Goebing looked &#8220;as if for the first time he had discovered there was evil in the world&#8221;. This is remarkable, because for all intents and purposes, a Van Meegeren couldn&#8217;t be distinguished from a Vermeer (To prove his claim, Van Meegeren had to paint another &#8220;Vermeer&#8221;, only then was he believed).</p>
<p>It is thus the way “How pleasure works” is written. Reading this book won&#8217;t tell you how to be happier, how to get pleasure from your work or how to spend your time more usefully than watching television at night. But it will tell you how pleasure works.</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/book-review-how-pleasure-works/">Book review: How pleasure works</a></p>
 <p><a href="http://kilianvalkhof.com/?flattrss_redirect&amp;id=785&amp;md5=380d1d5104f6b4602860bae721b5fcf0" title="Flattr" target="_blank"><img src="http://kilianvalkhof.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2010/css-xhtml/book-review-how-pleasure-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use RGBA() in IE</title>
		<link>http://kilianvalkhof.com/2010/css-xhtml/how-to-use-rgba-in-ie/</link>
		<comments>http://kilianvalkhof.com/2010/css-xhtml/how-to-use-rgba-in-ie/#comments</comments>
		<pubDate>Mon, 31 May 2010 03:00:48 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=672</guid>
		<description><![CDATA[<blockquote><p>While it's <em>not mentioned anywhere</em> in the msdn article, the gradient filter has an #ARGB syntax.</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/how-to-use-rgba-in-ie/">How to use RGBA() in IE</a></p>
]]></description>
			<content:encoded><![CDATA[<p>The modern browsers all have <a href="http://kilianvalkhof.com/2007/css-xhtml/understanding-css-colour-modes/"><code>rgba()</code></a>, giving you a semi-transparent background colour while keeping the foreground elements (text, images) fully opaque. But if you want to use that in your design, what about IE? Here&#8217;s how to do it.<span id="more-672"></span></p>
<p>A while ago I made <a href="http://talenttime.nl">a design</a> with lot&#8217;s of semi transparent areas (I know, stupid me, it&#8217;s only 2010 after all) and solved that in modern browsers with <code>rgba()</code>. All fine and well, I threw in some border-radius and box-shadow, and from Opera through Firefox to Webkit, it looked increasingly better. Great, I&#8217;m all for progressive enhancement. Except it of course looked really bad in IE. I set out to find an acceptable solution.</p>
<h2>Gradients, where?</h2>
<p>For general opacity, we have <a href="http://msdn.microsoft.com/en-us/library/ms532967(v=VS.85).aspx">the alpha filter</a>. but that sets the opacity of foreground elements as well, making it useless in this case. Looking a bit further, I found the gradient filter. Seeing as how I needed transparency and not gradients, this didn&#8217;t seem very useful.</p>
<p><em>But</em> <a href="http://msdn.microsoft.com/en-us/library/ms532997(VS.85).aspx">the gradient filter</a> supports some fun stuff. While it&#8217;s <em>not mentioned anywhere</em> in the msdn article, the gradient filter has an #ARGB syntax. That&#8217;s right, the A is for Alpha. No, I don&#8217;t know why it&#8217;s at the front.</p>
<p>Anyway, Gradients don&#8217;t <em>have</em> to be between two different colours, right? You can just as easily go from white&#8230;to white. So that&#8217;s what I did:</p>
<pre><code>filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26ffffff,endColorstr=#26ffffff);</code></pre>
<p>And there you go, alpha-transparent backgrounds!</p>
<h3>Gotcha&#8217;s</h3>
<p>Of course, it&#8217;s not that easy. <code>rgba()</code> notation is in values from 0 to 255, with the <code>a</code> being a floating point between 0 and 1, and #ARGB is in hexadecimal format. You need to convert <code>rgba()</code> to #ARGB to make it useful. </p>
<p>I&#8217;ve saved you the math, here&#8217;s an easy (to and from) converter:</p>
<h3>Convert to and from rgba() and #ARGB</h3>
<style>
#converter {
-moz-border-radius:0.5em;
-webkit-border-radius:0.5em;
border-radius:0.5em;
background:#EEEEE1;
padding:1.5em;
width:auto;
}
#converter label {
width:50px;
float:left;
margin-bottom:0;
margin-top:0;
font-weight:bold;
}
#converter input {
width:25%;
float:left;
margin-top:0;
margin-right:6.5em;
margin-bottom:0;
}
</style>
<form id="converter" class="horizontalForm">
<fieldset>
  <label for="rgba">rgba()</label><br />
<input id="rgba" name="rgba" value="rgba(255,255,255,1)">
  <label for="argb">#ARGB</label><br />
<input id="argb" name="argb" value="#FFFFFFFF">
  </fieldset>
</form>
<p><script>
(function ($) {
  $(function () {
    $("#converter").submit(function(){return false;});
    $("#rgba").bind('keyup change', function () {
      var value = $(this).val();
      setArgb(value);
    });
    $("#argb").bind('keyup change', function () {
      var value = $(this).val();
      setHex(value);
    });
    setArgb = function(val) {
      var valArr = val.split("(")[1].split(")")[0].split(","),
          red = toHex(valArr[0]),
          green = toHex(valArr[1]),
          blue = toHex(valArr[2]),
          alpha = toHex(valArr[3]*255);
      $("#argb").val("#" + alpha + red + green + blue);
    };
    setHex = function(val) {
      var value = val.substring(1,9),
          red = parseInt(value.substring(2,4), 16),
          green = parseInt(value.substring(4,6), 16),
          blue = parseInt(value.substring(6,8), 16),
          alpha = Math.round((parseInt(value.substring(0,2), 16)/255)*10)/10;
      $("#rgba").val("rgba(" + red + "," + green + "," + blue + "," + alpha +")");
    };
    toHex = function(val) {
      val = parseInt(val);
      val = Math.max(0,val);
      val = Math.min(val,255);
      val = Math.round(val);
      return "0123456789ABCDEF".charAt((val-val%16)/16) + "0123456789ABCDEF".charAt(val%16);
    };
  })
}(jQuery));
</script></p>
<h3>More gotcha&#8217;s (<em>or: Oh, IE!</em>)</h3>
<p>Of course, just finding the correct value for #ARGB isn&#8217;t the <em>only</em> problem you will have. There are more downsides. For one, the code above isn&#8217;t actually the one you have to write. The code below is:</p>
<pre><code>background:none;
-ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26ffffff,endColorstr=#26ffffff);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26ffffff,endColorstr=#26ffffff);
zoom: 1;</code></pre>
<p>Firstly, you have to set the actual background to none, then you have to use -ms-filter for IE8, filter for everything below, and set zoom:1; to make sure the element has <code>hasLayout</code> (or else the filter doesn&#8217;t work.)</p>
<p>Apart from the code, there are two other downsides: When you use filters, <a href="http://blogs.msdn.com/b/ie/archive/2006/08/31/730887.aspx">ClearType gets disabled</a>. That&#8217;s a pretty big downside, since non-cleartyped text looks hideous. According to some you can <a href="http://cookbooks.adobe.com/post_IE8_clearType_fix_when_using_filters-16676.html">fix it</a>, but YMMV.</p>
<p>Secondly, as soon as you place the website in an iframe, say goodbye to the A in your gradient. the backgrounds will lose there transparancy and look hideous. I learned that the hard way. if you use the gradient filter, don&#8217;t display your site in an iframe. </p>
<h3>Should you use it?</h3>
<p>Using stuff like this, it&#8217;s a bit like we&#8217;re dragging IE along, kicking and screaming. And that&#8217;s what we do. We want to move forward, so we find ways to get around the limitations of lesser browsers. Whether losing ClearType is worth it depends wholly on the design. In my case it did, in your case, it might not.</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/how-to-use-rgba-in-ie/">How to use RGBA() in IE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2010/css-xhtml/how-to-use-rgba-in-ie/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>CSS Vendor prefixes considered important</title>
		<link>http://kilianvalkhof.com/2010/css-xhtml/css-vendor-prefixes-considered-important/</link>
		<comments>http://kilianvalkhof.com/2010/css-xhtml/css-vendor-prefixes-considered-important/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:26:07 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=633</guid>
		<description><![CDATA[<blockquote><p>Sure, typing -moz-, -webkit, -o- again and again gets annoying, but come on, <em>you're a developer</em></p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/css-vendor-prefixes-considered-important/">CSS Vendor prefixes considered important</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Lately, there has been a lot of hate towards vendor prefixes. First, PPK <a href="http://www.quirksmode.org/blog/archives/2010/03/css_vendor_pref.html">wrote about them</a>, and then a <a href="http://ajaxian.com/archives/should-css-vendor-prefixes-be-nuked-or-just-tweaked">some</a> <a href="http://www.vcarrer.com/2010/05/css-vendor-prefixes-can-we-all-get.html">other</a> people did. The proposed solution to the &#8216;problem&#8217; of vendor prefixes is to get rid of them in favor of one <code>-beta-</code> prefix. Simply put: That won&#8217;t work.<span id="more-633"></span></p>
<h3>Why they exist</h3>
<p>You see, vendor prefixes exist for one important reason. Vendor prefixes are used for <strong>unfinished specifications</strong>. Unfinished specifications change. They evolve. Sometimes they don&#8217;t describe the implementation at all, or the syntax has yet to be agreed upon. They are not done yet. <strong>They are <em>unfinished</em></strong>. </p>
<p>This means browsers could, and will implement things differently. To give a concrete example: Gecko and Webkit implemented the <code>border-radius</code> syntax differently. Had there been only one &#8220;<code>-beta-</code>&#8221; prefix, you could not have used border-radius in a cross browser way. That doesn&#8217;t seem like a real solution, does it? </p>
<h3><i class="lquo">&#8220;</i>But I have to type so much!<i class="rquo">&#8221;</i></h3>
<p>Sure, typing -moz-, -webkit, -o- again and again gets annoying, but come on, <em>you&#8217;re a developer</em>. It&#8217;s trivial to make a snippet (or whatever your editor calls them) for this, or to use a <a href="http://sass-lang.com/">Sass</a> or <a href="http://lesscss.org/">LESS</a> mixin. <strong><a href="http://gist.github.com/144406">Tools will save us</a></strong>. </p>
<h3>Vendor prefixes are awesome</h3>
<p>Vendor prefixes allow us to test out new technologies, they allow different browsers to implement them in the way they seem most conforming to the specification (at that moment). This in turn allows developers to deal with browser differences by setting different values for each vendor prefix. </p>
<p>Browsers get to test out different implementations, and developers get early access to new possibilities. That seems like an excellent deal to me.</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/css-vendor-prefixes-considered-important/">CSS Vendor prefixes considered important</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2010/css-xhtml/css-vendor-prefixes-considered-important/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CSS3 loading spinners without images</title>
		<link>http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/</link>
		<comments>http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 04:00:53 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=575</guid>
		<description><![CDATA[<blockquote><p>After playing around with chaining different transforms, I found out something interesting&#8230;</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/">CSS3 loading spinners without images</a></p>
]]></description>
			<content:encoded><![CDATA[<p>While playing around with css-transform to make various shapes, I saw a way to create animated image-less loading spinners such as used in a lot of webapps and of course on the iPhone.<span id="more-575"></span></p>
<h3>CSS transforms</h3>
<p>CSS transform (in Firefox 3.5+ and Webkit-based browsers) has a whole bunch of interesting functions, such as rotation, translation, scaling and skewing. To learn more about the different functions, check out the Mozilla developer center overview of <a href="https://developer.mozilla.org/en/CSS/-moz-transform">CSS transform</a>. After playing around with chaining different transforms and seeing the effect, I found out something interesting:</p>
<div style="width:100px;height:100px;border:1px solid #eee;position:relative;margin-bottom:1.5em">
<div style="position:absolute;height:50px;width:20px;top:25px;left:40px;background:#ddd;"></div>
<div style="position:absolute;height:50px;width:20px;top:25px;left:40px;background:#000;-moz-transform:rotate(45deg) translate(0, -35px);-webkit-transform:rotate(45deg) translate(0, -35px)"></div>
</div>
<pre><code>transform:rotate(45deg) translate(0, -35px);</code></pre>
<p>If you rotate first, and then translate (move), it will move <em>along the rotated axis</em>. The above code translates a block to the top-right corner (45 degrees). (the gray div is not transformed while the black one is.)</p>
<p>Using this, I could rotate and translate a bunch of divs to create loading spinners (though this one doesn&#8217;t spin yet!):</p>
<div id="div1">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<p>In this example, each div is rotated an additional 45 degrees. The first one is not rotated, the second one is rotated 45 degrees, the one after that 90 degrees, and so forth. Additionally, each div has increased opacity to make it look like most loading spinners.</p>
<h3>Animation</h3>
<p>Webkit supports CSS animations, but these are continuous while most loading spinners are not. On the left side is a spinner animated with CSS animation (only works in Safari and Chrome), on the right there&#8217;s one animated with a small bit of JavaScript to look like regular loading spinners:</p>
<div id="div2">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<div id="div3">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<p style="clear:both">The code for the CSS animation is fairly straightforward:</p>
<pre><code>#div2 {
  -webkit-animation-name: rotateThis;
  -webkit-animation-duration:2s;
  -webkit-animation-iteration-count:infinite;
  -webkit-animation-timing-function:linear;
}
@-webkit-keyframes rotateThis {
  from {-webkit-transform:scale(0.5) rotate(0deg);}
  to {-webkit-transform:scale(0.5) rotate(360deg);}
} </code></pre>
<p>While the (quick and dirty) code for the JavaScript animation is pretty easy as well:</p>
<pre><code>  var count = 0;
  function rotate() {
    var elem2 = document.getElementById('div3');
    elem2.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
    elem2.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
    if (count==360) { count = 0 }
    count+=45;
    window.setTimeout(rotate, 100);
  }
  window.setTimeout(rotate, 100);</code></pre>
<p>Someone else might be able to duplicate the loading spinner-style rotation with CSS animations (please let me know!), but the JavaScript solution looks better and works in Firefox too.</p>
<h3>Going crazy with it (More examples!)</h2>
<p>Once I had the basic &#8216;functionality&#8217; working, I just decided to go crazy with it and create a whole bunch of different style loading spinners. You can find them on this page: <strong><a href="/uploads/spinners/">CSS3 loading spinner examples</a></strong>. </p>
<p>Check out the source for the way to style the different spinners and let me know when you make interesting variations!</p>
<style>
/* position the bars and balls correctly (rotate them and translate them outward)*/
.bar1 {
  -moz-transform:rotate(0deg) translate(0, -40px);
  -webkit-transform:rotate(0deg) translate(0, -40px);opacity:0.12;
}
.bar2 {
  -moz-transform:rotate(45deg) translate(0, -40px);
  -webkit-transform:rotate(45deg) translate(0, -40px);opacity:0.25;
}
.bar3 {
  -moz-transform:rotate(90deg) translate(0, -40px);
  -webkit-transform:rotate(90deg) translate(0, -40px);opacity:0.37;
}
.bar4 {
  -moz-transform:rotate(135deg) translate(0, -40px);
  -webkit-transform:rotate(135deg) translate(0, -40px);opacity:0.50;
}
.bar5 {
  -moz-transform:rotate(180deg) translate(0, -40px);
  -webkit-transform:rotate(180deg) translate(0, -40px);opacity:0.62;
}
.bar6 {
  -moz-transform:rotate(225deg) translate(0, -40px);
  -webkit-transform:rotate(225deg) translate(0, -40px);opacity:0.75;
}
.bar7 {
  -moz-transform:rotate(270deg) translate(0, -40px);
  -webkit-transform:rotate(270deg) translate(0, -40px);opacity:0.87;
}
.bar8 {
  -moz-transform:rotate(315deg) translate(0, -40px);
  -webkit-transform:rotate(315deg) translate(0, -40px);opacity:1;
}
#div1, #div2, #div3 {
  position:relative;
  width:100px;
  height:100px;
  margin-bottom:1.5em;
  margin-right:1.5em;
  -moz-border-radius:100px;
  float:left;
  -moz-transform:scale(0.5);
  -webkit-transform:scale(0.5);
}
#div1 {float:none}
#div1 div,
#div2 div,
#div3 div {
  width:10px;
  height:30px;
  background:#000;
  position:absolute;
  top:35px;
  left:45px;
}
#div2 {
  -webkit-animation-name: rotateThis;
  -webkit-animation-duration:2s;
  -webkit-animation-iteration-count:infinite;
  -webkit-animation-timing-function:linear;
}
@-webkit-keyframes rotateThis {
  from {-webkit-transform:scale(0.5) rotate(0deg);}
  to {-webkit-transform:scale(0.5) rotate(360deg);}
} 
</style>
<p><script>
  var count = 0;
  function rotate() {
    var elem2 = document.getElementById('div3');
    elem2.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
    elem2.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
    if (count==360) { count = 0 }
    count+=45;
    window.setTimeout(rotate, 100);
  }
  window.setTimeout(rotate, 100);
</script></p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/">CSS3 loading spinners without images</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>Slides of my Fronteers talk</title>
		<link>http://kilianvalkhof.com/2009/css-xhtml/slides-of-my-fronteers-talk/</link>
		<comments>http://kilianvalkhof.com/2009/css-xhtml/slides-of-my-fronteers-talk/#comments</comments>
		<pubDate>Mon, 11 May 2009 05:00:22 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=404</guid>
		<description><![CDATA[<blockquote><p>The presentation is a general overview of the current CSS frameworks, both client side and server side</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2009/css-xhtml/slides-of-my-fronteers-talk/">Slides of my Fronteers talk</a></p>
]]></description>
			<content:encoded><![CDATA[<p>On the 8th of may I gave a presentation on CSS frameworks at a <a href="http://fronteers.nl" lang="nl">Fronteers</a> meeting at Mirabeau in Eindhoven. I made the slides in <a href="http://prezi.com">Prezi</a> as an experiment, which proved to be a very interesting way of presenting.<span id="more-404"></span></p>
<h3>The presentation</h3>
<p><iframe src="http://prezi.com/52514/view" style="height:365px;width:560px;border:none;"></iframe><br />
<em>Or watch it here, if full screen is more of your thing: <a href="http://tinyurl.com/fronteerscss">CSS frameworks by Kilian Valkhof</a>. It&#8217;s in Dutch.</em></p>
<p>The presentation is a general overview of the current CSS frameworks, both client side and server side. It gives a rundown of the way they work, what their (dis)advantages are and which <a href="http://sencss.kilianvalkhof.com">one you should use</a>. Just kidding ;) </p>
<p>I managed to keep SenCSs out of the presentation, for its larger part. The most fun discovery was that very little people knew about the server-side options like sass and cssscaffold. They provide a powerful way to manage your CSS and allow you to write smarter css, faster. It&#8217;s where the cool stuff will be happening :)</p>
<p>Prezi was interesting to work with, even though <a href="http://getsatisfaction.com/zuilabs/topics/oops_trouble_with_your_prezi">their sloppy coding</a> prohibited me from making my presentation on my normal pc, a 64bit Ubuntu installation. It worked nicely in a 32bit VM though. Prezi, if you want a horde of smart, creative early adopters to use your product, pay me and I&#8217;ll fix your code ;) </p>
<h3>The Meeting</h3>
<p>Thanks to Martin for hosting the May meeting, Mirabeau in Eindhoven has an awesome looking office. It was our most southern meeting yet, and there were more people than I expected, so that was all good.</p>
<p>Besides my presentation, <a href="http://arjaneising.nl">Arjan Eising</a> gave a talk about WAI-ARIA. It was very interesting and he had some nice code examples, though I had hoped to hear a little bit more about the juxaposition between it and HTML5. </p>
<p>I also got rid of about 60 more stickers, which have been going like hot buns ever since they got the <a href="http://zeldman.com">Zeldman</a> <a href="http://www.flickr.com/photos/weblogmangrove/3353893961/">seal of approval</a>.</p>
<p>If you want to host a Fronteers meeting in the future, don&#8217;t hesitate to <a href="http://fronteers.nl/bijeenkomsten/organiseren" lang="nl">contact us</a>!</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2009/css-xhtml/slides-of-my-fronteers-talk/">Slides of my Fronteers talk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2009/css-xhtml/slides-of-my-fronteers-talk/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Combining Cufón and @font-face</title>
		<link>http://kilianvalkhof.com/2009/css-xhtml/combining-cufon-and-font-face/</link>
		<comments>http://kilianvalkhof.com/2009/css-xhtml/combining-cufon-and-font-face/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 03:00:31 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=389</guid>
		<description><![CDATA[<blockquote><p>So, with an @font-face declaration in your CSS, and a bit of JavaScript telling you if the font is available, all you have to do is&#8230;</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2009/css-xhtml/combining-cufon-and-font-face/">Combining Cufón and @font-face</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Everyone wants @font-face to work everywhere, but as it stands, it only works in Safari and the upcoming versions of Firefox and Opera. In this article I&#8217;ll show you how to use <a href="http://cufon.shoqolate.com/generate/">Cufón</a> only if we can’t load the font through other, faster methods.<span id="more-389"></span></p>
<p>If you&#8217;re not familiar with Cufón, check out my previous article: <a href="http://kilianvalkhof.com/2009/javascript/cufon-vs-typefacejs-which-one-is-better/">Cufon vs. Typeface.js, which one is better?</a> or this article: <a href="http://www.cameronmoll.com/archives/2009/03/cufon_font_embedding/">Exploring Cufón, a sIFR alternative for font embedding</a> by Cameron Moll.</p>
<h3>Not just @font-face&hellip;</h3>
<p>Now, @font-face isn&#8217;t the only way to display custom fonts. What if the visitor already has the font installed? It&#8217;ll display automatically then, again leaving us with no reason to use load Cufón. These are the three options you have when you want to display custom fonts, in order of speed:</p>
<ul>
<li>The font is already installed on the users computer</li>
<li>The font get&#8217;s downloaded and displayed with the use of @font-face</li>
<li>The font gets replaced by Cufón</li>
</ul>
<p>I will not go into @font-face in this post, for more on web fonts, read these articles: <a href="http://www.alistapart.com/articles/cssatten">CSS at ten</a> and <a href="http://jontangerine.com/log/2008/10/font-face-in-ie-making-web-fonts-work">@font-face in IE: making web fonts work</a> (Which not only explains how to use @font-face in browsers that support it, but also in IE using their proprietary DRM-ed .eot &#8216;standard&#8217;.)</p>
<h3>The trick</h3>
<p>The effect of an installed font and using @font-face are the same: The font is rendered and displayed natively by the browser. This means that you only have to check <em>if the font is available</em>, and can forgo checking if @font-face is at all an option. A very smart solution to do this is the <a href="http://code.google.com/p/jquery-fontavailable/">jQuery fontAvailable</a> plugin. The implementation looks like this:</p>
<pre><code>$(document).ready(function() {
    if($.fontAvailable('Optimer')) {
        // code here
    }
});</pre>
<p></code><br />
The plugin works in a most ingenious way: On document load, it created an element with the alphabet in it, and sets the font-family to a non-existent font to apply the default font. It then replaces the font-family with the font you've specified, and checks if the width has changed. If the width has changed, that means the font was applied and is available.</p>
<p><strong>Update:</strong> <a href="http://dev.enekoalonso.com/">Eneko Alonso</a> ported the plugin to mootools: <a href="http://code.google.com/p/moo-fontavailable/">moo-fontavailable</a>. Cool no?</p>
<p>So, all you have to do to make this work, is make sure that <strong>the font-name you define in your @font-face declaration is the same as the real font name</strong>, and it will automatically work for both already installed fonts, and fonts loaded in with @font-face!</p>
<h3>And then Cufón</h3>
<p>So, with an @font-face declaration in your CSS, and a bit of JavaScript telling you if the font is available, all you have to do is add in @cufón when <code>$.fontAvailable</code> returns false! (Note the added ! in the example code, so Cufón gets executed if the font is <strong>not</strong> available)</p>
<pre><code>$(document).ready(function() {
    if(<strong>!</strong>$.fontAvailable('Optimer')) {
      Cufon.replace('h1');
    }
});</pre>
<p></code></p>
<p>Unfortunately it's not <em>quite</em> that easy. Because IE can show a <abbr title="Flash Of Unstyled Content">FOUC</abbr> with Cufón, you have to add <code>Cufon.now();</code> at the end of the page. If we use Cufón from within <code>$(document).ready();</code>, that would make <code>Cufon.now();</code> ineffective because it would actually be parsed before the document is ready, and thus before the initial <code>Cufon.replace();</code> function.</p>
<p>It will still work, but IE users might see the font getting changed while the page is loaded. Over at the Google group, they are already working on a <a href="http://groups.google.com/group/cufon/browse_thread/thread/a9ee5d7e8984bfba/8b22afa9fb6975de">solution</a> to this, so it shouldn't be long before you won't need <code>Cufon.now();</code> at all anymore.</p>
<h3>That's all there is to it</h3>
<p>All in all, it's quite simple. Check if the font is available, either through already being installed or through @font-face, and if it isn't, we'll let Cufón display it. This offers you the best of both worlds, because browsers that support @font-face will have their native text, and browsers without @font-face support will still get custom fonts. </p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2009/css-xhtml/combining-cufon-and-font-face/">Combining Cufón and @font-face</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2009/css-xhtml/combining-cufon-and-font-face/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Add a little HTML5 to your websites</title>
		<link>http://kilianvalkhof.com/2009/css-xhtml/add-a-little-html5-to-your-websites/</link>
		<comments>http://kilianvalkhof.com/2009/css-xhtml/add-a-little-html5-to-your-websites/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 01:00:53 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=283</guid>
		<description><![CDATA[<blockquote><p>A lot of the HTML5 supported today are actually browser quirks, formalised.</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2009/css-xhtml/add-a-little-html5-to-your-websites/">Add a little HTML5 to your websites</a></p>
]]></description>
			<content:encoded><![CDATA[<p>It will be a while before we can start using <em>real</em> HTML5, but because HTML5 is as much about defining current behaviour as it is about adding new, there is already a very large part available to us today. Here are the parts you can use today.<span id="more-283"></span></p>
<h3>Why?</h3>
<p>HTML5 is arriving sooner rather than later. <a href="http://ishtml5readyyet.com/">The 2022 date</a> means that it&#8217;s fully supported, finished, done. <strong>It doesn&#8217;t mean we can&#8217;t use it</strong>. For example, CSS2.1, from 1998, still isn&#8217;t fully supported, finished, done, either. We all use that as well, right? </p>
<p>A lot of the HTML5 supported today are actually browser quirks, formalised. It&#8217;s usable right now, will get you acquainted with HTML5 and will basically make your front-end life easier :) (And it all works in Internet Explorer too!)</p>
<p><strong>There is much, much more to HTML5 than visible in this article.</strong> This article only focusses on what you can use now. If you want more info on HTML5, check the <a href="http://www.whatwg.org/specs/web-apps/current-work/">specifications</a>, or <a href="http://blog.whatwg.org/">the whatwg blog</a>.</p>
<pre><code>&lt;!doctype html&gt;</code></pre>
<p>The simplified doctype is ierhaps the most iconic idea in HTML5. It turns out, the above code is <a href="http://www.dustindiaz.com/skinny-on-doctypes/">all that&#8217;s needed</a> to trigger standards mode. The <a href="http://validator.nu/">validator</a> understands it as well. Quite a change from the humongous HTML4 or XHTML doctype declarations, no?</p>
<pre><code>&lt;meta charset="utf-8"&gt;</code></pre>
<p>This works the same as the doctype. You don&#8217;t need anything more than this to make your browser set a charset. It turned out that people so often mistype this attribute, (<code>content="text/html; charset=utf-8"</code>), that browser parsers actually encountered <code>charset=utf-8</code> more than the whole <code>content</code> attribute. Since it&#8217;s legal to omit the quotes, charset is being parsed as an attribute in all browsers. And it&#8217;s legal in HTML5.</p>
<pre><code>&lt;script&gt;
 //your javascript
&lt;/script&gt;

&lt;style&gt;
 // your css
&lt;/style&gt;</code></pre>
<p>You no longer have to declare the <code>type</code> attribute with <code>text/javascript</code> or <code>text/css</code>. All browsers already act as if anything inside those tags is javascript or CSS.</p>
<h3>Getting used to new structural elements</h3>
<p>HTML5 introduces a bunch of new elements that allow you to better describe your document:</p>
<ul>
<li>&lt;header&gt;</li>
<li>&lt;footer&gt;</li>
<li>&lt;nav&gt;</li>
<li>&lt;section&gt;</li>
<li>&lt;article&gt;</li>
<li>&lt;aside&gt;</li>
</ul>
<p>These are not all the new elements, but they are the ones that are going to replace the numerous divs used today. While <a href="http://www.brucelawson.co.uk/2009/html-5-elements-test/">you can use them already</a>, I consider it a bit tricky in-production (it&#8217;s dependent on javascript). Instead of using the elements however, it&#8217;s a smart thing to start using these names as classes for the divs you currently use. When the time comes, it&#8217;s easy to just switch over to these elements.</p>
<h3>Soon we&#8217;ll be living in the future!</h3>
<p>When you start using HTML5 like in the examples above, you have the benefit of acquainting yourself with HTML5, still make websites that work today and more importantly, make sure your websites will still work for a long time to come!</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2009/css-xhtml/add-a-little-html5-to-your-websites/">Add a little HTML5 to your websites</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2009/css-xhtml/add-a-little-html5-to-your-websites/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>A useful print stylesheet</title>
		<link>http://kilianvalkhof.com/2008/css-xhtml/a-useful-print-stylesheet/</link>
		<comments>http://kilianvalkhof.com/2008/css-xhtml/a-useful-print-stylesheet/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 09:01:27 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=242</guid>
		<description><![CDATA[<blockquote><p>So, we've known about this since 2002 <em>at least</em>, why do clients still ask for a special print page and a little printer icon for people to click on?</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/css-xhtml/a-useful-print-stylesheet/">A useful print stylesheet</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Print stylesheets are pretty well supported. In this article I&#8217;ll discuss what I think makes a good print stylesheet, and we&#8217;ll take a look at how we can improve public familiarity with them.<span id="more-242"></span></p>
<h3>What makes a good print stylesheet?</h3>
<p>A good print stylesheet, first and foremost, <strong>hides all the unnecessary elements</strong>, such as navigation, search, sidebars and other elements that aren&#8217;t directly important for the page being printed. It removes as much of the colours as possible, so that you&#8217;re not wasting anyone&#8217;s colour ink, and make sure your text is the width of the page (<code>width:auto</code>) so that you&#8217;re not wasting anyone&#8217;s paper. </p>
<p>There&#8217;s one smart trick when making a print-stylesheet. In print, people can&#8217;t click on your links, but they might want to visit them anyway. By using this bit of CSS, you place the actual link in parenthesis behind the linked word:</p>
<pre><code>a::after {
  content: " (" attr(href) ") ";
  font-size: 90%;
}</code></pre>
<p>Where the <code>font-size</code> makes it just slightly smaller than the normal text to distinguish it a bit more.</p>
<p>Two very handy CSS properties are <code>page-break-before</code> and <code>page-break-after</code>. With these elements you can control where your site should &#8220;break&#8221; over into the second page. On this site, I use this CSS:</p>
<pre><code>div.comments {page-break-before:always;}
h2, h3 {page-break-after:avoid;}</code></pre>
<p>Comments are always placed on the second page, so that the article is always on it&#8217;s own as well. One thing I find pretty ugly is when a page ends with a header, and the following paragraph is on the next page. The second bit of code prevents that.</p>
<p>There are two ways you can add a print stylesheet. One is with a seperate stylesheet, and linking to it with <code>&lt;link rel="stylesheet" type="text/css" href="print.css" <strong>media="print"</strong> /&gt;</code>. The other one, which I use on my own site, is an @media print code block at the bottom of my CSS file:</p>
<pre><code>@media print {
  //my print-only css
}</code></pre>
<p>Which I think is better, because it saves a http request while still being fairly clear.</p>
<p>Of course, most of this information isn&#8217;t new. There is a great <a href="http://www.alistapart.com/articles/goingtoprint/">A list apart article from 2002</a>(!) that details much of what I&#8217;ve written above.</p>
<h3>Updated: Additional cool techniques by <a href="http://janpaulposma.nl">Jan Paul Posma</a></h3>
<p>The trick we used before to display links can be used in a number of different ways. Suppose, perhaps, that you are using relative links on your domain. <code>about ( /about )</code> wouldn&#8217;t be very useful. Luckily you can add arbitrary text to your ::after content, such as this:</p>
<pre><code>a[href^="/"]:after {
	content: " (http://kilianvalkhof.com" attr(href) ")";
	font-size: 90%;
}</code></pre>
<p>And the same idea can be applied to acronyms and abbreviations!</p>
<pre><code>abbr[title]:after,
acronym[title]:after {
	content: " (" attr(title) ")";
	font-size: 90%;
}</code></pre>
<p>The [title] part of the selector is there to make sure only abbreviations with a title element get explained. This prevents empty parentheses from popping up.</p>
<h3>In the eye of the public</h3>
<p>So, we&#8217;ve known about this since 2002 <em>at least</em>, why do clients still ask for a special print page and a little printer icon for people to click on? </p>
<p>The reason for that is of course pretty clear: the browsers doesn&#8217;t tell people that a page is especially adopted for print as well as screen. And so in turn people have no idea of the possibilities. </p>
<p>Print stylesheets arent very useful if people don&#8217;t use them.</p>
<p>And I really don&#8217;t know how to change that. Do you?</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/css-xhtml/a-useful-print-stylesheet/">A useful print stylesheet</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2008/css-xhtml/a-useful-print-stylesheet/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Absolute positioning Vs. floats</title>
		<link>http://kilianvalkhof.com/2008/css-xhtml/absolute-positioning-vs-floats/</link>
		<comments>http://kilianvalkhof.com/2008/css-xhtml/absolute-positioning-vs-floats/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 01:00:28 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=178</guid>
		<description><![CDATA[<blockquote><p>They're both right. Each method breaks faster, but in different situations.</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/css-xhtml/absolute-positioning-vs-floats/">Absolute positioning Vs. floats</a></p>
]]></description>
			<content:encoded><![CDATA[<p>It seems that there is a divide between people saying you should use absolute positioning and people saying you should use floats, both claiming that the other method breaks faster.<span id="more-178"></span></p>
<h3>They&#8217;re both right.</h3>
<p>Of course, it&#8217;s all about <em>when</em> you use which method. In some cases, absolute positioning breaks faster and it&#8217;s better to use floats, while in other situations it&#8217;s better to use absolute positioning because floats would break the layout. luckily for us, there is one very simple rule:</p>
<blockquote><p>If elements should not interact, use absolute positioning, if they should, use floats.</p>
</blockquote>
<p>It&#8217;s that simple. Lets take this site for example. The searchform in the top right uses fixed positioning (which mostly behaves like absolute positioning) because it will, and it must, never interact with the other elements on the website. However if you scroll down to the footer, you can see 4 lists next to each other. It&#8217;s entirely possible that there are only two or three lists available. In that case, you do not want a gap on the left or in the middle, you want the elements to interact and line up nicely starting from the left. That&#8217;s what floats do for you.</p>
<p>If you want a more in-depts explaination of css positioning, check out my articles on them: </p>
<ul>
<li><a href="http://kilianvalkhof.com/2008/css-xhtml/understanding-css-positioning-part-1/">Understanding CSS positioning, part 1</a></li>
<li><a href="http://kilianvalkhof.com/2008/css-xhtml/understanding-css-positioning-part-2/">Understanding CSS positioning, part 2</a></li>
<li><a href="http://kilianvalkhof.com/2008/css-xhtml/understanding-css-positioning-part-3/">Understanding CSS positioning, part 3</a></li>
</ul>
<p>So, now you know that it&#8217;s not black and white (<em>It&#8217;s grey!</em>). There are times when you use floats, and there are times when you use absolute positioning. In my opinion, correctly styled floats are much more robust than absolute positioning, so I personally tend to use them more. How about you?</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/css-xhtml/absolute-positioning-vs-floats/">Absolute positioning Vs. floats</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2008/css-xhtml/absolute-positioning-vs-floats/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>The CSS3 :not() selector</title>
		<link>http://kilianvalkhof.com/2008/css-xhtml/the-css3-not-selector/</link>
		<comments>http://kilianvalkhof.com/2008/css-xhtml/the-css3-not-selector/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 08:11:07 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[CSS & (X)HTML]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=135</guid>
		<description><![CDATA[<blockquote><p>The <code>:not()</code> selector is only supported by modern browsers, <code>:not(IE)</code>.</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/css-xhtml/the-css3-not-selector/">The CSS3 :not() selector</a></p>
]]></description>
			<content:encoded><![CDATA[<p>There isn&#8217;t a lot of information to be found about the <code>:not()</code> selector. The specifications only offer 3 lines of text and a couple of examples. So lets see what it can do!<span id="more-135"></span></p>
<h3>The Specification</h3>
<blockquote><p>The negation pseudo-class, :not(X), is a functional notation taking a simple selector [&hellip;] as an argument. It represents an element that is not represented by the argument. </p></blockquote>
<p>What it says here, is that a selector with a <code>:not()</code> in it will match all elements that <em>do not</em> match what&#8217;s between the parenthesis. </p>
<p>A simple selector is a term used in the specifications. A simple selector is: a single element, attribute selector, class, id or pseude-class.</p>
<p>Examples of simple selectors:</p>
<pre><code>body
*
[value="foo"]
.foo
#foo
:hover</code></pre>
<p>Basically, any of the above type, but with only <em>one</em> selector. </p>
<h3>The browsers</h3>
<p>The <code>:not()</code> selector is only supported by modern browsers (Firefox, Safari and Opera), <code>:not(IE)</code>.</p>
<p>Let&#8217;s take a look at what browsers allow you to do:</p>
<pre><code>div:not(.home) {&hellip;}</code></pre>
<p>This selects all div elements that do not have the class <code>.home</code></p>
<pre><code>div *:not(p) em {&hellip;}</code></pre>
<p>This selects all em elements that are in an element (that is not a p element) and that are in a div element. so <code>&lt;div&gt;&lt;strong&gt;&lt;em&gt;&hellip;&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;</code> is a match, but <code>&lt;div&gt;&lt;p&gt;&lt;em&gt;&hellip;&lt;/em&gt;&lt;/p&gt;&lt;/div&gt;</code> is not.</p>
<pre><code>input:not([type="file"]) {&hellip;}</code></pre>
<p>This uses the attribute selector to select all input element, save for the file upload ones. </p>
<p>I was surprised to find out that</p>
<pre><code>h2:not(.foo, .bar) {&hellip;}</code></pre>
<p>also works. You can give the <code>:not()</code> selector a comma separated list as well! (Tested in Firefox 3) This is surprising, because it&#8217;s not documented as such in the specifications.</p>
<p>You can use the <code>:not()</code> selector as a part of a large selector. I&#8217;ve done this a few times in my current design:</p>
<pre><code>li:not(.pingback) .comment-content p:first-child:first-line {&hellip;}
body:not(.home) h2 + p:first-letter {&hellip;}
.post:not(.first-post) a:hover {&hellip;}</code></pre>
<p>The <code>:not()</code> selector is a nice addition to the CSS Tookit, and it can already be used in a way that allows for graceful degradation, such as I do on this website. If you have any nice experiences with <code>:not()</code>, please share them in the comments!</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/css-xhtml/the-css3-not-selector/">The CSS3 :not() selector</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2008/css-xhtml/the-css3-not-selector/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
	</channel>
</rss>

