DEV Community

Share Point Anchor
Share Point Anchor

Posted on • Originally published at sharepointanchor.com on

HTML <col> Column Tag

In an HTML document, the Column tag used for specifying the properties of one or more columns. This tag is generally used within an element.

Estimated reading time: 3 minutes

Syntax:

The

tag does not contain the closing tag. But in XHTML , it contains both opening and closing tags.

<col attribute="value">

Enter fullscreen mode Exit fullscreen mode

HTML Tag:

th, td{ padding: 20px; }

| HTML

tag | Used to specify the properties of one or more columns. |
| Content categories | None |
| Permitted content | None, It is an empty element. |
| Tag omission | It must have an opening tag, but does not require a closing tag. |
| Permitted parents | tag |
| Implicit ARIA role | No corresponding role |
| Permitted ARIA roles | No role permitted |
| DOM interface | HTML TableColElement. |

Sample of HTML Tag:

Here is the example for HTML column tag:


<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      table, th, td {
        border: 1px solid #666;
      }
    </style>
  </head>
  <body>
<h3>Sample of HTML <col> Tag</h3>
    <table>
      <colgroup>
        <col span="2" style="width:20%; background-color:#eee;">
        <col style="width:10%; background-color:#F5bf42;">
      </colgroup>
      <thead>
        <th>Name</th>
        <th>Gender</th>
        <th>Age</th>
      </thead>
      <tr>
        <td>Bella Smith</td>
        <td>Female</td>
        <td>19</td>
      </tr>
      <tr>
        <td>Jack Johnson</td>
        <td>Male</td>
        <td>23</td>
</tr>
    </table>
  </body>
</html>

Result:

Result

Download Sample File:

HTML-Column-TagDownload

Attributes:

The tag supports the global attributes and the event attributes.

th, td{ padding: 20px; }

element to a character. It is used only if the attribute is aligned = “char”.** Not supported in HTML5.**element. The number must be a positive integer. If the parameter is not specified, the default value is 1.
Attribute Value Description
align The align attribute will help to set the alignment of the content of the column. Not supported in HTML5.
left It aligns to the left.
right Used to the right alignment.
center Helps to align the center.
justify This value helps to stretch the lines so that each line has equal width.
char It is used to align a special character with a minimum offset , which is defined by the “char” and “charoff” attributes.
char character This value will align the content related to an
charoff number Helps to shift the content of the cell relative to the character specified as the value of the attribute to the right (positive values) or to the left (negative values). It is used only if the attribute is aligned = “char”.** Not supported in HTML5.**
span number Sets the quantity of columns , the properties of which are determined by the
valign The “valign” attribute helps to align the content vertically.
top It helps to align at the top of the line.
bottom This value used to align the bottom edge.
middle Used for center or middle alignment.
baseline This value is used for baseline alignment. Not supported in HTML5.
width % pixels relative_length It will set the width of the column. Not supported in HTML5.

Browser Support:

Browser Support

Related Articles:

The post HTML Column Tag appeared first on Share Point Anchor.

Top comments (0)