css - Style Header Title Based on Column Cell Type -


i have table filled cells css classes string , currency. want headers of string columns left aligned, , headers of currency columns right aligned.

is there way purely css?

in following code, strings header left aligned , currency header right aligned, , should know detecting class type of cells in column.

note: cells in single column (under header) share same class type. there no mixing , matching.

<table>     <thead>         <tr>             <th>strings</th>             <th>currency</th>         </tr>     </thead>     <tr>         <td class="string">this string.</td>         <td class="currency">100.00</td>     </tr> </table> 

my idea this:

table td.string thead th { // if cells in column of string type     text-align:left; }  table td.currency thead th { // if cells in column of currency type     text-align:right; } 

i know css above won't work, there css trickery this?

based on given note

note: cells in single column (under header) share same class type. there no mixing , matching. 

you can try changes in html , css achive this.

html:

<table>         <thead>             <tr>                 <th class="string">                     strings                 </th>                 <th>                     currency                 </th>             </tr>         </thead>         <tr class="currency">             <td class="string">                 string.             </td>             <td class="currency">                 100.00             </td>         </tr>     </table> 

css:

 .string          {             text-align: left;         }          .currency         {             text-align: right;         } 

hope :)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -