Ben Monastyrsky Ben Monastyrsky - 4 months ago 21
CSS Question

Target everything except a certain class

<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th {
font-family: arial;
font-weight: normal;
}
</style>
</head>
<body>
<table width="200" height="300">
<tr style="font-weight: bold">
<th>Year</th>
<th>Balance</th>
<th>Interest</th>
</tr>
</table>
</body>


Is there a way to make CSS target everything EXCEPT a certain class?
I would like it to target every th tag EXCEPT a certain class.

Answer

you can use :not

li:not(.different) {
  font-size: 13px;
}

Reference: https://developer.mozilla.org/en/docs/Web/CSS/:not