Search code examples
htmlcssfixedword-wrap

Make column's width fixed and wrap words to next line


I tried to set the width of the two columns fixed :

.thkqgiai{
    width:20% !important;
}

.thkqso{
    width:80% !important;
}

.tdkqgiai{
    text-align:center;
}

.tdkqso{
    text-align:center;
    word-wrap:break-word !important;
}

thkqgiai and tdkqgiai are first column's th and td classes respectively

thkqso and tdkqso are second column's th and td classes respectively

How to I make the columns's width stay fixed, and long text will wrap to the next line?

enter image description here


Solution

  • Simply you need to apply table-layout to be fixed:

    table{
      table-layout: fixed;
    }
    

    By default table-layout is auto.