Search code examples
htmlcsscamelcasingbem

HTML/CSS:CamelCase vs Underscores


I have read lots of articles about advantages and disadvantages of camelCase and Underscore naming conventions. I've always prefered camelCase mainly because it saves bytes.

But learning about BEM, I've been really confused. BEM naming is more readable but '_','__' and long names add file size. Also I couldn't found any js plugins with it. So which one is better for qualified webpage?

P.S. sorry for bad English. Any opinion is appreciated


Solution

  • For css I can't recall I ever seen camel case (in professional work).

    For me I use BEM when I work on private projects. I tend to use double underscore like .banner__image and .banner__image--large (you get it if you read the BEM specs).

    At work our team use BEM with a modification though, only one underscore or hyphen (for modifiers) .banner_image and .banner_image-large.

    If not using BEM you probably should write classes with a hyphen (-). Like this .banner-image and .banner-image-large. For examples you can look at Twitters bootstrap structure with class names, or any other site infact.