Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS hide all images with matching SRC attribute

Is it possible to create a CSS rule that would apply a style to any IMG tag with a SRC that contained a specific string, say "hideme"? For instance, if I had the following 3 images on a page it would hide the second one?

<img src="images/test1.png">
<img src="images/hideme.gif">
<img src="images/test3.jpg">
like image 836
THE JOATMON Avatar asked Jul 20 '11 14:07

THE JOATMON


1 Answers

Use this CSS3 attribute selector:

img[src*="hideme"] {
    display: none;
}

I'd prefer to use a hideme class instead, but if you must hide an image based on its src attribute, the above is fine.

like image 183
BoltClock Avatar answered Oct 21 '22 15:10

BoltClock