The Secret of Building a Table with Dreamweaver

It’s easy peasy to create a table in Dreamweaver. It’s not so easy to create a table in Dreamweaver that sticks to the ideal of separation of content from presentation and uses CSS rather than HTML to determine presentation.

If you want to build a table for your web page that does use best practice rules and will be responsive to every potential situation, there are a lot of things in Dreamweaver that you should not do. I’m going to show you what not to do, explain why, and give you a best practice alternative.

The insert table dialog box

Do not put anything in the table width, border thickness, cell padding, or cell spacing boxes. Do select the appropriate heading type for your table, and do enter a caption and summary if needed.

table dialog box

I added an X to the boxes that you should leave empty. Table width, border thickness, cell padding, and cell spacing options are all used to add HTML presentation to the table. You want to keep the width, border, and padding presentation rules in the CSS. It’s best to use percentage widths for the various table rules rather than pixels. (See Adding borders to data tables with CSS for information about adding border with CSS.)

The Document Window

When you create a table the way I just described, you see something like this in your Dreamweaver document.

empty table in DW Document window

Insert the cursor in the first table cell so you can enter text and Tab your way into the next table cell. As you enter text, the table expands to fit the text you’ve entered. Padding for the td cells and other width and spacing rules to make the table more attractive go in the CSS.

table with text

It’s possible to drag the borders of the table around in the document window. This is another thing you should not do. As you can see in the image below, when you drag the table borders to resize it, absolute pixel values appear and are written into the HTML. In your stylesheet, use the width property for selectors like table, th, and td to set widths in percentages or ems for your table.

table border being dragged

The Properties panel

While you’re entering data in the table, you see table properties in the Properties panel. This is another set of options that you should not touch.

Properties panel

Do not enter pixel values in the width or height boxes. Do not select a background color for the table or for individual table cells. I’ve put an X in the forbidden fields in the image above. All of these options add HTML presentation to the table. You want to set these presentation values in the CSS. The image above shows the Properties panel with the HTML toggle selected. When the CSS toggle is selected, entering values into the width and height boxes also results in values coded into the HTML, not added to the style sheet as you might expect when the CSS toggle is active.

That’s it. Most of what Dreamweaver offers as table controls need to be left alone, and the majority of your work needs to happen in the stylesheet, not in the Document window. You can create a table that will work for all your users on just about any device if you learn what not to touch.

2 thoughts on “The Secret of Building a Table with Dreamweaver”

Leave a Reply