Your're using CSS, Right???

As a Java developer, you know that hard-coding text strings and values is a no-no. You also know that you shouldn't tightly couple the model, view, and controller. In the HTML / Web world, this same item approach applies: Don't hard-code formatting rules in the content. (Stated in J2EE terms, don't couple the model and the view.)

I've run into several code examples that have this:

  1. <div style="margin-top: 10px; width:250px">
  2. Delivery is made within 2-6 business days
  3. </div>

When in reality, they should be doing this:

  1. <div id="deliverystyle">
  2. Delivery is made within 2-6 business days
  3. </div>

And in your CSS file, you have this:

  1. #deliverystyle {
  2. margin-top: 10px; width: 250px;
  3. }

When web pages are trivial, you can get away with hard-coding the layout in the content. But then again, the same can be said about models, views, and controllers.

Building a solid, maintainable Web 2.0 application requires the use of Cascading Style Sheets (CSS). And to be clear, all of the toolkits back this up. Accordingly, all examples here assume that the following CSS will be used.

If you're not familiar with CSS, I'd recommend you do some investigation. There are a number of good tutorials on the web. If you're more of a book person, I personally like the Visual Quickstart book titled "HTML, XHTML, and CSS". (Mine is the sixth edition, and I'm sure that's not the most recent version.)