What is MIME type "image/x-icon"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

The MIME type image/x-icon defines a file format for icon images. It is used to show small graphics that represent websites or applications.

In web pages, it is best known for displaying the favicon in browser tabs and bookmarks. It also appears in file explorers to symbolize programs and files.


Files using this MIME type typically carry the extension ICO. For more details, you can check resources like W3C and MDN Web Docs.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: image/x-icon    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="image/x-icon">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'image/x-icon');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

Is image/x-icon the official MIME type for .ico files?

Technically, image/vnd.microsoft.icon is the IANA-registered standard for .ico files. However, image/x-icon was the de facto standard for many years and remains widely supported by all major browsers and web servers for backward compatibility.

How do I add a favicon using image/x-icon in HTML?

To set a favicon, place a <link> tag within the <head> section of your HTML document. Use the code: <link rel="icon" type="image/x-icon" href="/favicon.ico">. This tells the browser to load the file as an icon.

How do I configure Apache to serve .ico files as image/x-icon?

If your Apache server is not sending the correct headers, add the line AddType image/x-icon .ico to your .htaccess file or your main configuration file. This ensures browsers interpret the file as an icon rather than text or a generic binary.

Why use image/x-icon instead of image/png for favicons?

The primary reason to use image/x-icon is strictly for legacy support, particularly for older versions of Internet Explorer (IE10 and below). For modern browsers, standard MIME types like image/png or image/svg+xml are generally preferred for better quality and transparency support.

Can an image/x-icon file contain multiple resolutions?

Yes, one of the main advantages of the ICO format is that it acts as a container for multiple images. A single file can hold 16x16, 32x32, and 48x48 pixel versions, allowing the operating system or browser to choose the best resolution for the specific display area.

How do I fix Nginx serving .ico files as text/plain?

This error occurs if the MIME type mapping is missing. Edit your mime.types file (often located in /etc/nginx/) to include the line image/x-icon ico;. Reload Nginx to apply the changes.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.