Does it matter if i name my pictures "test.jpg" or just "test" for the viewers?
<img src="test.jpg" />
<img src="test" />
Both works in all browsers i know but is there any point in using the right file extension?
Does it matter if i name my pictures "test.jpg" or just "test" for the viewers?
<img src="test.jpg" />
<img src="test" />
Both works in all browsers i know but is there any point in using the right file extension?
Nope. Only the MIME type in the response matters, and sometimes not even that.
No, what matters is the Content-Type header, which gets served in the HTTP response.
It probably does not matter (see other answers).
Having that said, why NOT keeping the filename extension? It will make your page source much more readable, and you'll easily understand the file types stored at the server.
Even if there are no technical reasons for that, it is a very good practice to keep each file with a meaningful extension. Likewise, I guess you can save your .c
, .h.
and .py
files without extensions. They'll compile and run, but it would just make your life a whole lot harder.
For images it doesn't really matter since they use the mime-type. But the fact that you're asking means that even you think it's slightly confusing. This also assumes some mod_rewrite foo or you're loading the images through your framework which is going to cost you some performance.
In theory, what matters is the Content-Type header, as Anton pointed out.
However, in practice, at least Internet Explorer will in some cases try to "guess" the MIME type, even if it is specified in the Content-Type header. Then the filename is one of the things considered. This should however only apply in some special cases.
See here: http://msdn.microsoft.com/en-us/library/ms775147%28VS.85%29.aspx
To the browser, no, the MIME type is what truly matters. See this list of MIME types.
To the user, adding the extension may be meaningful, but most image URLs aren't visible to the end user so this isn't a big point.
To the server, the extension could definitely matter. Most web servers use the extension of a file as the means by which they determine how to handle an incoming request. e.g.:
If you had the need to dynamically generate the robots.txt file you may set up your web server to handle incoming .txt requests differently than if you used a static robots.txt.