1
<th style="position: relative; top: 0px;">
    <div style="width: 48.003906px;" data-lngst="nullpx" data-ndx="2">123</div></th>
<th id="" class="abc_naem" nowrap="" style="position: relative; top: 0px;">
    <div style="width: 44.003906px;" data-lngst="nullpx" data-ndx="4">...</div>
<th style="position: relative; top: 0px;">
    <div style="width: 48.003906px;" data-lngst="nullpx" data-ndx="5">123</div></th>
<th id="" class="abc_phase" nowrap="" style="position: relative; top: 0px;">
    <div style="width: 44.003906px;" data-lngst="nullpx" data-ndx="3">...</div>

how do I select all 'th' element using css selectors that do not have a classname? All the 'th' elements have exactly the same attributes except classname and I need the ones without it. I tried th[classname=''] and that does not do the trick. I tried all the css selection options like 'no-child' etc, still it always returns all th elements

1 Answer 1

3

Assuming your HTML is properly formed, you can use :not() with the attribute selector []. Ex th:not([class])

Example:

th:not([class]) {
  color: red;
}
<table>
  <tr>
    <th style="position: relative; top: 0px;">
      <div style="width: 48.003906px;" data-lngst="nullpx" data-ndx="2">123</div>
    </th>
    <th id="" class="abc_naem" nowrap="" style="position: relative; top: 0px;">
      <div style="width: 44.003906px;" data-lngst="nullpx" data-ndx="4">123</div>
      <th style="position: relative; top: 0px;">
        <div style="width: 48.003906px;" data-lngst="nullpx" data-ndx="5">123</div>
      </th>
      <th id="" class="abc_phase" nowrap="" style="position: relative; top: 0px;">
        <div style="width: 44.003906px;" data-lngst="nullpx" data-ndx="3">123</div>
      </th>
  </tr>
</table>

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so ,much!!! I was tryingth:not(class) and with your example, i realized, it has to be th:not([class])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.