CSS hide all images with matching SRC attribute

CssCss SelectorsWildcard

Css Problem Overview


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">

Css Solutions


Solution 1 - Css

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTHE JOATMONView Question on Stackoverflow
Solution 1 - CssBoltClockView Answer on Stackoverflow