get a TABLE tag's CAPTION tag to shrink to fit its contents - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Caption

Description

get a TABLE tag's CAPTION tag to shrink to fit its contents

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">
caption>span {
   background:Chartreuse;
   padding:0 5px;
}

th {<!--   w w w  .ja  va 2s.c o  m-->
   padding:6px;
   border:3px solid yellow;
   background:blue;
   color:pink;
   text-align:center;
}

td {
   border:OrangeRed;
   padding:6px;
}
</style> 
 </head> 
 <body> 
  <table> 
   <caption> 
    <span>Lorem ipsum dolor sit amet</span> 
   </caption> 
   <thead> 
    <tr> 
     <th>Lore</th> 
     <th>Lorem</th> 
     <th>Lorem i</th> 
    </tr> 
   </thead> 
   <tbody> 
    <tr> 
     <td>Lorem i</td> 
     <td>Lorem ipsum dolor sit amet, c</td> 
     <td>Lorem ipsu</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials