Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an image file format selector in CSS?

Tags:

html

css

image

I want to use the display:none property on all .gif images (displayed using <img> tags) on my website. Is there a CSS selector that can do that? Or is jQuery the best way to do this?

This doesn't work, but I'm looking for something like this:

img[gif] {
    display:none;
}

I know it's a simple question; Google yielded no results.

like image 436
JSW189 Avatar asked Sep 19 '13 02:09

JSW189


People also ask

How do I reference an image using CSS?

Usage is simple — you insert the path to the image you want to include in your page inside the brackets of url() , for example: background-image: url('images/my-image. png'); Note about formatting: The quotes around the URL can be either single or double quotes, and they are optional.

How do you change an image in CSS?

Answer: Use the CSS background-image property You can simply use the CSS background-image property in combination with the :hover pseudo-class to replace or change the image on mouseover.

Which of the following is the correct CSS selector for selecting the file ending with .png extension?

$('img[src*=". png"]').

What are the selectors in CSS?

A CSS selector is the first part of a CSS Rule. It is a pattern of elements and other terms that tell the browser which HTML elements should be selected to have the CSS property values inside the rule applied to them.


1 Answers

You can do:

img[src$=".gif"] { 
  display: none; 
}

This looks at the end of the src attribute for ".gif" on all <img> elements.

like image 156
Bill Criswell Avatar answered Sep 27 '22 22:09

Bill Criswell