1
I have a problem that seems simple, but I haven’t found a solution. I created a link style that instead of having a text-Decoration underline, I want a bottom edge.
The problem is that if an image has a link, I want to remove the border.
I’m trying this code, but the pseudo-class :not
, is not being applied to the image, so I have a border image underneath every time I insert a link into it.
.post-body a:not(img) {
padding-bottom: 1px;
border-bottom: 1px solid #000;
}
.post-body a img {
padding-bottom: 0;
border-bottom: none;
}
<div class="post-body">
<a href="#">
Link
</a>
</div>
<br /> Imagem sem link:
<div class="post-body">
<img src="https://source.unsplash.com/WLUHO9A_xik/200x150" />
</div>
Imagem com link:
<div class="post-body">
<a href="#">
<img src="https://source.unsplash.com/WLUHO9A_xik/200x150" />
</a>
</div>
How to apply the border only to links and not to images+links using CSS?
I’ve already updated...
– Mari
I already say that
a:not(img)
does not work because the selector says "a taga
other than a tagimg
", but obviously noa
will beimg
.– Rafael Tavares
Hmm, I get it. But then it would be impossible to apply a style to a link that wasn’t an image, or otherwise?
– Mari