HTML - <col> Tag



Description

The HTML <col> tag allows authors to group together attribute specifications for table columns. It does not group columns together structurally -- that is the role of the <colgroup> element.

The elements are empty and serve only as a support for attributes.

Example

<!DOCTYPE html>
<html>

   <head>
      <title>HTML col Tag</title>
   </head>

   <body>
      <p>This example shows a colgroup that has three columns of different widths:</p>
      <table border = "1">
         <colgroup span = "3">
            <col width = "50"></col>
            <col width = "100"></col>
            <col width = "150"></col>
            <col width = "50"></col>
         </colgroup>
         
         <tr>
            <td>col 1</td>
            <td>col 2</td>
            <td>col 3</td>
            <td>col 4</td>
         </tr>
      </table>
   </body>

</html>

This will produce the following result −

Global Attributes

This tag supports all the global attributes described in HTML Attribute Reference

Specific Attributes

The HTML <col> tag also supports the following additional attributes −

Attribute Value Description
align right
left
center
justify
char
Defines horizontal alignment, not supported in Html5.
char character Defines a character to use to align text on (use with align = "char"), not supported in Html5.
charoff pixel Specifies an alignment offset (either in pixels or percentage value) against the first character as specified with the char attribute, not supported in Html5.
span number Defines the number of columns the <col> should span, not supported in Html5.
valign bottom
middle
top
baseline
Defines vertical alignment, not supported in Html5.
width pixels or % Specifies a default width for each column spanned by the current col element, not supported in Html5 .

Event Attributes

This tag supports all the event attributes described in HTML Events Reference

Browser Support

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes ?
html_tags_reference.htm
Advertisements