nate koechley's blog

http://nate.koechley.com

Dec
22
2006

Trackback or comment.

Find citations on Bloglines or Technorati. View blog reactions

By category: Engineering, Front End Engineering, Life....

Replying to comments on my 24ways article about YUI Grids, I had occasion to mention the two things to consider when choosing good class and ID names. I want to write more on this, but for now wanted to cross-post my quick note:

Regarding class and ID names:

Names should not be based on appearance, but on meaning. For maximum extensibility, choose names that express semantic meaning (derived from the element’s content), and/or structural meaning (derived from the element’s role in the DOM’s tree). Good structural names include “footer” and “module”; good semantic names include “price” and “date”.

The alternative, what-it-looks-like names such as “left” and “doc950px”, is contextually brittle (i.e., mobile) and temporally brittle (because things change). These are the same reasons professional consensus says class=”redButton” and class=”smallBoldVerdana” are undesirable.

Leave a Comment

Comments are held for moderation so I can manually delete spam not caught by the filters.