HTML | <colgroup> width Attribute
The HTML <colgroup> width Attribute is used to specify the width of the colgroup element. The <colgroup> attribute sets a predefined width of column group.
Syntax:
<colgroup width="pixels|%|relative_lngth">
Attribute Values:
- pixels: It specify the width of the colgroup in terms of pixels.
- %: It specify the width of the colgroup element in percent. For ex-width=”50%”
- relative_length: It divides the length of the table in terms of pixels.
Example:
<!DOCTYPE html> <html> <head> <title> HTML ColumnGroup width Attribute </title> <style> #myColGroup { background: green; } table { color: white; background: yellow; } #Geek_p { color: green; font-size: 30px; } td { padding: 10px; } </style> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>HTML ColumnGroup width Attribute</h2> <table> <colgroup id="myColGroup" span="3" align = "left" width="150"> </colgroup> <tr> <th>S.No</th> <th>Title</th> <th>Geek_id</th> </tr> <tr> <td>Geek_1</td> <td>GeekForGeeks</td> <th>Geek_id_1</th> </tr> <tr> <td>Geek_2</td> <td>GeeksForGeeks</td> <th>Geek_id_2</th> </tr> </table> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browsers supported by <colgroup> width attribute are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | <col> width Attribute
- HTML | <th> width Attribute
- HTML | <col> width Attribute
- HTML | <hr> width Attribute
- HTML | <pre> width Attribute
- HTML | <img> width Attribute
- HTML | <td> width Attribute
- HTML <video> width Attribute
- HTML | Marquee width attribute
- HTML | <input> width Attribute
- HTML | <embed> width Attribute
- HTML | <canvas> width Attribute
- HTML | <object> width Attribute
- HTML | <iframe> width Attribute
- HTML | <table> width Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



