There are three seperate things at play here:
- The
<a>
text visible to the user (which can be anything and doesn't need to be a valid link)
- The URL itself, inside the
href
attribute of the <a>
tag
- The actual content being served at that URL
Browsers do not use file extensions to determine the type of the content being served. Instead, they inspect the Content-Type
header in the HTTP response that the server sends.
It is completely possible (albeit surprising) for an HTTP server to be configured in such a way that a .zip
will be served with a PDF type (application/pdf
), in which case the browser will try to open it as a PDF file (whether it succeeds in doing so depends on whether the contents of the file form an actual, valid PDF). Likewise, it is completely possible for a server to serve a .pdf
file as a ZIP file (application/zip
), in which case the browser will try to open it as a ZIP file. The extension of the file is irrelevant; it's the Content-Type
that the server reports that counts.