Search code examples
htmlimagefaviconico

Is there a way to display an icon file in a page, with a specific size selected?


My company's site has a series of subdomains for their customers, and most of the subdomains have a unique favicon associated with them. Up until recently, we would manually upload any new favicons. I'm working on moving favicon support to where our system admin can upload + assign them by web form.

We have a table of a few hundred subdomains, and I'd like to display the favicon as a preview in an html table, on the same row as the subdomain it is associated with.

Is there a way to display the .ico files in image tags? If the .ico has multiple sizes (we usually do 64x, 32x, and 16x pixel sizes), is there a way to specify which size to display?

Some research I did suggested that IE doesn't display them while other browsers do, but it was unclear whether that was as a favicon, or as an image in the page.


Solution

  • I've had some success just putting the file's path in an <img> tag like any other image, and specifying the width and height desired. I'm not sure whether the 16x16 size would be used if I specify width and height of 16, or if it uses the largest size and scales it down.