13.7.1. A Simple Announcement Box
Figure 13-21 depicts a
simple one-cell table containing text. By setting the background to a
bright color, it can be used as an effective attention-getting device
for a special announcement. It could also be used as an alternative
to a graphical headline for a page. By using the
align attribute in the
<table> tag, you can position the table
along the left or right margin and allow text to wrap around it,
making a nice space for a sidebar or callout.
You can use width and height
attributes to make the bar any size. Try playing with the border and
cell padding for different effects. Remember, placing the
bgcolor within the cell will render differently
than placing it in the <table> tag in
Internet Explorer, so experiment and test to see what you like the
best. Note that because height is a nonstandard
attribute, it may not work in all browsers (including Version 6
browsers operating in "strict" rendering mode).
Figure 13-21. Announcement box
13.7.4. Creating a Box Rule
Although Microsoft Internet Explorer
recognizes the proprietary bordercolor,
bordercolorlight, and
bordercolordark attributes, there is no method for
specifying border colors using standard HTML for all browsers.
To create a colored rule around a box of text using standard HTML,
place one table within another as shown in Figure 13-24. To nest tables, place the entire contents of
one table within a <td> of the other.
Figure 13-24. Two examples of creating box rules with nested tables
In Example 1 in Figure 13-24, cell width and height
are set in the interior table. In the exterior table, a cell padding
of 0 results in a one-pixel rule around the table. You can increase
the thickness of the rule by increasing the
cellpadding value. Note, however, that this will
also increase the overall dimensions of the table. The color of the
rule is specified by the
bgcolor attribute
in the <table> tag for the exterior table:
<TABLE CELLPADDING=0 BORDER=0>
<TR>
<TD BGCOLOR="#333333" ALIGN=center VALIGN=center>
<TABLE BORDER=0 WIDTH=200 HEIGHT=200 CELLPADDING=10>
<TR><TD BGCOLOR="#999999">cell contents</TD></TR>
</TABLE>
</TD>
</TR>
</TABLE>
In Example
2 in Figure 13-24, to restrict the dimensions of the
table, set specific dimensions for the exterior table and set the
dimensions of the interior table slightly smaller (to a difference
twice the desired rule thickness). In this example, the desired rule
thickness is 10, so the interior table's dimensions are 20
pixels less than the exterior table's dimensions.
<TABLE WIDTH=200 HEIGHT=200 cellpadding=0 border=0>
<TR>
<TD BGCOLOR="#333333" ALIGN=center VALIGN=center>
<TABLE BORDER=0 WIDTH=180 HEIGHT=180 CELLPADDING=10>
<TR><TD BGCOLOR="#999999">cell contents</TD></TR>
</TABLE>
</TD>
</TR>
</TABLE>