Col element defines a column within a table and is used for grouping and alignment purposes. It generally is found within a <colgroup>
element.
Attributes
- align
- This attribute specifies horizontal alignment of a cell's contents.
- bgcolor
- Applies a background color to all cells in the column (IE 5.5 only).
- char
- This attribute is used to set the character to align the cells in a column on. Typical values for this include a period (.) when attempting to align numbers or monetary values.
- charoff
- This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the char value.
- span
-
When present, this attribute applies the attributes of the
<col>
element to additional consecutive columns.
- valign
- This attribute specifies the vertical alignment of the text within the cell. Possible values for this attribute are baseline, bottom, middle, and top.
- width
- This attribute specifies a default width for each column in the current column group. In addition to the standard pixel and percentage values, this attribute might take the special form 0*, which means that the width of each column in the group should be the minimum width necessary to hold the column's contents. Relative widths such as 0.5* also can be used.
Example
<table border="1" width="400"> <colgroup> <col align="center"width="150" /> <col align="right" /> </colgroup> <td>This column is aligned to the center.</td> <td>This one is aligned to the right.</td> <tr> <td>!</td> <td>?</td> </tr> <tr> <td>!</td> <td>?</td> </tr> </table>
Notes
Under XHTML 1.0, <col>
requires a trailing slash: <col />
.
This element should appear within a colgroup element, and like that element, it is somewhat of a convenience feature used to set attributes with one or more table columns. In practice, few developers seem to use it.
Element HTML |
---|
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
(Zobacz także: Kategoria HTML) |