102

Possible Duplicate:
HTML Title Image

Can someone please tell me how to make icons appear on browser tabs in PHP?

I want my icon to appear on the tabs when my site is being accessed.

Community
  • 1
  • 1
osg
  • 1,117
  • 2
  • 7
  • 6

2 Answers2

157
  1. This is not done in PHP. It's part of the <head> tags in a HTML page.
  2. That icon is called a favicon. According to Wikipedia:

    A favicon (short for favorites icon), also known as a shortcut icon, website icon, URL icon, or bookmark icon is a 16×16 or 32×32 pixel square icon associated with a particular website or webpage.

  3. Adding it is easy. Just add an .ico image file that is either 16x16 pixels or 32x32 pixels. Then, in the web pages, add <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> to the <head> element.
  4. You can easily generate favicons here.
B.B
  • 144
  • 2
  • 19
citruspi
  • 6,709
  • 4
  • 27
  • 43
  • 2
    Should not it be simply `icon` instead of `shortcut icon`? – kapa Aug 09 '12 at 23:39
  • 4
    @bažmegakapa It can be either. – citruspi Aug 09 '12 at 23:41
  • 9
    The default seems to be /favicon.ico if not specified. Wouldn't having a relative url like the one in this answer break pages which are deeper than the root level? – Phil Jul 07 '16 at 06:58
  • for those who want to add a favicon to a web application such as express in nodejs. I got it to work by placing the favicon file in the root of the public folder from where your static files are served. Then added this line to the head section of my html file. `` – Asim Oct 06 '19 at 06:09
  • What if I have a 64x64 png? – Radovan Babjak Feb 17 '21 at 15:26
  • 1
    @kapa virtually whatever you put in the `rel` would work as long as the word icon is there – Dan Jun 08 '21 at 18:20
90

Simply put a file named favicon.ico in the webroot.

If you want to know more, please start reading:

kapa
  • 77,694
  • 21
  • 158
  • 175