Because there are so many ways to skin the proverbial cat, as CSS developers, we pretty much have free reign to do things as we please.
While some things in CSS are pretty straightforward (like if you want to add a rollover color, you use
:hover), that is not the case with others. In many cases, there is no set way to accomplish a single task in a layout or with regards to some other CSS-based technique.
In such cases, it’s up to the developer to choose what he wants to do based on his own preference, his workflow, his knowledge of CSS, and experience in dealing with certain aspects of the language.
Examples of Decisions That Need to Be Made
Here are some examples of decisions that CSS developers need to make:
- Should I use a reset?
- Should I use a CSS framework?
- Multi-line or single-line declaration blocks?
- Hacks or conditional comments?
- ID or class?
- Should the
<body>tag be my container?
- Margins or padding?
- Shorthand or longhand?
- Fluid-width or fixed-width?
- Pixels, ems, or percentages?
- “Clearfix” or “overflow:hidden/auto” to clear floats?
- Should I use a larger font stack?
- Should I use min- and max-based properties like “min-width” and “max-height”?
- Should I indent my declaration blocks to match the HTML indentation?
- How often should I insert a comment?
In many of the above listed decisions, the result visually will be exactly the same regardless of which choice is made, again emphasizing the fact that there really are many ways to skin a cat. (Of course, in cases like choosing indenting or single-line CSS, there would be a visible difference code-wise, but not in the actual display of any page.)
I don’t really know what this post is supposed to accomplish other than maybe to remind us of how flexible our craft really is, and how many little decisions we face and decide upon often instantaneously.
This also might serve as a reminder that these options are available, and we shouldn’t get too dependent on a single style of CSS coding.
Are there any other CSS decisions that need to be made that fall under the “either/or” category like many of those listed above?