set word break in table th or td, when column and table-layout auto using CSS - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Column

Description

set word break in table th or td, when column and table-layout auto using CSS

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
div {<!--from ww w . j ava  2  s . com-->
   overflow:hidden;
}

table {
   table-layout:auto;
}

table, th, td
 {
   text-align:left;
   white-space:nowrap;
   text-overflow:ellipsis;
}
</style> 
 </head> 
 <body> 
  <div style="width:400px; border: 1px solid red; background-color:lightgrey;"> 
   <table> 
    <thead> 
     <tr> 
      <th>Lorem </th> 
      <th style="width:100%">Lore</th> 
      <th style="width:100%">Lor</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lorem ipsum do</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit amet,</td> 
     </tr> 
    </tbody> 
   </table> 
  </div> 
  <p></p> 
  <div style="width:400px; border: 1px solid red; background-color:lightgrey;"> 
   <table> 
    <thead> 
     <tr> 
      <th>Lorem </th> 
      <th style="width:100%">Lore</th> 
      <th style="width:100%">Lor</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lorem ipsum do</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit</td> 
     </tr> 
     <tr> 
      <td>Lo</td> 
      <td>Lore</td> 
      <td>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorp</td> 
     </tr> 
    </tbody> 
   </table> 
  </div>  
 </body>
</html>

Related Tutorials