I have a table with 7 columns. I want the columns to have the following width:
- 3 columns x
width=20%
- 4 columns x
width=10%
I created 2 CSS classes, one per width, and assign them to each cell.
What I have and it does not work. Instead, width always wraps the content. If I just put one letter, the width will be very small, if I overlap a large string, the width will be too large. I want him to be permanent.
CSS and HTML:
table { width: 100%; } .ten { width: 10% } .twenty { width: 20%; }
<table> <tr> <th class="ten">H1</th> <th class="ten">H2</th> <th class="ten">H3</th> <th class="twenty">H4</th> <th class="twenty">H5</th> <th class="twenty">H6</th> <th class="ten">H7</th> </tr> <tr> <td class="ten">A1</td> <td class="ten">A2</td> <td class="ten">A3</td> <td class="twenty">A4</td> <td class="twenty">A5</td> <td class="twenty">A6</td> <td class="ten">A7</td> </tr> <tr> <td class="ten">B1</td> <td class="ten">B2</td> <td class="ten">B3</td> <td class="twenty">B4</td> <td class="twenty">B5</td> <td class="twenty">B6</td> <td class="ten">B7</td> </tr> </table>
Can someone explain how to achieve what I want?
source share