-- Learn More Than Just Technology, But Also Your Dreams!
HTML width Attribute
Definition and Usage:
In HTML5, the <colgroup> width attribute is not supported.
The width attribute specifies the width of a column group.
Usually, the space taken up by a column group is the amount needed to display its contents. The width attribute can be used to set a predefined width for a column group.
Note: This attribute will be overridden by any width setting in the <col> element.
Syntax:
<colgroup width="pixels|%|relative_length">
Attribute Values:
| Value | Description |
|---|---|
| pixels | Sets the width value in pixels (e.g., width="50"). |
| % | Sets the width value as a percentage of the enclosing element (e.g., width="50%"). |
| relative_length | Distributes available pixels among parts. Part one is set to "1*", part two is set to "2*". (For example, if the table's width is 100px, the first column group is 20px, and the second column group is 50%, then the remaining available pixels are 30px.) |
Example:
| Month | Savings |
|---|---|
| January | $100 |
| February | $80 |
Browsers Support
All mainstream browsers support the width attribute. However, no browser supports the relative_length value.
YouTip