You are here:

  1. Manual
  2. Development
  3. Links and navigation
  4. Downloadable files

Links and navigation: Links to downloadable files

Visitors to websites are regularly given the option of clicking on a link to download a file that is not a web page; PDF, Word or ZIP files, each with their own purpose and application. A number of guidelines to make links to downloadable files are discussed below.

Before making information available as a separate downloadable file, the web developer or content manager should ask himself whether it would be better to publish this information on an accessible web page.

In the event that important information is provided through a closed standard, the same information should also be provided through an open standard.

Guideline R-pd.5.1

If the conclusion is that the information must be downloadable as a separate file, links to that file are subject to the following principles.

Inform and instruct the visitor

Web developers and content managers can add the following information to the link to the file.

  • The content of the file.
  • The file type. Possibly with suggestions for opening this type of file.
  • The file size. Possibly with an indication of the download time.
    For example: ‘2 minutes with a 56k modem’.
  • Date added or date modified, if the file content is changed or supplemented regularly.

When presenting downloadable files, inform the visitor how to download and then use them.

Guideline R-pd.8.20

Do not make any assumptions concerning the download method

Files of different types are downloaded and opened in various ways, by means of different systems and by visitors with individual requirements. In short, the web developer can only guess as to how the file from his website will be downloaded and then opened. It is better if web developers concentrate on making the file available as correctly and completely as possible.

Serve files with the correct MIME type

Serve files with the correct MIME type.

Guideline R-pd.8.21

The MIME (Multipurpose Internet Mail Extensions) type identifies file types for the browser. Consequently, browsers decide what to do during and after downloading the file. The visitor can instruct his browser about what to do with files of a particular type.

For example, if a PDF file is downloaded and the web server provides the correct MIME type for it (application/pdf), the browser can then decide to open this file in the Adobe PDF plugin, in the browser window. If this plugin is not available, the file is downloaded and then opened in a separate programme (for example, Adobe Acrobat Reader). Alternatively, the browser does not recognise the MIME type and asks the user to intervene.

Many web developers think the browser determines the file type according to the file extension (.pdf for instance). This is only half true. A compliant browser looks at the file's MIME type first. If this is unavailable or unknown to the browser, the browser can make a guess.

The most widely used browser, Microsoft Internet Explorer, is notorious letting the file extension prevail. However, this is no excuse for web developers to ignore the correct MIME type of files.

MIME types for files are sent from the web server through the HTTP Content-type header. The method used to change the MIME type settings on the web server depends on the type of server.

Download links and new windows

Do not automatically open links to downloadable files in a new window. Web developers sometimes think that PDF or Word documents are always opened by means of a browser plugin and must therefore be opened in a new window – as if they were links to external websites. In that case, visitors who do not have a browser plugin are confronted with an empty window. See also Links and new windows.

Do not automatically open links to downloadable files in a new window.

Guideline R-pd.8.22

Visitors may be inconvenienced when a downloading file opens in the same browser window as the website, due to a browser plugin. However, if information on the file type is added to the download link, the visitor can make an deliberate decision to open the file in a new window himself or to do something else with it.

Preventing files from opening in browser windows

Sometimes it is not at all useful for a visitor if a file is opened by a browser plugin – and therefore in a browser window–. In that case the web developer has two ways of suggesting to the browser that the file just be downloaded to the visitor's hard disk and not opened in the browser: ‘compressing’ the file, or serving with a special HTTP header.

Make clear that a file is always downloaded before a browser or another programme can do anything with it. Even if a file automatically opens in a browser window it has been downloaded first. However, the issue is what a browser does after a file has been downloaded: does it open the file in a browser window by means of a plugin, or does it just leave the file alone?

‘Compressing’ the file

The file can be compressed – or ‘zipped’ – using the standard ZIP format. Although nothing can guarantee that a browser will not open a file in the browser window, practice has shown that browsers will usually just download a ZIP file to the visitor's hard disk.

If the browser does not decompress the file automatically after downloading, the user will have to do this himself. In any case plugins that would normally open the file are by-passed.

The HTTP Content-disposition header

If the web server sends an extra HTTP header to the browser before a file is downloaded, the browser can decide to merely download this file as an attachment to the visitor's hard disk.

Content-disposition header

Content-disposition: attachment

Forcing a download via the MIME type

In many browsers, serving certain (unknown) MIME types causes the file to be downloaded without the visitor's browser doing anything else with this file after downloading.

Do not intentionally serve downloadable files with an unknown or incorrect MIME type to force the browser to do something.

Guideline R-pd.8.23

Web developers forcing a browser to take specific action deprive the visitor of the freedom to decide what to do with files of a particular type. In some systems, this results in unusable files on some systems. Always serve files with the correct MIME type.


Web Guidelines version 1.3, November 2007.