SomeShinyObject
SomeShinyObject

Reputation: 7821

Website naming conventions

Is there a standard way I should be naming my element's IDs and classes. Recently I have been looking into cleaning up all my CSS (NIGHTMARE!) and I have been seeing a lot of different schemes for naming. I am using camel casing for mine but I have been seeing, in my adventure to organize, hyphened selectors, capitals at the start of every new "selector word", and much more. I also use dang near whole words for my selectors. So should it be:

rightContent

right-content

RightContent

or is it really personnel preference.

Upvotes: 3

Views: 196

Answers (2)

pinkgothic
pinkgothic

Reputation: 6179

As Delan Azabani said, it boils down to consistently applied personal choice.

Larger projects tend to formalise their project's coding standards, which also include naming conventions (usually of far more than just CSS) - that's the point you need to adhere to (possibly) someone else's personal choice. For example, Zend's framework has some (not-CSS) publically available, to give you an idea of how such an agreement might look.

Something like that can pay off the minute you have more than one developer - to just sit down and agree on a Definite Way To Do It TM. But if you're the sole developer, just pick a flavour and run with it.

Upvotes: 2

Delan Azabani
Delan Azabani

Reputation: 81492

It is completely personal preference, but there is one thing you should do: be consistent with what you choose.

Upvotes: 8

Related Questions