Select only a single column in a HTML table - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Table Column

Description

Select only a single column in a HTML table

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolor si</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
table, th, td {
   border:2px solid Chartreuse;
}

table th:nth-child(1), table td:nth-child(1) {
   background:green;
   -webkit-touch-callout:none;<!--from ww w. j a v a2 s  .c  o  m-->
   -webkit-user-select:none;
   -khtml-user-select:none;
   -moz-user-select:none;
   -ms-user-select:none;
   -o-user-select:none;
   user-select:none;
}

table th:nth-child(2), table td:nth-child(2) {
   background:blue;
   color:yellow;
   -webkit-touch-callout:all;
   -webkit-user-select:all;
   -khtml-user-select:all;
   -moz-user-select:all;
   -ms-user-select:all;
   -o-user-select:all;
   user-select:all;
}
</style> 
 </head> 
 <body> 
  <h2>Lorem ipsum dolor sit ame</h2> 
  <table> 
   <tbody> 
    <tr> 
     <th class="unselectable">Lorem ips</th> 
     <th class="selectable">Lorem ip</th> 
    </tr> 
    <tr> 
     <td class="unselectable">Lorem</td> 
     <td class="selectable">Lorem i</td> 
    </tr> 
    <tr> 
     <td class="unselectable">Lore</td> 
     <td class="selectable">Lorem i</td> 
    </tr> 
   </tbody> 
  </table>  
 </body>
</html>

Related Tutorials