<col>

  • Revision slug: HTML/Element/col
  • Revision title: col
  • Revision id: 70798
  • Created:
  • Creator: Ptak82
  • Is current revision? No
  • Comment style

Revision Content

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.

{{ HTML:Element_Navigation() }}

{{ languages( { "pl": "pl/HTML/Element/col" } ) }}

Revision Source

<p><b>Col</b> element defines a column within a table and is used for grouping and alignment purposes. It generally is found within a <code><b>&lt;colgroup&gt;</b></code> element.
</p>
<h3 name="Attributes"> Attributes </h3>
<dl><dt>align </dt><dd> This attribute specifies horizontal alignment of a cell's contents.
</dd></dl>
<dl><dt>bgcolor </dt><dd> Applies a background color to all cells in the column (IE 5.5 only).
</dd></dl>
<dl><dt>char </dt><dd> 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.
</dd></dl>
<dl><dt>charoff </dt><dd> This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the <b>char</b> value.
</dd></dl>
<dl><dt>span </dt><dd> When present, this attribute applies the attributes of the <code><b>&lt;col&gt;</b></code> element to additional consecutive columns.
</dd></dl>
<dl><dt>valign </dt><dd> This attribute specifies the vertical alignment of the text within the cell. Possible values for this attribute are <b>baseline</b>, <b>bottom</b>, <b>middle</b>, and <b>top</b>.
</dd></dl>
<dl><dt>width </dt><dd> 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.
</dd></dl>
<h3 name="Example"> Example </h3>
<pre>    &lt;table border="1" width="400"&gt;

      &lt;colgroup&gt;

    &lt;col align="center"width="150" /&gt;
    &lt;col align="right" /&gt;
      &lt;/colgroup&gt;

      &lt;td&gt;This column is aligned to the center.&lt;/td&gt;
      &lt;td&gt;This one is aligned to the right.&lt;/td&gt;
    &lt;tr&gt;

       &lt;td&gt;!&lt;/td&gt;

       &lt;td&gt;?&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;

       &lt;td&gt;!&lt;/td&gt;

      &lt;td&gt;?&lt;/td&gt;
    &lt;/tr&gt;

    &lt;/table&gt; 
</pre>
<h3 name="Notes"> Notes </h3>
<p>Under XHTML 1.0, <code><b>&lt;col&gt;</b></code> requires a trailing slash: <code><b>&lt;col /&gt;</b></code>.
</p><p>This element should appear within a <b>colgroup</b> 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.
</p><p>{{ HTML:Element_Navigation() }}
</p>{{ languages( { "pl": "pl/HTML/Element/col" } ) }}
Revert to this revision