html - CSS: Table multiple column widths -


here's code:

<table> <col style="width:10px"><col style="width:20px"><col style="width:30px"> <td> .... 

which defines 3 columns of different widths. there way define css layout whole table - 3 comumns - in 1 single entry, can write:

<table class="cols3"> ... 

and cols3 class define table has 3 columns of predefined width? thank you.

you can use nth-child selector on child columns, css might this:

.cols3 col:nth-child(1){width:10px;} .cols3 col:nth-child(2){width:20px;} .cols3 col:nth-child(3){width:30px;} 

be aware nth-child selector, 1 used first child element, not typical 0.


Comments