Select all PNG images

How to apply CSS style only to PNG images?

.pngImages {opacity:0.75} .pngImages:hover {opacity:1} 

I have many pages containing duplicate PNG files. How to apply this class to all of them without specifying img class="pngImage" ...

A similar thing, but only for png images:

 div {background-color:#ddd} 
+6
source share
4 answers

You can use attribute selector

 img[src$=".png"] 

This selects all png images

+6
source

Assuming you only need to follow the <img> tags, not the background images:

 img[src$='.png'] { background-color: #ddd; } 

This basically selects image tags whose src attribute value ends in .png

+1
source

You can use the [attribute$='value'] selector to do this:

 img[src$=".png"] { opacity:0.75; } img[src$=".png"]:hover { opacity:1; } 
0
source

I think you should do this using attribute selector 1 , for example:

img[src$=".png"]{border:2px solid #8c0000;}

You may need to test this in Internet Explorer to make sure it is up.

0
source

Source: https://habr.com/ru/post/951188/


All Articles