Articles by

Chris Coyier

Founder, writer, designer, spam-deleter, email personality

Common Unicode Icons

a[href^="mailto:"]:before { content: "\2709"; }
.phone:before             { content: "\2706"; }
.important:before         { content: "\27BD"; }
blockquote:before         { content: "\275D"; }
blockquote:after          { content: "\275E"; }
.alert:before             { content: "\26A0"; }
<p>
  <a href="mailto:[email protected]">
    [email protected]
  </a>
</p>

<p class="phone">
    555-555-5555
</p>

Saving contenteditable Content Changes as JSON with Ajax

Elements with the contenteditable attribute can be live-edited right in the browser window. But of course those changes don’t affect the actual document on your server, so those changes don’t persist with a page refresh.

One way to save the …

(Updated on )

(Better) Tabs with Round Out Borders

A good-looking tab control usually has one feature that I've always found impossible to reproduce without images: borders that bend to the outside at the bottom of each tab. In this article I would like to show how you can use the CSS :before and :after pseudo elements to create this effect without using images.
(Updated on )

Break Out of iframe

if (top.location!= self.location) {
   top.location = self.location.href;
}

That will generally work, but there is a small chance of failure in the case that window is overridden. Here’s a couple of clever alternatives from Nathan Smith:

<script>

// Break 
(Updated on )

addClass Function

If you are going library-free, you might need to roll your own function like this.

function addClass(id,new_class){
       var i,n=0;

       new_class=new_class.split(",");

       for(i=0;i<new_class.length;i++){
               if((" "+document.getElementById(id).className+" ").indexOf(" "+new_class[i]+" ")==-1){
                       document.getElementById(id).className+=" "+new_class[i];
                       n++;
               }
       }

       return n;
}

Usage

<div id="changeme" class="big red"></div>
<button 

Upcoming Speaking

My first half of 2012 is sprinkled with some web conferences I’m very much looking forward to. …

CSS Profiling and Optimization

Direct Link

Just as I got done saying how I hope we can soon stop talking about CSS selector performance, Juriy Zaytsev publishes some great research on selector performance using Opera and WebKit’s new “style profiler” as part of the dev tools. …