If you're looking to display a simple key/value list, such as a list of user's contact information, a table might be overkill. I'd suggest the use of the definition list. In my opinion, the syntax for this element is far simpler – leading to more manageable code. It's only downfall is how it's rendered on the page (value below key).

To make DL behave more like a table with columns, use the following CSS as a guide:

dt { float: left; clear: left; width: 100px; margin: 5px 10px 0 0; }
dd { float: left; margin: 5px 0 0 0; }

You may want to adjust the width of the dt if you expect larger amounts of text.

Tags:

1 Comment

  1. Note: IE 7 doesn't float the DD elements properly. You can overcome this by using absolute

    positioning as follows:

     

    dl { *position: relative; }
    dt + dd + dt + dd { *position: absolute; *left: 210px; *margin-top: 30px; }

     

    The asterisk forces the styles to be interpreted by IE only.

Leave a Reply

Your email address will not be published. Required fields are marked *