问题
Possible Duplicate:
Why are dashes preferred for CSS selectors / HTML attributes?
Personally I use "lower-case with dashes" to format my HTML classes, which seems to be the standard these days. Using something like camel case seems more reserved for JavaScript in my eyes, but I realise that's just my opinion.
I'm trying to improve front-end code consistency at my workplace and part of that will be coding guidelines. Rather than just saying "we should do it this way" I'm keen to hear some valid reasons behind this common trend.
So the question in summary, what are some valid technical reasons for the "lower-case with dashes" trend for HTML classes?
回答1:
Just like you mentioned in your own question but I realise that's just my opinion
.
Coding-conventions are:
- guidelines for making code more readable (amount of spaces for identation, naming of variables, ..)
- in no way a limit in your coding
- different for every language
In short, it's only a proposed way of coding which you don't need to follow but it's more readable for other people if you do.
If you come across one set of conventions, it means a lot of people agree with that set and adopt it for themselves (with or without some modifications =) )
Some languages restrict conventions a bit (like class names having to start with an uppercase letter, ..), that's why it's different for every language.
回答2:
There are none. It's an acceptable naming convention, to help the author from confusing between his different languages. You can name your class names in any way you'd like.
回答3:
Coding Conventions are just that: conventions.
What is a convention? It's some rule how to do things?
Why is it like that? Because someone said so.
来源:https://stackoverflow.com/questions/9735650/why-is-lower-case-with-dashes-the-standard-for-html-classes