How to select an element that doesn't have a child or contains a particular element

how can i select an element in css if it doesn't have or contain a particular element for example

<style>
 /* 
this is not selecting the category container if it doesn't have a child element with a class of category
 */
  .category-container:has(>:not(.category)){
    background-color:red;
  }
</style>
<div class="category-container">
  <div class="category"></div>
</div>

i want to match an element with a class called
category-container
and doesn't have a child element with a class called
category
Was this page helpful?