HTML and CSS Reference
In-Depth Information
10.2.1.9. The cols attribute
To format a table, the browser must first read a table's entire content to
determine the number and width of each column in the table. This can
be a lengthy process for long tables, forcing users to wait to see your
pages. The nonstandard
cols
attribute tells the browser, in advance,
how many columns to expect in the table. The value of this attribute is
an integer value defining the number of columns in the table.
The
cols
attribute only advises the browser. If you define a different
number of columns, the browser is free to ignore the
cols
attribute in
order to render the table correctly. In general, it is good form to include
this attribute with your
<table>
tag, if only to help the browser do a
faster job of formatting your tables.
10.2.1.10. The valign and nowrap attributes
The
valign
attribute sets the default vertical alignment of data in cells
for the entire table. Acceptable values for the
valign
attribute in
<table>
are
top, bottom, middle
, and
baseline
; the default vertical position is the
center of the cell.
Browsers treat each table cell as though it's a browser window unto it-
self, flowing contents inside the cell as they would common body con-
tents (although they are subject to special table-cell alignment proper-
ties). Accordingly, the browsers automatically wrap text lines to fill the
allotted table cell space. The
nowrap
attribute, when included in the
<t-
able>
tag, stops that normal word wrapping in all rows in the table. With
nowrap
, the browser assembles the contents of the cell onto a single line,
unless you insert a
<br>
or
<p>
tag, which then forces a break so that
the contents continue on a new line inside the table cell.
With the
<table>
tag, only Opera supports
valign
. None of the browsers
supports
nowrap
at that level. Instead, you can achieve similar effects by
including a
valign
or
nowrap
attribute within the individual
<tr>, <td>
,
and
<th>
tags, an approach that all the popular browsers support.