It’s always nice to receive emails from readers, and it’s especially nice when we hear that something we’ve written has been of help or has had a profound influence. Paul received one such email from reader Nick Lauro:
‘Thanks for your recent articles in PC Pro, where you highlighted the use of CSS in web design. As a wannabe web designer/dabbler since 1999, I struggled for not long enough with raw HTML before being introduced to Dreamweaver. Ever since then, I’ve wondered how so many sites manage to look so great without the use of lots of JavaScript or formatting mark-up within the source. It was only after reading your article, which also turned me onto Style Master, that the light bulb went on.
‘It’s changed my whole view of web-page design and given me real focus. Instead of hitting Dreamweaver and throwing in a load of tables and a few JavaScript tricks generated by Dreamweaver, I’ve now gone right back to school to learn the power of CSS. My use of Dreamweaver was akin to putting a huge pan of plain pasta on the stove and adding every conceivable ingredient I thought might enhance its taste, but without knowing exactly why it might make it taste better. But thanks to your article, I’ve discovered the real use of CSS and I’m a reformed character, learning all the time.’
Getting emails like that makes this job worthwhile. Nick goes on to recommend some tutorials and a book, and then asks a question about CSS-designed pages:
‘I still use Dreamweaver to create updatable templates and also in code view, but my main weapon is Style Master and some of the excellent tutorials by Russ Weakley, which you can find at www.maxdesign.com.au. I also recommend his Sams Teach Yourself CSS in 10 Minutes book for anyone wanting to drop Dreamweaver-driven layouts for CSS.
‘Just one question, do you still use tables for forms? Do you think this is possibly one of the few situations where tables are better for positioning elements than CSS?’
Well, Nick, the answer to your question is ‘it depends’. Although some CSS zealots think tables are the spawn of Satan, they’re usually missing one important point: tables do have a perfectly valid use, which not surprisingly is for displaying tabular data. Consider this example: if you want to display a matrix of monthly sales figures for half-a-dozen products, a table would be the perfect mark-up to use. And, likewise, if you had a form where the user could input those sales figures, a table would work well. However, for a typical website contact form, where you might ask for a name, email address, ‘how did you hear about us’ and so on, tables aren’t necessarily the best mark-up to use.
So what are the alternatives? Well, we’re going to be slightly controversial here and show an example using a definition list. Let’s get the controversy out of the way first. A definition list is a listing of related items, whose two parts are the term and the definition, for example:
Camembert
Smelly French cheese, sometimes runny
Stilton
English cheese, blue
In fact, entries in the list can contain multiple terms and/or definitions:
Grass
The green stuff in your lawn
To snitch on someone
A snitch
Herbal Cannabis
Greenhouse
Glasshouse
A place to grow tomatoes
The disputes arise because some people believe definition lists should only be used for terms and definitions – things like dictionaries and encyclopedia entries – while others hold that they may be used for any list of related data. At first, you might lean toward the former view, as after all those tags are called ‘definition term’ and ‘definition description’. However, if you take a look at the relevant W3C specs (www.w3.org), the authors state: ‘Another application of DL, for example, is for marking up dialogues, with each DT naming a speaker, and each DD containing his or her words’. That’s a fairly clear and unambiguous permission to use a definition list without sticking strictly to terms and their definitions. If W3C can do it, so can we. So with the controversy sidelined, let us return to our form. A typical
-based form might look like this:
To do the same kind of thing with a definition list would look something like this:
Note a few things here. First, the form has an id and the button has a class, so we can style them properly. Second, the form labels employ