The Skinny on CSS Attribute Selectors

CSS has the ability to target HTML elements based on any one of their attributes. You probably already know about classes and IDs. Check out this bit of HTML:

<h2 id="title" class="magic" rel="friend"David Walsh</h2

This single element has three …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Five Questions with Jonathan Longnecker

I met Jonathan at a conference last year. Jonathan was giving a presentation about ExpressionEngine and how good it is for designers. He gave me a good natured ribbing about my use of WordPress. Read the interview below where I …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

#80: Regarding Wheel Invention

A couple needs a photo gallery for their wedding, where everyone can browse and upload their own photos from the wedding. Beginner developer: I know of some great software we can use, give me a couple of days. Skilled developer:

Avatar of Chris Coyier
Chris Coyier on (Updated on )

The Great CSS Off & Giveaway

Alrighty folks, here’s the deal. I have a whole bunch of stuff I want to give away. Mostly books on web design and development. I’ve been deep in thought trying to figure out the best way to give them all …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

jQuery MagicLine Navigation

These “sliding” style navigation bars have been around a while, I just thought I’d take a crack at doing it myself as the opportunity came up recently. Turns out it’s really pretty darn easy. I put two examples together for …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

How nth-child Works

There is a CSS selector, really a pseudo-selector, called :nth-child. Here is an example of using it:

ul li:nth-child(3n+3) {  
  color: #ccc;
}

What the above CSS does, is select every third list item inside unordered lists. That is, …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Make IE 6 Crash

This is absolutely NOT recommended for use in any sort of “real” website scenario. It’s just kind of funny and interesting.

<style>*{position:relative}</style><table><input></table>
Avatar of Chris Coyier
Chris Coyier on

Force Leading Zero

<?php
  function forceLeadingZero($int) {
    return (int)sprintf('%02d',$int);
  }
?>

Forces leading zero to integers.

was | now

1 | 01
2 | 02
3 | 03

10 | 10
100 | 100
99 | 99…

Avatar of Chris Coyier
Chris Coyier on