Table Colgroup Span Column Styling
Apply column level styling and spanning using colgroup and col elements for efficient table layout control.
Code
<table>
<colgroup>
<col style="width: 200px; background: #f0f0f0;" />
<col span="2" style="text-align: right;" />
<col style="width: 100px;" />
</colgroup>
<thead>
<tr><th>Name</th><th>Price</th><th>Qty</th><th>Total</th></tr>
</thead>
<tbody>
<tr><td>Widget</td><td>$10</td><td>5</td><td>$50</td></tr>
<tr><td>Gadget</td><td>$25</td><td>3</td><td>$75</td></tr>
</tbody>
</table>What the code does
<colgroup>/<col> apply column-level width and styling without repeating attributes on every cell.
Statements that matter
<col style="width: 200px; background: #f0f0f0;" />
<col span="2" style="text-align: right;" />
<col style="width: 100px;" />
Interactive Tools for This Topic
CSS to Tailwind ConverterConvert standard CSS layout, spacing, typography, border, and color declarations into Tailwind utility classes along with unmapped property notes.CSV Column AnalyzerProfile every CSV column with inferred types, empty-cell counts, unique values, and numeric min and max ranges.
FAQ
- Which non-generic elements does the markup use?
- `<table>`, `<colgroup>`, `<col>`, `<thead>`, `<tr>`, `<th>`, `<tbody>`, `<td>` — each carries native semantics (or a browser behavior) that generic containers do not.
Report a problem with this exampleOpens a pre-filled issue on GitHub.