开发者

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 selecto开发者_开发百科rs. So should it be:

rightContent

right-content

RightContent

or is it really personnel preference.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜