Colspan and Appearance

The colspan attribute that you can use with tables has nothing whatever to do with how the table looks. Any affect that the attribute has on the table's appearance is purely a side effect of the browser's interpretation of that part of the table contents.

Let's consider an example.

<td colspan="3">A</td>

This tag is almost identically equivalent to the following HTML.


The only difference between these two is that the second will always display the content of the three cells separately whereas in most browsers the first will ahow the value once spread across the three cells.

The only effective difference that the first of these alternatives has with respect to the page content is that it is clearly specifying that the exact same content applies to all three cells whereas with the second version there is nothing to indicate that the content of the three cells are the same unless you actually compare their content.

While the colspan version usually just displays the value once across the three cells thre is no reason why some browsers (particularly those that speak rather than display the page content) cannot interpret the colspan as being a shortcut way specifying the content of the three cells (or however many that the colspan spans).

The attribute should therefore only ever be used for the meaning that it has with respect to the actual content of the table and should never be used in trying to achieve any particular appearance within the page. After all it is the CSS that is meant to determine how the web page should look. The purpose of HTML including the colspan attribute is to define the content of the web page and all that using colspan="3" means is that the three cells share the same value. How the browser actually renders the cells is for the browser and the CSS to determine.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow