Microsoft® Internet Explorer 5 gives the author more control over table presentation. Significantly faster rendering is now possible. Using this layout, authors can increase table rendering speeds by several orders of magnitude, particularly for longer, more complex tables.
Authors can also manipulate what table information reaches users, as well as when and how it is displayed. To this end, the author can now collapse rows and cells, render table content invisible, and join shared borders. These key features accord with the Cascading Style Sheets specification, keeping Internet Explorer the leader in standards support.
This overview examines all of these new features and suggests how they may be combined with other techniques available for enhancing table presentation.
Presentation is further improved by taking advantage of the new borderCollapse and tableLayout properties. Each of these properties adds performance gains to table rendering. With user patience usually measured in seconds, this speed is vital for delivering information to users before they move on to another page. Using the tableLayout property can easily halve the time for rendering of large tables. Faster rendering is possible with even larger tables.
Table rendering performance can be increased by specifying the tableLayout property. This property causes Internet Explorer to incrementally render the table, providing users with information at a faster pace. Using the tableLayout property, the layout of a table is determined in the following order:
<TABLE STYLE="table-layout:fixed" WIDTH=600> <COL WIDTH=100><COL WIDTH=300><COL WIDTH=200> <TR HEIGHT=20> <TD>...</TD><TD>...</TD><TD>...</TD> </TR> : </TABLE>
The performance gains are significant, especially for large tables. Because the browser does not need to parse through the table once simply to lay it out, the table rows can start to render immediately. Click the button to view a demonstration of this rendering gain.
Take care in choosing the column width. Cell content that exceeds the width of the column is wrapped, if possible, or clipped if the content cannot be wrapped. If row height has been set, the wrapped text will be clipped where it exceeds the height restriction. If data sources are dynamically bound to the table through data binding, consideration of all the content that may appear is especially important.
Too much information can confuse or distract your readers. To aid your readers and improve their comprehension of important data, you can selectively show information or you can enable the user to selectively view information. A number of techniques are available to achieve this end.
Hiding the full table itself is the most basic means of hiding data. This full table hiding has been available to authors since Internet Explorer 4. Using the display property, the entire table may be hidden and its physical space eliminated in the layout. Choosing the visibility property, on the other hand, hides the table but preserves its space in the layout.
The display and visibility properties can be limited to rows and cells. Using the display property, rows can be collapsed out of view. If, instead, you desire the space occupied by the row or cell to show, but not the information, apply the visibility property. Changing the visibility through scripting is useful for showing and hiding overlapping content based on user interaction. Note that for a child element to be visible, the parent element must also be visible. For style scripting information, see Dynamic Styles.
Note that similar functionality is available through the data-binding filtering mechanism. Data binding may be a more appropriate choice where scalability is important. For more information, see Data Binding.
<SCRIPT> function getPets() { tblChoice1.style.display="none"; tblChoice2.style.display=""; tblChoice3.style.display="none"; } </SCRIPT> : <TABLE> <TR ID="tblChoice1"> <TD>Horses</TD><TD ID="tblChoice1_1">Thoroughbreds</TD><TD>Fast</TD> </TR> <TR ID="tblChoice2"> <TD>Dogs</TD><TD ID="tblChoice2_1">Greyhounds</TD><TD>Fast</TD> </TR> <TR ID="tblChoice3"> <TD>Marsupials</TD><TD ID="tblChoice3_1">Opossums</TD><TD>Slow</TD> </TR> </TABLE> : <INPUT TYPE=button onclick="getPets()" VALUE="Show household pets">
Note that the author may use inline scripting to achieve the same result by replacing the onclick call in the last line above with:
onclick = "tblChoice1.style.display= 'none'; tblChoice2.style.display= ''; tblChoice3.style.display= 'none'"
<SCRIPT> function getFast() { tblChoice1_1.style.visibility="visible"; tblChoice2_1.style.visibility="visible"; tblChoice3_1.style.visibility="hidden"; } </SCRIPT> : <TABLE> <TR> <TD>Horses</TD><TD ID="tblChoice1_1">Thoroughbreds</TD><TD>Fast</TD> </TR> <TR> <TD>Dogs</TD><TD ID="tblChoice2_1">Greyhounds</TD><TD>Fast</TD> </TR> <TR> <TD>Marsupials</TD><TD ID="tblChoice3_1">Opossums</TD><TD>Slow</TD> </TR> </TABLE> : <INPUT TYPE=button onclick="getFast()" VALUE="Show fast pets">
<TABLE STYLE="table-layout:'fixed'"> <COL WIDTH=100><COL WIDTH=150><COL WIDTH=150> <TR> <TD>EST</TD><TD>9:00 a.m.</TD><TD>5:00 p.m.</TD> </TR> <TBODY ID=tblTB_1> <TR> <TD>CST</TD><TD>8:00 a.m.</TD><TD>4:00 p.m.</TD> </TR> </TBODY> <TBODY ID=tblTB_2> <TR> <TD>MST</TD><TD>7:00 a.m.</TD><TD>3:00 p.m.</TD> </TR> </TBODY> <TR> <TD>PST</TD><TD>6:00 a.m.</TD><TD>D2:00 p.m.</TD> </TR> </TABLE> <P> : <BUTTON onclick="tblTB_1.style.display='none';tblTB_2.style.display=''"> Hide CST</BUTTON> <BUTTON onclick="tblTB_1.style.display='';tblTB_2.style.display='none'"> Hide MST</BUTTON>
The advantage here is in the coding: setting the visibility property on each row in a large table is cumbersome. Leveraging the TBODY object accomplishes this goal with less script.
Authors can also collapse interior borders to keep a consistent width on all the borders in the table. Although borders should not overwhelm the data itself, traditional table rendering results in double-width borders between cells. Internet Explorer 5 allows you to maintain a consistent border width throughout the table.
<TABLE ID=id1 STYLE="border-collapse:collapse"> <TR><TD>EST</TD><TD>9:00 a.m.</TD></TR> <TR><TD>CST</TD><TD>8:00 a.m.</TD></TR> <TR><TD>PST</TD><TD>6:00 a.m.</TD></TR> </TABLE>
Authors now can show tables emulating the thin border lines used in Microsoft® Excel, as shown in the following table (the collapsed borders will only be evident if you are using Internet Explorer 5).
EST | 9:00 a.m. | 5:00 p.m. |
CST | 8:00 a.m. | 4:00 p.m. |
PST | 7:00 a.m. | 2:00 p.m. |
The look of the preceding table is achieved using the following embedded style sheet:
<STYLE> TD {border:'thin black solid'} </STYLE>
The same table without collapsed borders (that is, in standard HTML) uses more space between the cells in order to render the detached borders.
EST | 9:00 a.m. | 5:00 p.m. |
CST | 8:00 a.m. | 4:00 p.m. |
PST | 6:00 a.m. | 2:00 p.m. |
Not only do authors have a new choice between these two styles of borders, additional styles can be attached to either using the CSS border properties made available in Internet Explorer 4.0.
When a page containing a table is printed, the CSS attributes page-break-before and page-break-after can be used to specify where in a table the break should occur. This is helpful for Web sites that implement large tables to organize pages. In addition, the display property exposes the table-header-group and table-footer-group possible values, which specify that the THEAD or TFOOT objects are always before or after any table rows. Using these possible values for the THEAD and TFOOT objects specifies that the header and footer will print on every page that a particular table spans.