Do you absolutely require the "contains an .image
" condition? If so, you won't be able to do this since there is no parent selector (see also How do I select an element based on the state of another element in the page with CSS?).
If every classless child element of .main
is guaranteed to contain an .image
and every child element that has a class is guaranteed not to do so, write selectors based on this assumption instead, since you won't be able to construct selectors based on the "contains an .image
" condition. Use a sibling combinator to exclude the first classless element:
.main > div[class], .main > div:not([class]) ~ div:not([class]) {
display: none;
}
But if — and this seems likely — not every classless element is guaranteed to contain an .image
or not every element that has a class is guaranteed not to do so, the answer loops back to "not possible with pure CSS".