adamcadot
adamcadot

Reputation: 33

CSS: What does the question mark at the end of css do?

Example from Wikipedia css:

#content a[href^="https://"], .link-https {
  background:url("images/external-link-ltr-icon.png?2") no-repeat scroll right center transparent;
  padding:0 13px 0 0;
}

Upvotes: 3

Views: 5501

Answers (7)

Diego
Diego

Reputation: 37

The question mark isn't part of the CSS, it's used to request a non-cached version of the image.

Upvotes: 0

cHao
cHao

Reputation: 86524

There's no question mark there except for the one in the URL. That one works just like in any HTTP url; the stuff after it is a query string, to be interpreted however the script that responds to the request chooses to interpret it.

In the case of a static image, this is a technique often used to defeat caching. The number's a bit too small to suggest that, though. The query-string part might be used to denote the version of the image, so that caches don't return an image that'd no longer work with the layout. That's just a guess, though.

Upvotes: 1

Gabriele Petrioli
Gabriele Petrioli

Reputation: 196026

This is (usually) used to invalidate the cached version of the image..

When ever you make a new version of the image, you change the number forcing browsers to reload and not use the cached version..

Not part of CSS, but rather the browser behaviour..

Upvotes: 2

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272557

This is not a CSS feature, it's a feature of URLs; the question-mark denotes the start of the query string.

Upvotes: 0

Jakub Hampl
Jakub Hampl

Reputation: 40543

It's probably a so-called cache-buster. It works by the server setting a far future cache expiry date and every time the designer changes that image he can increment the number in the stylesheet and the image will be reloaded.

Upvotes: 1

Matthew Flaschen
Matthew Flaschen

Reputation: 284836

Like everyone said, it's part of the URL. The purpose is cache-busting. When the image changes, so does the parameter, so clients will get the latest version.

Upvotes: 0

p.campbell
p.campbell

Reputation: 100587

That's actually not part of CSS itself, but rather, part of the querystring to the image.

It's the same as:

http://foo/images/external.png?bar=baz

The site will take that querystring parameter and value as part of the request. It could make a decision on which file to serve, based on the value supplied.

Likely it's a version number. It helps get around the situations where your browser may have cached the image.

Upvotes: 8

Related Questions