Can you give an example of 'col'?

QuestionsQuestions8 SkillsProSimple Text ProcessingNov, 29 2025
092

Certainly! The <col> tag is used in HTML to define column properties for an entire column group in a table. Here’s an example that demonstrates how to use the <col> tag along with <colgroup> to style specific columns in a table:

<table>
  <colgroup>
    <col style="background-color: lightblue; width: 100px;" />
    <col style="background-color: lightgreen; width: 200px;" />
    <col style="background-color: lightcoral; width: 150px;" />
  </colgroup>
  <tr>
    <th>Column 1</th>
    <th>Column 2</th>
    <th>Column 3</th>
  </tr>
  <tr>
    <td>Data 1</td>
    <td>Data 2</td>
    <td>Data 3</td>
  </tr>
  <tr>
    <td>Data 4</td>
    <td>Data 5</td>
    <td>Data 6</td>
  </tr>
</table>

In this example:

  • The first column has a light blue background and a width of 100 pixels.
  • The second column has a light green background and a width of 200 pixels.
  • The third column has a light coral background and a width of 150 pixels.

You can adjust the styles and widths as needed for your specific design!

0 Comments

no data
Be the first to share your comment!