Nerds Gone Wild

Since I’ve been down with OPC (”other people’s CSS”) all day, I figured I’d take a quick break to do a post about my anal-retentiveness; also known as, “This is how I like my CSS and you better recognize, beeotch!”

The way I like stylesheets to be set up is very specific. Let’s look at an example, shall we?

h2.title {

 color: #339;

 font-size: 110%;

 margin: 0 0 2px 0;

 text-shadow: #666 0px 0px 3px;

}

h2.title a { text-decoration: none; }

h2.title a:link, h2.title a:visited { color: #339; }

h2.title a:hover { color: #7D523D; }

.blogEntry .timestamp, .blogEntry .comments, .blogEntry .category {

 font-size: 90%;

 padding-top: 5px;

}

A few things to note:

  • CSS properties are in alphabetical order.
  • There is one space after the semi-colon for each property.
  • Each property is on its on line.
    • If the selector contains only one declaration, then the rule is on one line.
      • When the rule is on one line, there’s a space before and after the declaration.
    • If the selector contains two or more declarations, then it’s broken up onto multiple lines.
      • When the rule spans multiple lines, the selector is on top, with opening bracket; then all the declarations, indented by one space; then the closing bracket on the last line.
  • I ♥ shorthand, inheritence, and group selectors.
  • If the value (of a margin, for example) is zero, then I don’t bother putting a unit, because it doesn’t matter.
  • I try to group together styles that kind of “go together” (all the h2.title styles, for example), and when I’m done with a “group”, I put one blank line before moving on.

Anal-retentive coders, unite!

11 Responses to "Nerds Gone Wild"

  1. Charles R says:

    I’ve been butchering your elegant coding, trying to learn CSS by pure trial-and-error.

    I’ve noticed that the IE blank space “bug” (I’m not sure if it is a ‘bug’ or ‘artifact’ or ‘glitch’ or whatever is the more technical expression for code nerds…) results from using PHP to create entries in both the main blog space and in the sidebar. I’ve thought of a workaround, but it will involve fundamentally changing how ASB looks. At least, looks for me.

  2. Rusty says:

    I suspect drowning in a wading pool of curdled rat semen would be more fun than coding around IE’s, umm, quirks.

  3. Amber says:

    That’s the worst thing you’ve ever said.

  4. Rusty says:

    I’ve said WAY worse stuff than that.

  5. Patrick Fitzgerald says:

    That curdled stuff is nasty… gimme fresh any day.

  6. Amber says:

    I’ve said WAY worse stuff than that.

    Well, not on this blog, you haven’t.

    … that I recall, anyway.

  7. Adam Zagursky says:

    I still can’t completely decide about this. It’s nagging.

    How tall are you?

  8. Amber says:

    Adam:

    I still can’t completely decide about this. It’s nagging. Why are you such a creepy motherfucker?

  9. Zagursky says:

    Genetics, and training.

  10. Jen says:

    Adam, when is your site going to go live?

  11. Adam Zagursky says:

    It lives. It’s always been live, I just made the interface hard to understand. For fun.

    The new incarnation features little holes or stars around the sun, upon which you click to read old stories. You just have to look really closely to find them. They turn into little red inverted crosses, when you hover the pointer over them.

    There will be some new photos of my house and cats, too.

    Watch out, though, because the site is all motherfucking creepy.