HTML-<colgroup> Tag
Definition und Verwendung
<colgroup>
Das Tag wird verwendet, um das Format der Gruppen, die eine oder mehrere Spalten in einer Tabelle enthalten, zu definieren.
Um Stile für alle Spalten anzuwenden,<colgroup>
Das Tag ist sehr nützlich, da es nicht erforderlich ist, die Stile für jede Zelle und jede Zeile wiederholt anzuwenden.
Hinweis:<colgroup>
Das Tag muss <table>
der Nachkommen des Elements, located before any <caption>
nach dem Element und jedem <thead>
、<tbody>
、<tfoot>
und <tr>
vor dem Element.
Hinweis:Um <colgroup>
Um unterschiedliche Attribute für eine bestimmte Spalte zu definieren, geben Sie bitte <colgroup>
Im Tag verwendet <col>-Tag.
Weitere Informationen:
HTML Referenzhandbuch:<col>-Tag
HTML DOM Referenzhandbuch:ColumnGroup-Objekt
Beispiel
Die Hintergrundfarbe der drei Spalten wird mit den Tags <colgroup> und <col> festgelegt:
<table> <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>HTML Basics</td> <td>$53</td> </tr> </table>
Attribute
Attribute | Value | Description |
---|---|---|
span | Number | Specifies the number of columns the column group should span. |
Global Attributes
<colgroup>
The tag also supports Global Attributes in HTML.
Event Attributes
<colgroup>
The tag also supports Event Attributes in HTML.
Default CSS Settings
Most browsers will display the following default values <colgroup>
Element:
colgroup { display: table-column-group; }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |