Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all PNG images

Tags:

html

css

image

How can apply a css style just to PNG images?

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

I have many pages that contain repeated PNG files. How can apply this class to all of them without specify img class="pngImage" ...

A thing like this but just for png images:

div {background-color:#ddd}
like image 563
user2586454 Avatar asked Aug 07 '13 06:08

user2586454


2 Answers

You can use the attribute selector

img[src$=".png"]

This selects all png images

like image 136
Christopher Perrin Avatar answered Sep 22 '22 09:09

Christopher Perrin


Assuming you only need to take care of <img> tags, and not background-images as well:

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

This selects all image tags which have an src attribute value ending in .png.

like image 30
godfrzero Avatar answered Sep 19 '22 09:09

godfrzero