TCS - Excessive Line Break Tags

Excessive Line Break Tags

by Don Singleton
Tulsa Computer Society
From the December 2002 issue of the I/O Port Newsletter

Paula ran across some web site publishing software and asked me to take a look at it, because she could not get it to support tables, and tables are a very basic aspect of HTML, and neither of us could understand why commercial software could not handle them.

We are both still baffled as to why anyone would release commercial software that would not handle tables, but here is an explanation of why it misbehaves when processing tables.

Paula's article involved a lot of graphic images, but in order to make the example small enough to fit on one screen I changed it to tables with just phrases like "Test1" and "Test2" in the table cells. When published it displayed like this. The golden area was not gold, of course, but there was blank space there which should not have been there:

I used the following HTML code:
<table border=1><tr>
<td>Test1</td>
<td>Test2</td>
</tr><tr>
<td>Test2</td>
<td>Test1</td>
</tr></table>
<table border=1><tr>
<td>Test1</td>
<td>Test2</td>
</tr><tr>
<td>Test2</td>
<td>Test1</td>
</tr></table>
<table border=1><tr><td>Test1</td><td>Test2</td></tr>
<tr><td>Test2</td><td>Test1</td></tr></table>
<table border=1><tr><td>Test1</td><td>Test2</td></tr>
<tr><td>Test2</td><td>Test1</td></tr></table>
<p>
Now is the time
for all good men
to come to the aid
of their country
<p>

This code should display like this:

But when I copied the code to the clipboard and pasted it in to the "Full Story" section of their "Article Publisher"

And then when I looked at the published article it displayed like this. The golden area was not gold, of course, but there was blank space there which should not have been there:

The problem was that when the HTML code was pasted into the "Article Publisher", it added the <BR> line break tag at the end of each line, as shown below in red.
<table border=1><tr><BR>
<td>Test1</td><BR>
<td>Test2</td><BR>
</tr><tr><BR>
<td>Test2</td><BR>
<td>Test1</td><BR>
</tr></table><BR>
<table border=1><tr><BR>
<td>Test1</td><BR>
<td>Test2</td><BR>
</tr><tr><BR>
<td>Test2</td><BR>
<td>Test1</td><BR>
</tr></table><BR>
<table border=1><tr><td>Test1</td><td>Test2</td></tr>
<tr><td>Test2</td><td>Test1</td></tr></table>
<table border=1><tr><td>Test1</td><td>Test2</td></tr>
<tr><td>Test2</td><td>Test1</td></tr></table><BR>
<p><BR>
Now is the time<BR>
for all good men<BR>
to come to the aid<BR>
of their country<BR>
<p><BR>

When a web browser interprets this code, it knows that line break tags do not belong between <tr> and <td> or between </td> and <td>, so while it is constructing the table it just processes each of these line break tags, so it skips down seven blank lines before displaying each of the first two tables (the two large areas shown in gold), and one blank line before the next two, and the reason there was not a large space above the next two, or between the two tables, was because I formatted them as one very long line (which is shown above as four shorter lines, so you don't have to scroll horizontally to read it).

Note also that the "Now is the time for all good men to come to the aid of their country" phrase should have displayed as one long line, but because it was presented as four short lines, line break tags were added after each line segment, so it displayed as four short lines.



For more information on the Tulsa Computer Society click here




Tulsa Computer Society 12/02/2002
Don Singleton, President