Friday, July 13, 2007

Tables, Attributes, and Document Types

I had an odd problem in HTML yesterday. In adding a column to a table, I found that I could not set the column widths. Things looked fine in Dreamweaver 8 but in IE 6 and Firefox 2 the specified widths were being ignored. After trying a variety of things in Dreamweaver I brought the code over to Visual Studio 2005, to see if it rendered the table like Dreamweaver or the browsers. It rendered the table like Dreamweaver. I play around with the column widths a bit in VS 2005 and then formatted the code (I like how VS 2005 formats code), then brought it back to Dreamweaver. When I previewed the code again it worked! I scanned it quickly to see what had changed. I saw that it was no longer using the width attribute, VS 2005 had changed it to the style attribute with the width property. After a quick test I confirmed that once I manipulated the table columns in VS 2005, it re-wrote the tags.

The width attribute for the IS valid for XHTML 1.0 Transitional, so it validates (that’s the default document type in Dreamweaver), even though IE and Firefox have intermittent problems dealing with the attribute.

Funny thing about Dreamweaver, the width attribute is NOT valid for XHTML 1.0 Strict nor is it valid for XHTML 1.1, yet if you create a table in a document set to one of those types, Dreamweaver still sticks in the width attribute when you resize the columns. When you run the validator, you are shown the table you inserted is using outdated attributes. VS 2005 will underline outdated attributes and show a tooltip explaining why. I’m surprised Dreamweaver doesn’t do that, but more surprised that it inserts code that won't validate.

No comments:

Post a Comment