It's working, but you're telling the browser that img
elements do have to be wrapped in something. So img
tags directly inside the article
tag will not work, but anything nested e.g. in a div
will:
article *:not(figure) img {
border: 2px solid red;
}
<article>
<img src="//placehold.it/50">
<figure class="x">
<img src="//placehold.it/50">
</figure>
<div>
<img src="//placehold.it/50">
</div>
</article>
What you probably need:
article *:not(figure) img,
article > img{
border: 2px solid red;
}
<article>
<img src="//placehold.it/50">
<figure class="x">
<img src="//placehold.it/50">
</figure>
<div>
<img src="//placehold.it/50">
</div>
</article>
Please, do consider the advice from the comments, and see if your situation doesn't allow for an alternative solution that does not use the *
universal and :not
selector. E.g. this may be a lot simpler:
article img {
border: 2px solid red;
}
article figure img {
border: none;
}
<article>
<img src="//placehold.it/50">
<figure class="x">
<img src="//placehold.it/50">
</figure>
<div>
<img src="//placehold.it/50">
</div>
</article>
But whether that's usable for you depends on the entire context.