Standardize CSS class naming
As both a designer and developer, I find it irritating to see different naming styles in code.
Can we please standardize a naming format for CSS IDs and classes.
For example we have...
.pagenav -- words together, short words (in this case "nav" instead of "navigation")
.page_item -- words separated by underscore
.page-item-## -- words separated by dashes
.wp-caption -- WP prefix
It is up to the community to vote and decide on a standard but I would prefer #3 in the example above for the following reasons...
1 - CSS standard naming is dash separated words. I prefer to follow whatever the naming standard is for the language it is in (if there is a standard unlike PHP ;_;).
2 - It is readable. Not short naming like .pg-item or something like that.
3 - It is specific. It could have been like "ul.page li.item" but then if you had a ".item" rule then some styles could of been inherited when it was not intended. With "page-item" you know it has to be an item in a page.
4 - The "WP" prefix, if really needed, should only be used for WordPress specific stuff. But so far, I see no need for this so I would prefer not to have this prefix.
I think it's a bad idea personally to try to force people to conform to one coding style. It will reduce development productivity as developers/designers will have to spend as much or more time learning and conforming to the standard than it takes to actually design and code the solution.
People are individuals. Not all people think or create alike. It's like telling a painter that they can ONLY apply paint to the brush in a certain way, they can only stroke the canvas in a certain way, etc.
As long as they follow the rules of CSS (which is the standard you and others should be concerning themselves with)there is NO reason that they should be forced to follow someone else's coding "style".
Thumbs down IMO.
While I don't like feeling boxed in, I can't see anything wrong with a "Best Practices" of sorts.
There seems to be quite a lot of bloat with regards to class names and such. If we could all agree on a very, *very* basic pattern, we could address reason 3&4 above.
There are best practices and guidelines for all this in the themes group (there's a group of crazy volunteers who work on all this) and they enforce standards on WordPress themes.
Right NOW, it won't change. If there IS a change, it would have to support BOTH methods for a while, to give people time to change. How long would that time be? That's a big issue. It would make your pages a little bigger, confuse people over what to change. Deprecating code is a very tricky process and harder with the viral nature of open source :/
RSS feed for this topic
You must log in to post.