DEV Community

Cover image for HTML tags | colgroup-col
Carlos Espada
Carlos Espada

Posted on • Updated on

HTML tags | colgroup-col

They are used to define groups of columns within a table. <colgroup> defines the total group of columns and <col> defines each of the columns in the group. It is useful for applying styles to entire columns, rather than repeating them for cells and in each row.

<colgroup> must be a child of a <table> element, after <caption> and before <thead>, <tbody>, <tfoot>, <tr> and <th>. It has a span attribute, which will contain a positive integer indicating the number of consecutive columns it spans. If not present, its default value is 1. This attribute cannot be used if the <colgroup> contains one or more <col> elements.

<col> has to be a child of a <colgroup> element. Like its parent, it has a span attribute that will contain a positive integer indicating the number of consecutive columns it spans. If it is not present, its default value is 1.

  • Type: table-column-group / table-column
  • Self-closing: No / No
  • Semantic value: No / No

Definition and example <colgroup> - Definition and example <col> | Support <colgroup> - Support <col>

Top comments (0)