Here is a simplified page struture, where I want to select all images inside the "page"-div and enclosed elements, but not those that are in either "keepoffa" or "keepoffb".
<!DOCTYPE html>
<html lang="en">
<body>
<div class="page">
<img/> <!-- OK -->
<div class="keepoffa">
<img/> <!-- never take this-->
</div>
<div class="keepoffb">
<img/> <!-- never take this-->
</div>
<img/> <!-- OK -->
<div class="subpage">
<img/> <!-- OK -->
<ul>
<li>
<img/> <!-- OK -->
</li>
</ul>
</div>
<ul>
<li>
<img/> <!-- OK -->
</li>
</ul>
<div>
</body>
</html>
Here's what I have thought:
.page img:not(.keepoffa):not(.keepoffb) {
max-width: 300px;
}
But the unwanted divs are not excluded.
How to effectively select the images but exclude the images inside those unwanted divs? CSS-only required.