HTML CSS examples for HTML Tag:colgroup
The span attribute defines the number of columns a <colgroup> element should span.
Value | Description |
---|---|
number | Sets the number of columns a column group should span |
The following code shows how to Set the background color of the first two columns using the <colgroup> span attribute:
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style><!--from w ww. java 2 s . c o m--> </head> <body> <table> <colgroup span="2" style="background:red"></colgroup> <tr> <th>ISBN</th> <th>Title</th> <th>Price</th> </tr> <tr> <td>1</td> <td>My first HTML</td> <td>$1</td> </tr> <tr> <td>2</td> <td>My first CSS</td> <td>$2</td> </tr> </table> </body> </html>