It should be added that if the browser sets the default attribute, you may need a workaround. This doesn't seem to be a problem in “modern” browsers, but it is a problem that I have encountered, so be sure to check the performance in different browsers.
For example, I found that in IE up to 9 colSpan is set for all TDs in the table, so any single cell has a hidden colspan of 1.
Therefore, if you are targeting "any TD with the colspan attribute" that you use in your web document, even td that does not have the colspan attribute set, for example, any TD that is a separate cell will get a CSS style. IE less than 9 will be basically their style!
The only reason for concern about this is all other XP users who cannot upgrade above IE8.
For example, I have a group of tables whose contents can change from end to end, leaving 1 to 7 cells empty at the end or at the beginning.
I want to apply color to any empty cells at the end or beginning using the colspan attribute. Using the following will not work in IE less than 9
#my td[colspan] {background-color:blue;}
... all TDs will be stylized (funny, since styling conditional attributes in IE is supposedly better, but I digress ...).
Using the following works in all browsers when I set the colspan value to 'single' for any single cell / TD that I want to include in the stylesheet, however this is a “hack” and will not be checked correctly ...
#my td[colspan="single"] {background-color:blue;} #my td[colspan="2"] {background-color:blue;} #my td[colspan="3"] {background-color:blue;} #my td[colspan="4"] {background-color:blue;} #my td[colspan="5"] {background-color:blue;} #my td[colspan="6"] {background-color:blue;} #my td[colspan="7"] {background-color:blue;}
Alternatively, you should be able to more adequately solve the problem using conditional styles, using "if lt IE 9" to override. That would be the right way to do this, just keep in mind that in the process you have to hide the “properly built CSS” from IElt9, and I think that the only right way to do this is with custom stylesheets.
In any case, most of us are already doing this, but nevertheless, you should still think and check if the browser uses an auto-attribute when it does not see it, and how it can process your rest of the syntax to style the attribute values.
(By the way, colspan is simply not yet specified in the css specification [as of css3], so in this example, a validation error is not generated.)