Maddog's HTML for Real People Chapter 10, Lesson 7


[INDEX] Ch 10, L 7 - Empty Cells and Blank Cells

If you already know the difference between an "empty" and a "blank" cell, and how to specify both in an HTML table, you can skip this lesson.

Occasionally, we want to "fill" a table with a blank cell or empty space. This is important enough for a special lesson. Its application will be more apparent in advanced graphic applications (than for tabular data), but it's useful here, too.

One responsibility of the browser is to manage the alignment of columns, as we've see before. For example, if we have a table of four rows, each with four data, we would expect to see the browser paint a table with four rows and four columns. But what if the second row only had two data? Let's see it:

cell 1cell 2cell 3cell 4
cell 5cell 6
cell 7cell 8cell 9cell 10
cell 11cell 12

The browser left a empty space (but not a blank cell) where the third and fourth data might have been in the second row. But if you look at the fourth row, you'll notice that there are two empty spaces there also. This is because there are two empty cells in that position. In the case of the fourth row, even though the cells were created using the <TD></TD> tag pair, they had no contents, and so they were interpreted by the browser as an empty cell. When the browser encounters an empty cell in a table, or when the browser finds cells missing at the end of a row, it inserts table "space", a kind of neutral placeholder to indicate nothing is there.

Interestingly enough, empty cells (and hence, empty table space) can be sized. This is the case in the second cell of the fourth row, where we embedded the 'WIDTH=75" attribute in the opening <TD> tag of that second cell. As a consequence, the entire second column was widened to accommodate the specified empty cell.

Sometimes, this is not the behavior we want for our table. Sometimes, we want our table to have a blank cell (not an empty cell), so that the browser will paint a cell (instead of table space). In this case, the cell will have a cell border, and occupy a table position like any other cell, but the cell will not have any visible contents. To make a blank cell, we place the Non-Blanking SPace between the cell's opening and closing tags, like so:

<TD></TD> &nbsp;<TD>

That single Non-Blanking SPace now becomes the sole content of that cell, and although you can't see it, it's enough for the browser to recognize that cell as a non-empty or blank cell.

Now let's see some examples and some HTML source code:

HTML Source Code Follows:

<TABLE  BORDER=5>
<TR ALIGN="CENTER"><TD></TD><TH>Y</TH></TR>
<TR ALIGN="CENTER"><TH>X</TH><TD>     4,0</TD></TR>
</TABLE>
<P>
In the following table, the first cell is empty and sized at 50 x 50 pixels:
<P>
<TABLE  BORDER=5>
<TR ALIGN="CENTER"><TD HEIGHT=50 WIDTH=50></TD><TH>Y</TH></TR>
<TR ALIGN="CENTER"><TH>X</TH><TD>     4,0</TD></TR>
</TABLE>
<P>
In the following table, the first cell is a normal whitespace:
<P>
<TABLE  BORDER=5>
<TR ALIGN="CENTER"><TD>     </TD><TH>Y</TH></TR>
<TR ALIGN="CENTER"><TH>X</TH><TD>4,0</TD></TR>
</TABLE>
<P>
In the following table, the first cell is '<B>&nbsp;</B>':
<P>
<TABLE  BORDER=5>
<TR ALIGN="CENTER"><TD>&nbsp;</TD><TH>Y</TH></TR>
<TR ALIGN="CENTER"><TH>X</TH><TD>4,0</TD></TR>
</TABLE>
<P>
The following table is a good example of the use of column and row spanning, and empty space:
<P>
<TABLE BORDER=5 WIDTH=95%>
<CAPTION>REGISTRATION CALL-IN TIMES</CAPTION>
<TR ALIGN=CENTER>
    <TD COLSPAN=2 ROWSPAN=2></TD>
    <TH COLSPAN=3>Last Numeral of SSAN</TH></TR>
<TR ALIGN=CENTER>
    <TH>0-3</TH>
    <TH>4-6</TH>
    <TH>7-9</TH></TR>
<TR ALIGN=CENTER>
    <TH ROWSPAN=4>1st Initial of Last Name</TH>
    <TH>A-F</TH>
    <TD>2 PM- 4 PM</TD>
    <TD>10 AM- 12 PM</TD>
    <TD>10 PM- 12 AM</TD></TR>
<TR ALIGN=CENTER>
    <TH>G-M</TH>
    <TD>8 AM- 10 AM</TD>
    <TD>12 AM- 2 AM</TD>
    <TD>4 PM- 6 PM</TD></TR>
<TR ALIGN=CENTER>
    <TH>N-T</TH>
    <TD>2 AM- 4 AM</TD>
    <TD>6 PM- 8 PM</TD>
    <TD>6 AM- 8 AM</TD></TR>
<TR ALIGN=CENTER>
    <TH>U-Z</TH>
    <TD>12 PM- 2 PM</TD>
    <TD>8 PM- 10PM</TD>
    <TD>4 AM- 6 AM</TD></TR>
</TABLE>
(End of HTML Source Code)

Demonstration Follows:

In the following table, the first cell is empty:

Y
X 4,0

In the following table, the first cell is empty and sized at 50 x 50 pixels:

Y
X 4,0

In the following table, the first cell is a normal whitespace:

Y
X4,0

In the following table, the first cell is '&nbsp;':

 Y
X4,0

The following table is a good example of the use of column and row spanning, and empty space:

REGISTRATION CALL-IN TIMES
Last Numeral of SSAN
0-3 4-6 7-9
1st Initial of Last Name A-F 2 PM- 4 PM 10 AM- 12 PM 10 PM- 12 AM
G-M 8 AM- 10 AM 12 AM- 2 AM 4 PM- 6 PM
N-T 2 AM- 4 AM 6 PM- 8 PM 6 AM- 8 AM
U-Z 12 PM- 2 PM 8 PM- 10PM 4 AM- 6 AM

(Demonstration Ends)

Let's look at our four example tables:


-PREVIOUS- -CHAPTER- -INDEX- -NEXT-

Overseer: Monty Northrup ... maddog@io.com ... leave e-mail ...
...to maddog 'n' miracles homepage...