A favicon (short for "favorite icon") is an icon associated with a website or webpage intended to be used when you bookmark the web page. Web browsers use them in the URL bar, on tabs, and elsewhere to help identify a website visually. Also, it is used as application icon of mobile device.
A favicon is typically a graphic 16 x 16 pixels square and is saved as favicon.ico in the root directory of your server. You can use a favicon with any WordPress site on a web server that allows access to the root directories.
WordPress Version 4.3 implemented Site Icon feature that enables favicon in your web site. It is recommended that you use the Site Icon feature, instead of following the guidance below. When you use it, you don't need to prepare the favicon.ico file by yourself or modify your template file, just specifying square image that has at least 512 pixels wide and tall from Customizer screen.
Follow the below steps to set favicon in your site.
A favicon can be created using any graphics/image editing software, such as GIMP, that allows the saving of .ico files. There are also online services that will allow you to create a favicon for free.
The image should be clear and is usually designed to match your site's image and/or content, a big task for something so small.
To prepare the image to be saved as favicon.ico:
If you're using an online service to create your favicon, such as Faviconer.com (creates 24bit favicon.ico with a transparent background) or Dynamic Drive, follow the instructions provided by the site and then download the favicon.ico image to your computer.
In order for your favicon to show up in some older browsers, you will need to edit your page header. Remember, the best way to edit your theme's files is via a Child Theme. For the purpose of the following instructions you will need to create a copy of your parent theme's header.php file in your child theme.
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" />
This method needs you to make sure your source image already has a transparent background, which means it should be a GIF or a PNG. The rest of steps are as above. The one difference in the code is instead of favicon.ico use favicon.png or favicon.gif.
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.png" />
To see your new favicon, clear your browser's cache. You may need to restart your browser in order to see the new favicon.