Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does file extensions matter for browsers?

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?

like image 933
Martin Avatar asked Jan 27 '10 16:01

Martin


People also ask

Does a file extension matter?

Summary: file extensions have many benefits that make them useful, but not necessary. File extensions contain some metadata, whilst files contain the actual contents. As a complement, you may find a rather general information about file extensions here.

Is it OK to change the file extension?

Changing file extensions is usually unnecessary because files typically already have the appropriate extension. When you double-click a file that has the right extension, it will open with the correct program. For example, a file with a . TXT extension will open in a text editor, and a file with a .

Should I use HTML or HTM?

htm and . html are exactly the same and will work in the same way. The choice is down to personal preference, provided you're consistent with your file naming you won't have a problem with either. Depending on the configuration of the web server, one of the file types will take precedence over the other.

What does changing file extensions do?

The operation of changing the file extension on Windows should have no effect on the file itself. However, if you opened the file when it was a . txt (so it opened in Notepad ), and then saved it — you may have corrupted the file.


2 Answers

No, what matters is the Content-Type header, which gets served in the HTTP response.

like image 93
Anton Gogolev Avatar answered Sep 27 '22 23:09

Anton Gogolev


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.

like image 30
Adam Matan Avatar answered Sep 28 '22 01:09

Adam Matan