Let’s talk about CSS, baby

Okay, I have a bone to pick with you, Internet. Can we please agree to code our HTML attributes (class, id) in a better way?

Here’s my position: hyphens are superior to underscores

I can back this up with at least two arguments.

  1. In most text editors that I’ve used, keyboard shortcuts CTRL+Left/Right/Backspace will skip over underscores, but not hyphens. So that means if I’m trying to traverse (via keyboard, like a good computer ninja) over
    some_long_ass_CSS_class_name_someone_wrote

    then I’ll have to succumb to trying to guess how long to hold Left/Right… or worse yet, use the mouse!

  2. It’s an extra keystroke to type an underscore. Over the course of one small project, this might not seem a lot, but if it’s your craft & profession, This is a lot of extra keystrokes. Plus, it would speed up your probably-inevitable-RSI.

MailChimp, I’m looking at you!

As much as I love MailChimp, I was frustrated when trying to style their embeddable signup form. All these underscores!

Agree/Disagree?

I’m going to start using this format for writing my code. In fact, I already have. If you look at my recently redesigned homepage and inspect the first image on the page (me standing in the subway) you’ll see the link surrounding it is class=”pants-toggle” and the image itself has class “no-pants”.

If you dig on this, implement it yourself. Either way, I want to hear what you think in the comments.