<col>

  • Revision slug: HTML/Element/col
  • Revision title: col
  • Revision id: 70810
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 35 words added, 3 words removed

Revision Content

The HTML Col Element (<col>) defines a column within a table and is used for grouping and alignment purposes. It is generally found within a {{ HTMLElement("colgroup") }} element.

Attributes

{{ htmlattrdef("align") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}
This enumerated attribute specifies how horizontal alignment of each column cell content will be handled. Possible values are:
  • left, aligning the content to the left of the cell;
  • center, centering the content in the cell;
  • right, aligning the content to the right of the cell;
  • justify, inserting spaces into the textual context so that the content is justified in the cell;
  • char, aligning the textual content on a special character with a minimal offset, defined by the {{ htmlattrxref("char", "col") }} and {{ htmlattrxref("charoff", "col") }} attributes.
Note:({{ unimplemented_inline() }}: Inline attribute style text-align:value also is not supported.)
{{ htmlattrdef("bgcolor") }} {{ Non-standard_inline() }} {{ unimplemented_inline() }}
Applies a background color to all cells in the column (IE 5.5 only.)  (Note: use CSS and attribute style background-color:value instead)
{{ htmlattrdef("char") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}
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.
{{ htmlattrdef("charoff") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}
This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the char attribute.
{{ htmlattrdef("span") }}
When present, this attribute applies the attributes of the <col> element to additional consecutive columns.
{{ htmlattrdef("valign") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}
This attribute specifies the vertical alignment of the text within the cell. Possible values for this attribute are baseline, bottom, middle, and top. ({{ unimplemented_inline() }}: Inline attribute style vertical-align:value also is not supported.)
{{ htmlattrdef("width") }} {{ Deprecated_inline() }}
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 {{ HTMLElement("colgroup") }}lement, 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>The HTML Col Element (<span style="font-family: Courier New;">&lt;col&gt;</span>) defines a column within a table and is used for grouping and alignment purposes. It is generally found within a {{ HTMLElement("colgroup") }} element.</p>
<h3 name="Attributes">Attributes</h3>
<dl> <dt>{{ htmlattrdef("align") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}</dt> <dd>This enumerated attribute specifies how horizontal alignment of each column cell content will be handled. Possible values are: <ul> <li><span style="font-family: Courier New;">left</span>, aligning the content to the left of the cell;</li> <li><span style="font-family: Courier New;">center</span>, centering the content in the cell;</li> <li><span style="font-family: Courier New;">right</span>, aligning the content to the right of the cell;</li> <li><span style="font-family: Courier New;">justify</span>, inserting spaces into the textual context so that the content is justified in the cell;</li> <li><span style="font-family: Courier New;">char</span>, aligning the textual content on a special character with a minimal offset, defined by the {{ htmlattrxref("char", "col") }} and {{ htmlattrxref("charoff", "col") }} attributes.</li> </ul> <div class="note"><strong>Note:</strong>({{ unimplemented_inline() }}: Inline attribute style <a href="/en/CSS/text-align" title="en/CSS/text-align">text-align</a>:<em><span style='"text-align:&lt;span'>value</span></em> also <strong>is not</strong> supported.)</div> </dd>
</dl>
<dl> <dt>{{ htmlattrdef("bgcolor") }} {{ Non-standard_inline() }} {{ unimplemented_inline() }}</dt> <dd>Applies a background color to all cells in the column (IE 5.5 only.)  (Note: use CSS and attribute style <a href="/en/CSS/background-color" title="en/CSS/background-color">background-color</a>:<em><span style='"background-color:&lt;span'>value </span></em>instead)</dd>
</dl>
<dl> <dt>{{ htmlattrdef("char") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}</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>{{ htmlattrdef("charoff") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}</dt> <dd>This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the <strong>char</strong> attribute.</dd>
</dl>
<dl> <dt>{{ htmlattrdef("span") }} </dt> <dd>When present, this attribute applies the attributes of the <span style="font-family: Courier New;">&lt;col&gt;</span> element to additional consecutive columns.</dd>
</dl>
<dl> <dt>{{ htmlattrdef("valign") }} {{ Deprecated_inline() }}{{ unimplemented_inline("915") }}</dt> <dd>This attribute specifies the vertical alignment of the text within the cell. Possible values for this attribute are <span style="font-family: Courier New;">baseline</span>, <span style="font-family: Courier New;">bottom</span>, <span style="font-family: Courier New;">middle</span>, and <span style="font-family: Courier New;">top</span>. ({{ unimplemented_inline() }}: Inline attribute style <a href="/en/CSS/vertical-align" title="en/CSS/vertical-align">vertical-align</a>:<em><span style='"vertical-align:&lt;span'>value </span></em>also <strong>is not</strong> supported.)</dd>
</dl>
<dl> <dt>{{ htmlattrdef("width") }} {{ Deprecated_inline() }}</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 <span style="font-family: Courier New;">0*</span>, 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 <span style="font-family: Courier New;">0.5*</span> 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, <span style="font-family: Courier New;"><code>&lt;col&gt;</code></span> requires a trailing slash: <span style="font-family: Courier New;"><code>&lt;col /&gt;</code></span>.</p>
<p>This element should appear within a {{ HTMLElement("colgroup") }}lement, 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>
<p>{{ languages( { "pl": "pl/HTML/Element/col" } ) }}</p>
Revert to this revision