Grow your CSS skills. Land your dream job.

New Poll: Hyphens, Underscores, or camelCase?

Published by Chris Coyier

I'm talking about anywhere you need to write multiple words, but can't use spaces. For example: CSS classes and id's, programming language variables and function names, website usernames or passwords, etc.

You can vote in the poll in the sidebar. Feel free to share your reasoning in the comments. Results in a monthish.

Comments

  1. as an ex programmer, I was always a camelcase guy.. but in the last six months or so citing readability as a my reason i’ve migrated to hyphens. Underscores are simply an irritation to type repeatedly and quickly while coding.

    • Rob Carruthers
      Permalink to comment#

      if (html || css) hypens;
      else camelCase;

      I was always told it was bad form to use uppercase with html and css, has this changed?

    • I can’t answer your question but I’m also onboard with your paradigm:
      * html & css – hyphens
      * everything else – camel

    • Ahmed
      Permalink to comment#

      Indeed. for html/css it should be hyphens, for php functions & else, camelCase is the best choice.

    • Doc
      Permalink to comment#

      Jep, that’s the way (ah ah) I like it too.

    • Permalink to comment#

      Same here.
      And, if java lower camelCase, if C# upper CamelCase

    • Permalink to comment#

      same again from me!

    • Permalink to comment#

      Same here!

    • It is not bad form to use uppercase with css. XHTML does not allow a mixture of upper and lower case but class names are not “html” they are classes, and css.

      Not that I disagree with your choice but there is nothing wrong with camelCase for css.

    • Yeah, agree’d I should have specified CSS in my comment there, naturally assumed :D

      although, I do sometimes use hyphens in php, however I wouldn’t entertain using hyphens in java or c++..

      I think thats purely been influenced by other coders on the web, take word press functions for instance.

      Personally I was taught camelCase for programming applications.

    • mixing my hyphens and underscores there.. lol

      underscores is what I meant for php

    • Permalink to comment#

      /agree

    • Wyverald
      Permalink to comment#

      I agree. For HTML, CSS and XSLT etc. where it’s possible to use hyphens, I always use them. Otherwise, camelCase will be used.

      Also you typed ‘hyphen’ as ‘hypen’ in the poll…

    • TeMc
      Permalink to comment#

      I’ve been told the mirrorside of what Rob says. Namely, that php doesn’t allow hyphens. So since I dislike underscores, I was left with using camelCase.

      And in CSS/HTML I like to use hyphens due to the selectability (try it: test-test, test_test) and I don’t use camelCase in CSS/HTML due to hyphens being easier to read in a css-file (using “mostly single-line” style) I can easilty see a tree-like structure this way.

    • TeMc
      Permalink to comment#

      Tho in PHP functionnames I’m 100% underscores . .

    • Permalink to comment#

      I used to do camelCase everytime, everywhere, then i migrated from Mysql to Postgresql and, becose postgresql doesnt allow camelcase in tables/columns name (but just lower-case), i got stuck.
      I like to use the same ‘formatting’ on every language, so that’s it: hypens where they are allowed, underscores just everywhere else (php, for example)!

    • And in CSS/HTML I like to use hyphens due to the selectability (try it: test-test, test_test)

      Interesting – I can select the whole phrase with underscores, but not with hyphens. At least in the browser, in Safari, and I checked – also in text editors… that counts as a point towards underscores in my mind.

      As for readability – I feel underscores are more readable as separate words.

      Sadly, however, I am not terribly consistent with this and have my own “logic” (which might be fairly random at times). I need to change this bad habit… but I prefer allonewordlowercase for some situations, then underscores_between_words, then hyphenated-words-if-they-are-more connected, and sometimes a combination_of_underscores-and-hyphens, which is just silly, and occasionally, camelCase, but that is mostly for javascript and php. If I had to pick one for html/css, I would go for underscores for readability and selectability.

  2. Permalink to comment#

    Underscores in css classes and id’s
    CamelCase in php functions.

  3. Permalink to comment#

    Always camelCase :)

    • i like camelCase.

      html/css: #search_bar [underscore]
      functions: def myFunction [camelCase]
      classes : class MyAwesomeClass [CamelCase]

      I dont use hyphens anywhere.

      with dilse

  4. rpophe
    Permalink to comment#

    I like hyphens. I tend navigate with the keyboard and use command arrow a lot for jumping from word to word.

    Hyphens are the only of those options which allow jumping between the inner-words. If I misspell an inner-word, it allows for easy navigation for fixing the problem.

    • Bill
      Permalink to comment#

      Hypens are for true coders because there’s no shift key involved. And everyone knows that true coders are the laziest people alive. Hyphens cut work by 50%!

  5. camelCaseIsNice()

  6. TheDoc
    Permalink to comment#

    Used to be an underscore guy, but now there’s is no way I’d use anything other than hyphens. Cleanest option by far.

    I don’t do much programming, however, and I understand camelCase is used often there.

  7. Skofo
    Permalink to comment#

    Why does it matter?

    • EVula
      Permalink to comment#

      It doesn’t. Whatever works best for an individual is, by default, the best method.

      Doesn’t mean that people can’t put their heads together to see how other people do things, however.

  8. Permalink to comment#

    html/css: #search_bar [underscore]
    functions: def myFunction [camelCase]
    classes : class MyAwesomeClass [CamelCase]

    I dont use hyphens anywhere.

    Python Coding Style says CamelCase for classes and camelCase for functions

  9. That’s are great..!

  10. Permalink to comment#

    camelCase FTW!

    Saving your bandwidth, 1 byte at a time!

  11. Dan
    Permalink to comment#

    css: dashes.
    programming c#: camel case (and pascal case)
    when I write ruby (not very often): underscore (but i don’t like it too much because I have to press an extra shift).

    I use the different styles because of the “best practices” of each language.

  12. camelCase FTW! No matter what I’m writing in.

    Also, thanks for posting this, I’ve often wondered what other people use.

    Did I miss where you say what you prefer?

  13. Permalink to comment#

    camelCase is perfectly all-round. I use it in CSS classes and ID’s as well as in PHP and Javascript variables and functions.

  14. Permalink to comment#

    Hi. In css use only hyphens, in php only use underscores, in use only java and javascript only camelStyle… :))))) – honestly!!! :)))

  15. Permalink to comment#

    I’m a camelCase guy ;)

  16. Permalink to comment#

    Hyphens in CSS and HTML attributes. Read somewhere that older browsers glitch if you use underscores.

    In other programming, I use underscores for variables and function/method names. Looks cleaner, in some way. Camelcase is not very readable I think.

  17. Permalink to comment#

    I used to strictly be an underscore guy, but I’m starting to switch to hyphens because I type them faster.

  18. Permalink to comment#

    I tend to use camelCase more than anything. But sometimes I do use hyphens. I absolutely HATE underscores. They are really hard for me to type. lol. So I avoid those as much as possible.

  19. Permalink to comment#

    I always prefer…

    HTML & CSS: hyphens
    PHP & JS: underscores
    VB.Net & C#: CamelCase

  20. Eire32
    Permalink to comment#

    I may be weird but all three.

    CSS is the dash.
    PHP varibles underscores
    PHP functions and JS Camelcase

  21. MySchizoBuddy
    Permalink to comment#

    How about a keyboard with a special underscore button so you don’t have to use the shiftkey

  22. Permalink to comment#

    Programming: CamelCase
    CSS: dashes

    I really hate underscores. They take way too long to type. I use dashes in CSS because I like to keep as much stuff as possible in lowercase in my HTML.

  23. Permalink to comment#

    CamelCase! MuchEasierToTypeAndTheReadabilityIsn’tHardAtAll. IfAnythingItMightJustImproveYourReadability.

  24. I didn’t vote in the poll since it depends.

    Anything a search engine can read you’re better off using dashes. Otherwise just be consistent.

    I typically use underscores when programming, but even then it depends on the language. I try to use whatever seems most common in the particular language.

  25. Between hyphens and underscores, such as in URLs, I always use hyphens.

    Programmatically, I’ve preferred hyphens as well, but several languages don’t support them in variable and function names, so lately I’ve been migrating to CamelCase.

  26. Permalink to comment#

    I generally use hyphens, though I slip-up and use underscores once in awhile, as I tend to name PHP functions along the lines of the_function_name(). I’m really not a fan of camelCase. It seems less legible to me.

  27. Permalink to comment#

    It depends on what I am doing. With CSS & HTML I use hyphens, with AS3 I use camel case and underscores (for variables and constants respectively). Since this is a CSS blog I imagine you only meant for CSS use so I voted hyphens :)

  28. Matt
    Permalink to comment#

    Which is more search engine friendly? I was always told that using hyphens is the optimal way of write multi-word file names or URLs. Edumacate me!!

    • Permalink to comment#

      Hyphens are best when it comes to URLs – but what you use in programming doesn’t affect SEO.

    • caefer
      Permalink to comment#

      Hyphens are in fact search engine friendlier as google is able to split by them but not by underscores. Underscores count as characters and though glue two words to a single big word which is unlikely to be a SEO keyword. CamelCase words can never be split by search engines as there can be no formal rule how to split.
      It is however very unlikely that CSS classes and IDs will be considered by search engines.

  29. Sverri
    Permalink to comment#

    I have always been fond of using underscores.

    When working with rather large amounts of code underscores make the ascenders more visible and therefore easier to read (we read words largely by the shape of the word, and not letter by letter).

    Hyphens and, to a much larger degree camelCase, has the effect of making the words look more like one big word, making it more difficult to quickly locate what you are looking for:

    1: $this_is_a_variable

    2: $this-is-a-variable

    3: $thisIsAVariable

    The first line has much more air between the words.

    Well, that is just me.

    • Zoran
      Permalink to comment#

      I agree with you, i use underscores all the time, i have used camelCase, but then i find it hard to manage the code when i debug.

    • Permalink to comment#

      I agree also,

      Underscores keep the words cleaner and more seperated then camelCase. For readability its win_win!

      I use it for everthing is code: html/css, php and javascript.

  30. Daniel
    Permalink to comment#

    Chris, I think you should specify when, since some of us, including myself, would answer like so:

    Programming: CamelCase
    CSS: hyphens

    I think I will go with hyphens for the poll though ;)

  31. Permalink to comment#

    I use_underscores in my CSS and PHP.

    I just don’t like the look of hyphens, and I heard that it was best to keep everything lowercase.

  32. This isn’t really fair. I try to match the accepted idioms of the languages I program in.

    For CSS I use either underscores or hyphens depending on my mood. :)

    For PHP and JavaScript I normally use underscores for variables, camelCase for function names, and MixedCase for constructors or object literals.

    For Ruby I use underscores for both variables and functions.

    For friendly urls I always use hyphens, all lower case.

    Perhaps you need to limit the scope of the Poll to one language… maybe CSS ?

  33. Permalink to comment#

    Unless I’m trying to save bandwidth, I use hyphens. Or limit myself to one word. Otherwise, I use CamelCase.

  34. Simes
    Permalink to comment#

    CamelCase

  35. I like using dashes for CSS class names, underscores for DOM IDs.

    • That’s a nice system, I guess it’s handy when you want to use an ID that’s similar or the same as an existing class name.

  36. I do underscores…always have. No reason, I just always do it like that :D

  37. Scott
    Permalink to comment#

    #top-nav

    function db_connect()

  38. I generally use CamelCase for speed (and out of habit) but I’m thinking that I may try and use hyphens in CSS, mainly for when other people who don’t have a programming background are going to be working on the same files.

  39. Cole Geissinger
    Permalink to comment#

    Would love to cast my vote, although I cannot do so on my iPhone . Have to when I get home I guess!

  40. I use dashes, the reason: SEO friendly filenames.

    I’ve read that search engines interpret underlines as ‘nothing’ thus “about_company_name.php” would be the read as “aboutcompanyname”, and that is only one word that wouldn’t mean anything to search engines.

    On the other hand “about-company-name.php” would be understood as “About Company Name”, thus giving the page a relevant name related to the type of content that page would have.

    With that being said, everything I do, when it comes to naming, I use dashes instead of underscores or camelCase styles.

    • Permalink to comment#

      That’s the reason I use dashes as well. I use dashes for image names too, like bg-li-a-header.gif…

  41. Permalink to comment#

    yes cameCase for Programming
    Hyphens for CSS Selectors
    and underlines sometimes for files (esp. for PC Windows-Systems which I sometimes don’t trust?)

    My favorites are dashes and camelCase but the best would be just a plain ________Space.

  42. Yuvalik
    Permalink to comment#

    Variations on CamelCase, everywhere except constants, those are in CAPITAL_UNDERSCORE.

    I have strict coding standards for PHP and JS and apply them to html/css as well.
    Besides, using hyphens makes the code unreadable to me (allthough I understand some disagree with that) and underscores are a bore to use on the keyboard.

  43. I use underscores for id’s and camelCase for almost everything else

  44. Permalink to comment#

    Personally I use them all.

    In my code I never (I mean ever) use hyphens. The only place I use them is in files that do not contain code. ie: images.

    For files that contain code I use underscores for the name.

    In the code itself, I use camelCase for class names and underscores for the functions and methods. Also, I preceed all the names of private variables and methods with an underscore, even with php5 syntax.

    So for instance that would look like a private method in a class in my code:


    class MyClass
    {

    private _some_var;

    private function _my_function()
    {
    // some code
    }
    }

  45. gonzo
    Permalink to comment#

    camelCaseIsNotBadAtAll

  46. Quintin
    Permalink to comment#

    Since I come from a Flash / ActionScript background, it was natural for me to go straight to camelCase. However, a couple of casing hiccups in some web languages lead to me using underscores out of prudence.

    Does anybody know if it really makes a difference to use uppercase?

  47. organicit
    Permalink to comment#

    for DB Tables underscore, but programing wise I am onboard with the consensus here.

  48. Permalink to comment#

    I’m a CamelCase guy, but am inconsistent and sometimes just combine the words with no Camel, but never use underscore or dash.

  49. Permalink to comment#

    For CSS and HTML I used underscores, but some time ago, I switched to dashes.

    PHP – camelCase

  50. Permalink to comment#

    That was a difficult poll to answer because it really depends on what we’re referring to here. I’m pretty much with everyone else on the comments here in that:
    html / css / domain names : hyphens
    js / php / perl / ruby / etc: camelCase

    usernames and stuff like that I tend to go underscores if there is going to be a space…which I always try not to have.

  51. HTML/CSS: Hyphens.
    URLS: Hyphens.
    PHP/JS: camelCase.

    It’s always best to use hyphens whenever possible for readability, seo, and it just looks sexy to tell you the truth.

    PHP/JS is best using camelCase considering underscores are just plain annoying. I like using underscores with variables though, otherwise functions and such are definite camelCase.

  52. Permalink to comment#

    HTML/CSS: Hyphens
    Everything else: camelCase

    looks like you need another option on your poll ;)

  53. matthew c
    Permalink to comment#

    camelCase to replace spaces between words, underscores to indicate important distinctions. eg: sampleFile_v01

  54. Permalink to comment#

    I also dislike typing underscores. So I prefer hypens and camelCase.

  55. William
    Permalink to comment#

    Used to be an underscore type of person, but recently (like tonight after reading the comments), for CSS and HTML ONLY, I use hyphens for select ability, for everything else (PHP, Obj-C, JS, etc.) It’s camelCase all the way!

  56. Hitesh
    Permalink to comment#

    Most time: underscore, because they are easy to read

  57. Maikel
    Permalink to comment#

    camelCase for almost anything.

  58. Matt
    Permalink to comment#

    Underscores out of habit, but it’s a habit I’m trying to break. Hyphens accomplish the same thing, but without getting the shift key involved, so why don’t I use them? No clue.

  59. Permalink to comment#

    ILoveCamelCase…

  60. Since I do a lot of programming in Rails, I have to use all three of those — camel case for classes, underscores for function names and hyphens in CSS. But if I prefer hyphens, because I can avoid the shift key there.

  61. Permalink to comment#

    Hyphens are nice. Hate underscore. Sometimes CamelCase.

  62. rizza
    Permalink to comment#

    I like camelCase, and always use it for almost programming language.

    Anyway just curious, what about your filename like
    – filename.php
    – fileName.php
    – file_name.php

  63. Permalink to comment#

    Coming from an XML/XHTML side of things, I’ve never used camelcase because of the all lowercase standards.

    And since PHP has had trouble with hyphens (or so i’ve heard) I’ve always defaulted to underscores for everything.

  64. The web motion and CSS 3 advents makes me feel that a near day we’ll have CSS expressions using hyphens. I know JavaScript libs were hyphen is already a selector, and who don’t know “-moz-opacity”…

    Underscore it’s not easy to type, but it’s a convention in many programming languages, were camel would not be very semantic.

    I use all camelCase, saving 1 byte, compact code and anything that saves connection time. If i build a common css widget… i name as package clock_nav (for a clock widget).

    I’ve done lots of research on JavaScript and CSS to build my lib (leaf.googlecode.com). The main point is what will come next about CSS expressions.

    Sorry about my English and laarge comment. I felt that I should say it.

  65. Rahul
    Permalink to comment#

    iLoveCamelCase… :)

  66. Permalink to comment#

    Depends on what I’m doing.

    – PHP / Java / CSS – Camelcase
    – URL’s of websites – Underscores
    – C# – PascalCase
    – Almost never use Hyphens (unless I have to, like with CSS properties “margin-left”)

  67. Permalink to comment#

    actually i do prefer milk with my coffee.

  68. Interesting discussion going on… I love using camelcase always…

    -Deepu

  69. chihwen
    Permalink to comment#

    follow CSS build-in style use Hypens.

  70. Permalink to comment#

    I don’t care too much as long as it’s consistent throughout the code. For example, Drupal and WordPress use underscores in all function names; Symfony and CakePHP mostly camelcase.

    I agree with other people in terms of it depending on the language; html/css dashes are fine – in php they are not allowed.

  71. In xhtml/css I use hyphens, in php or python I use CamelCase it is more readable to me

  72. Seems to be one option missing. Lowercase only.

  73. I used underscores since i started coding, but tried camelcase few months ago and it seems it’s the best.

  74. Permalink to comment#

    camelCase, and underscores rarely

  75. Permalink to comment#

    camelCaseFtw =3

    • Permalink to comment#

      btw, I Forgot to mention that… to make my camelCase really work for me, is better to use smaller words. =)

  76. Mostly CameCase (I don’t want speacial chars in my variable or function names names)

  77. Bryan
    Permalink to comment#

    I started out using camelCase when I was in college working on my IS degree. Now I’m mostly a hyphen guy.

  78. Hyphens for CSS, HTML and file names, camelCase for eveyrthing else.

  79. Permalink to comment#

    It all comes down to my fat fingers… hyphen is much easier for my thick digits than underscore.. of course there is the cases where the underscore is necessary but I try to avoid twisting my fingers around as much as I can

  80. I’m personally all about hyphens but I’m mainly in HTML / CSS. I find-that-it’s-much-cleaner-and-easier-to-type, see?

    When I’m working with Flash and making several movie clips I like to throw in underscores.

    Example: my-movie_mc or myMovie_mc depending on what mood I’m in I guess :P

  81. I’m cracking up that all you self-described “lazy programmers” say using the shift key is such a pain – yet you have to use it for camel case! I guess I’m a fast (nimble-fingered?) typer so I don’t have any issue using underscore, and I like the readability of it. As a grammarian, I like underscores for semantics, too – they convey separate_words better than hyphens, which are for connected or related words (grammatically speaking, anyway).

    For very short two word phrases, though, all lowercase using no shift key, no special characters, and is fastest and leanest. but for longer words and/or phrases, readability suffers.

    • Permalink to comment#

      camelCase = shift + letter key
      underscroe = shift + underscore key + then letter key.

      -1 move = 1 step forwards

      And i agreed with you about the longer words and phrases, but i think there is always a way to make your id, or your class, or your var, or function name shorter. So i don’t worry about huge phrases wrote in camelCase. xD

  82. Permalink to comment#

    Hypens, because on mac (PC users, sorry!) if i double/triple click on a list-of-words i can directly select just what i want.

  83. Permalink to comment#

    Always camelCase. CSS, Coldfusion, PHP, Java, you name it, I camelCase it. I guess there is one exception, I never use it with HTML, but I’ve never seen a need to use any of the above with HTML.

    On a side note. A lot of people above say that you shouldn’t use camelCase in CSS. Why?

  84. Cybergrace
    Permalink to comment#

    Hey, Chris,
    I always had the delusion that Google might be able to read hypen’s better and doing the hypen thang for HTML/CSS might help propel my sites up the Google food chain. Any truth to this… or another myth bites the dust?!

    • Permalink to comment#

      I’ve heard the same thing: that a hyphen is read by Google as a space, whereas an underscore is not. Not 100% if its true, but it makes sense to me.

  85. Kristi
    Permalink to comment#

    I use CamelCase for class names, camelCase for function and variable names, and underscores for CSS and database stuff.

  86. HTML / CSS – Hypens,
    Functions – camelCase,
    Classes – CamelCase

    I hate using underscores.

  87. Permalink to comment#

    HTML/CSS – hyphens (no camel casing because this technically invalidates CSS, even though I don’t give two sh*ts about CSS validation :))

    Javascript/PHP – camelcasing (except I’m sloppy and sometimes use underscores for JS variables)

  88. I like using Camel Casing most of the times.. but in C I have seen this trend of using underscores..

  89. EVula
    Permalink to comment#

    With CSS, classes that are related I’ll give similar prefixes to using hyphens (ie: #hd-about, hd-#cont, etc). For everything else (including PHP), I tend to use underscores.

    I don’t think I’ve ever used camelCase.

  90. Marco
    Permalink to comment#

    I rarely comment on posts on any website, however, i just want to tell you how awesome this site is. This simple polls have been really interesting to see.

  91. senshikaze
    Permalink to comment#

    sadly i use all of the above >_>
    camelcase the most since my programming teacher in college required everything that wasn’t a class name be camelcased.

  92. I’m going to throw in the always helpful: “It depends”.

    OOP Code: camelCase
    HTML/CSS preference: hyphens.

    Lately, I’ve had to plug in the ugly underscore, because that’s how ASP.NET decides to mangle IDs together when you dynamically create them.

  93. HTML & CSS ~ Hyphens
    PHP ~ CamelCase

  94. Anthony
    Permalink to comment#

    I like to go camelCase.

    Using php, Javascript and HTML/CSS, I use camelCase for everything in the name of consistency which I feel helps avoid some of those silly little mistakes which inevitably take hours to spot!

    I agree with some of the above comments that it’s considered bad form for HTML and CSS, but personally I find camelCase works well universally and makes it easy to find or match up ID’s within HTML/CSS/Javascript/php.

  95. Permalink to comment#

    I develop web and desktop applications so for the web, most of the time PHP, i use underscores, but in desktop i use camel case .

  96. Eileen
    Permalink to comment#

    I mostly use camelcase as I also hate using the extra shift at times.

  97. Jason
    Permalink to comment#

    I personally use underscores for most things since it is really easy to read and easy to select (double click) the variable. The hyphens don’t allow you to select words as easily with the double click, but they are more standard for Google to read them as separate words. Therefore I use the hyphen only in the URLs. CamelCase is to hard to read for me.

  98. Permalink to comment#

    As others have said – camelCase is my first choice for id or class names, but when it come to image-names, hyphens are the way to go as Google and other search engines have started referencing images for SEO and hyphens are seen as blank spaces where as under_scores and camelCase will be read as one word.

  99. lortp
    Permalink to comment#

    So if you use camelCase what about function name which return boolean value. Do you use for these function: is_integer() or maybe isInteger()?

  100. It really depends, I have a system that I use that helps me speedily see where a variable/function/class resides/belongs

    CSS Classes and IDs are-dashed (Read somehwhere it works better)

    Local/Private/Protected variables and functions are_underscored

    Public Variables/Functions and all Non-CSS classes are camelCased.

    Works for me.

  101. Permalink to comment#

    Hyphens are better for SEO from what i’ve read.

  102. Permalink to comment#

    Always used camelCase must be from being taught VB6 at college.

    frmContact
    btnSend
    labelCaption

    Recently i started using hyphens for html, it just reads better in the mark-up.

  103. I was an underscore guy until just a couple of months ago. No real aesthetic reason, just a matter of efficiency. Using a hyphen is one less keystroke than underscore or Camel Case (no Shift necessary). Also, the only uppercase letters I care to have in my code are commented section titles.

  104. Permalink to comment#

    I like to user a combination of underscores and dashes…

    dashes for more related information and underscores to break it up

    e.g. client_website-header

  105. rex
    Permalink to comment#

    functions or variables or ids or important names > underscore
    urls > hyphens.

    i just don’t stand camelcase… it’s not readable friendly to me…
    ThisIsWhyiDisLikecamelCAseIneedTodycryptIt!!

    Hyphens-are-good-but-i-feel-i-need-to-concentrate-while-reading-it

    But_underscores_totally_easy_to_read_for_me

    moreover by using underscore i give the names more uniqueness and distinct look than other texts!
    which helps me to memorize functions better and locating them much easier!

  106. I use all three. CamelCase I use for user names on and around the web. Underscores I use for web URL’s and filenames. In my CSS markup I use the dash.

    Can’t say I have a particular preference. Though you’ll never catch me with underscores and dashes in user names. Always opt for a space. Failing that the CamelCase wins.

  107. Permalink to comment#

    camelCase works fastest and is my preferred style. Underscores are more readable. hyphened variables cannot be selected entirely with a double-click.

  108. What? Hyphenated variables? Which language? C-style languages will think you’re trying to subtract, no?

    I used to be an allCamelCaseGuy for HTML IDs/classes (They’re HTML IDs/classes, not CSS IDs/classes). But not easy to stick a Microformat in your page then is it? So I converted, eventually.

    Underscores? Never. It was either early Opera or IE4 that wouldn’t select classes or IDs with underscores in them.

    • For those of us that ever had the pleasure Netscape Navigator would not read class or id values that included an ‘_’.

      I much prefer verbose camalCase for functional programming and ‘-‘s for css.

  109. Permalink to comment#

    I use hyphens all the time by force of habit stemming from the fact that Google doesn’t recognise underscores as spaces but hyphens it does. It looks neat.

  110. I lean towards hyphens for anything I write and underscores for “native” code from the platform. Camel case, not since the mid-naughts. And I insist on calling them hyphens, not dashes, to the chagrin of my co-workers.

  111. I use:

    #underscores_for_ids
    .hyphens-for-classes

    and a mixture of camelCase_underscores-and-hyphens in programming, depends how I’m feeling at the time but I only use one per website.

  112. Permalink to comment#

    I’ve moved to underscores for images and classes as out back-end technology is primarily .net and our developers have found issues with hyphens.

    I’ve also dropped the use of ID’s due to the nagging I get from developers about .net client id’s and the refactoring for scripts and styles we end up doing. Have tried some work arounds but inevitably something interfere’s with the .net framework scripts.

  113. Dashes for the IDs and classes in HTML/CSS and underscores for URLs.

  114. Antoine
    Permalink to comment#

    I always use camelCase when in programming. From my point of view it’s more reliable and easier to read than hyphens or underscores. I use hyphens for URLs

  115. Luis Fernando
    Permalink to comment#

    client-side: Hyphens.
    server-side: camelCase.

This comment thread is closed. If you have important information to share, you can always contact me.

*May or may not contain any actual "CSS" or "Tricks".