CSS クラスstringおよびcurrencyのセルで満たされたテーブルがあります。文字列列のヘッダーを左揃えにし、通貨列のヘッダーを右揃えにします。
純粋にCSSでこれを行う方法はありますか?
次のコードでは、Stringsヘッダーが左揃えになり、Currencyヘッダーが右揃えになります。その列のセルのクラス タイプを検出することで、これを認識する必要があります。
注: 1 つの列 (ヘッダーの下) 内のすべてのセルは、同じクラス タイプを共有します。混同はありません。
<table>
    <thead>
        <tr>
            <th>Strings</th>
            <th>Currency</th>
        </tr>
    </thead>
    <tr>
        <td class="string">This is a string.</td>
        <td class="currency">100.00</td>
    </tr>
</table>
私の考えは次のようなものです:
table td.string thead th { // if cells in column are of string type
    text-align:left;
}
table td.currency thead th { // if cells in column are of currency type
    text-align:right;
}
上記の CSS が機能しないことはわかっていますが、このようなことを行う CSS トリックはありますか?