CSS: What does the question mark at the end of css do?
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.
What does the question mark at then end of a css include url do?
That loads all.css
with a different query string so that if version 6637, for instance, is already cached on your machine, you'll get the new one (6638). Changing that number (in this case) will not give you a different file.
This is just a cache trick so they can send the file down with no expiration (i.e. you never have to ask for it again), because when it does change, the "file name", changes.
That said, you could make it so you load a different version based on the query string parameter. Doing so would be slightly non-trivial and akin to how you get different questions when you pass a different question ID to the URL of this page.
accessing the CSS in browser using question mark (?) in end
You need to add something after the ? then change it when you change the CSS. What is happening is a browser will cache anything that doesn't change for a specific period, it does that by checking file names. so main.css? is still main.css? Anything after the question mark is a query string, generally it's used to pass data to a particular file. In this case it's just used to change the file string so the browser will update it every time it changes without affecting the file itself.
There are a couple of ways you can handle this, the first is manually changing the version, probably the easiest idea if you have a single header file, as in a template system that always loads the same head data.
<link rel="stylesheet" type="text/css" href="assets/css/main.css?ver1/>
Then on next change:
<link rel="stylesheet" type="text/css" href="assets/css/main.css?ver2/>
If you'd rather do it automatically you can add a bit of PHP script to the css line like this:
<link rel="stylesheet" type="text/css" href="assets/css/main.css?time=<?php echo filemtime('./assets/css/main.css');?>" />
This is essentially adding a value that changes every time you save the file and results in something like this, the next time I save the file that time= value will change:
<link rel="stylesheet" type="text/css" href="http://localhost/refficient/trunk/assets/css/main.css?time=1350305706" />
What is the question mark at the end of some script tag for?
Everything behind the question mark is a parameter that is delivered to the JavaScript.
In the given case a change in the version number prevents the browser from using the cached file and instead getting it from the server.
stylesheet linked with question mark and numeric value
It is for preventing the browser from caching the CSS. When a CSS is requested by some browsers, specifically Internet Explorer, the browser will have a local copy of the CSS.
When a request is given to a server as:
site.com/assets/css/screen.css?skdjhfk
site.com/assets/css/screen.css?5sd4f65
site.com/assets/css/screen.css?w4rtwgf
site.com/assets/css/screen.css?helloWd
The server at site.com
sees only:
site.com/assets/css/screen.css
And gives the latest version. But when the HTML page is requesting the browser to fetch the CSS as: site.com/assets/css/screen.css
, for the first time, it fetches from the site.com
server. There are many possibilities that the content might be changed in the meantime when the next request is sent. So programmers generally add a ?and-some-random-text
, which is called Query String. This will force the browser to get a new copy from the server.
Some more detailed explanation:
It is a well known problem that IE caches too much of html, even when
giving aCache-Control: no-cache
orLast-Modified
header to
everypage.This behaiviour is really troubling when working with querystrings to
get dynamic information, as IE considers it to be the same page
(i.e.:http://example.com/?id=10
) and serves the cached version.I've solved it adding either a random number or a timestring to the
querystring (as others have done) like this
http://example.com/?id=10&t=2009-08-06_13:12:56
that I just ignore
serverside.Is there a better option? Is there another, cleaner way to acomplish
this? I'm aware thatPOST
isn't cached, but it is semanticaly
correct to useGET
here.
Reference: Random Querystring to avoid IE caching
Prevent ? (question mark) from being treated as a white-space like separator
I had the same issue, here are the two lines of css I used:
{
word-wrap: break-word;
white-space: pre;
}
What does the question mark at the end of filenames mean?
The ?
in a URL denotes the start of the query string. A ?
at the end with no variables following it is usually an unnecessary way of saying "this has absolutely no querystring".
It would be possible with a URL rewriting engine for example, to examine the incoming REQUEST_URI to see if it ends with ?
and take a different action than requests not ending in ?
, but that would be an unusual usage. It would much more common to just specify some value in the query string.
What is the meaning of ? (question mark) in a URL string?
Its name is query string. After the question mark you can pass key-value pairs and use them server-side.
Why does a diamond with a questionmark in it � appear in my HTML?
This specific character � is usually the sign of an invalid (non-UTF-8) character showing up in an output (like a page) that has been declared to be UTF-8. It happens often when
a database connection is not UTF-8 encoded (even if the tables are)
a HTML or script source file is stored in the wrong encoding (e.g. Windows-1252 instead of UTF-8) - make sure it's saved as a UTF-8 file. The setting is often in the "Save as..." dialog.
an online source (like a widget or a RSS feed) is fetched that isn't serving UTF-8
Related Topics
3D-Like Hover Effect on Button
Characters from Embedded Google Fonts Not Showing Up in Firefox 4 and Ie9
Chrome Dev Tools Showing a CSS Rule on a Grey Background. Why
Media Queries Running Weird Because of Non-Integer Width
CSS Animations End Together Even Though They Are Started at Different Times
CSS Drop Down - Sub Menu Color
CSS Dropdown Menu Hidden Behind Content Ie7
Full Width Background, Without a Wrapper
Understanding The Z-Offset in Transform-Origin
Detect Screen Width with CSS Media Queries
Left/Right Transparent Cut Out Arrow
Issue with: Global() CSS-Module Selectors Not Being Pure in Nextjs
How to Write Multiple CSS Selectors in One Line
Make an Image Fit Its Container by Setting The Image Height to The Containers Heights
Why Is My CSS Class Style Not Applying to Specific <Li>'s