The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS naming convention

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #39205


    this bugs me lately.

    Write words together is not eradable but …

    JavaScript uses camel case = SomeThingHere
    SQL uses underscores = Some_Thing_Here
    CSS uses dashed for 95% for what I saw = Some-Thing-Here

    Would it be unusual to use underscores in .CSS as for naming classes and ids ?

    .slideshow {float: left;} ... (hard to read)
    .SlideShow {float: left;} ... (slightly better)
    .slide-show {float: left;} ... (more readable)

    .slide_show {float: left;} (seems to be the winner = readable and copy_able)

    I like the ability to copy / paste names when using underscore (not possible with dashed) but I feel weird about it after 5 years of using dashed in CSS.

    How do you write classes in .CSS ?


    @krysak4ever, I know this isn’t the answer you’re looking for, but to help in selection you’re probably aware you can click and drag to select; but you can also double click and drag to select – this will select complete words as you drag making the selection simpler than by character.

    /* wow that was a long run on sentence ;) */


    @Krysak4ever If you are selecting text with your mouse, then you are probably going to be slower than using your keyboard no matter what method you use. I find it quicker to select text via my keyboard, avoiding moving my hand to the mouse if I can.

    I have generally used camelCase so that a simple SHIFT + OPTION + → selects the class within a single button combination, but have recently started using dashes as I am using more of a OOCSS approach now, and that allows me to easier copy select parts of classes. It also looks nicer as that is what CSS does, but that is just aesthetics.

    I do as much of my navigating throughout my code with my keyboard as possible. I highly recommend you learning to do the same, I think you will find it quicker too :)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.