Posts in current category

HTML5 <colgroup> tag


May 03, 2021 13:20 HTML5


Table of contents


HTML5 and colgroup,tags can be combined with .lt;col.gt; tags.

The labels set the background color for the three columns in the table:

 <table border="1">
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table> 
Try it out . . .

Browser support

HTML5 <colgroup> tag HTML5 <colgroup> tag HTML5 <colgroup> tag HTML5 <colgroup> tag HTML5 <colgroup> tag

All major browsers support the hashtag.


Label definition and instructions for use

The label is used to combine columns in a table to format them.

You can apply styles to the entire column without having to repeatedly style each cell or row by using the label.

Note: Labels can only be used within the element, after any one of the elements, in any one of the elements.

Tip: If you would like to define a different property for a column in the .


The difference between HTML 4.01 and HTML5

Most of the properties in HTML 4.01 are no longer supported in HTML5.


Property

Property Value Describe
align (abandoned)
left
right
center
justify
char
HTML5 is not supported. Specifies the horizontal alignment of content in a column combination.
char (abandoned) character HTML5 is not supported. Specify which characters to align the contents of a column group.
Charoff (abandoned) number HTML5 is not supported. Specifies the offset of the first aligned character.
span number Specifies the number of columns that a column group should span.
valign (abandoned) top
middle
bottom
baseline
HTML5 is not supported. Defines the vertical alignment of content in column combinations.
width (abandoned) pixels
%
relative_length
HTML5 is not supported. Specifies the width of the column combination.


Global properties

The label supports the global properties of HTML.


The event property

The tag supports the event properties of HTML.