How to set icon of an page using CSS - html

Is it possible to have this code:
<link rel="icon" href="icon.gif" />
Using css document?
(I would rather not have to go through and add that to every pages)
and is it possible to set title of page using css(I am not gonna use it as all pages have different title but just for general info)

You cannot set the favicon using CSS.... You need to use a link tag with rel value of shortcut icon.
Inorder to set that, you need to put the below string in between the <head> tags..
<link rel="shortcut icon" href="favicon.ico" />
-----^-----
<!--Remember to have .ico as the extension else
some browsers fail to load other extensions -->
You need to also specify the type attribute here type="image/x-icon" if IE fails to load your favicon, if it loads fine, you can just ignore the type attribute.

You can't do it using CSS it can only be done by inserting
<link rel="icon" href="icon.gif" />
as you have described above..
CSS is used to format some text/images etc in the page and and there is nothing to format in icon let me guess if you are working on many pages you probably have either a blog or an script to generate pages just add this line of text in it..
And you can always change icon of each page at once by just changing the icon itself...:)

You can't set a favicon from CSS - if you want to do this explicitly you have to do it in the markup as you described.
Most browsers will, however, look for a favicon.ico file on the root of the web site - so if you access http://example.com most browsers will look for http://example.com/favicon.ico automatically.

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
In href, you have to pass the image url.

Here is the combination of combination of .ico and .gif image
<link rel="shortcut icon" href="favicon.ico">
<link rel="icon" type="image/gif" href="animated_favicon1.gif">

Related

how to add an image to the website's title in html

<head>
<title><!--i want to add a picture into the title--></title>
</head>
plz help me guys I'm creating a website only using html. I want to know how to add a picture into the title which is shown in the browser
Title is used to display the page title as text.
You should use the balise below to display an icon named logo.png for example:
<link rel="icon" type="image/png" href="logo.png" />
You actually need to add a favicon to a website.
<link rel="icon">
Simply add the following code to the <head> element:
<link rel="icon" href="http://example.com/favicon.png">
What you're looking to add is actually a called a favicon. It is a tiny image you'd like to add next to the title of your website.
See this article for more info on favicons: https://www.abeautifulsite.net/what-are-favicons.
Some things to consider (taken from the article)
The most common sizes for favicons are:
32x32
48x48
64x64
-128x128
You can use a favicon generator to turn your image into the proper format and download it.
Insert the following code into your head after downloading your favicons and placing them in the directory of your html website.
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
Make sure you use an icon file with sizes as mentioned by #Joshua. Insert the following code.
<link rel="icon" href="....logo.ico?v=2" />
You will need to add ?v=2 query string to force a refresh. Otherwise you might have cache issues.

How to add an emoji tag to the page's title tag? [duplicate]

The image next to the page title in the browser tab - how can you link an image here?
That image is called 'favicon' and it's a small square shaped .ico file, which is the standard file type for favicons. You could use .png or .gif too, but you should follow the standard for better compatibility.
To set one for your website you should:
Make a square image of your logo (preferably 32x32 or 16x16 pixels, as far as I know there's no max size*), and transform it into an .ico file. You can do this on Gimp, Photoshop (with help of a plugin) or a website like Favicon.cc or RealFaviconGenerator.
Then, you have two ways of setting it up:
A) Placing it on the root folder/directory of your website (next to index.html)
with the name favicon.ico.
or
B) Link to it between the <head></head> tags of every .html file on your site, like this:
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
</head>
If you want to see the favicon from any website, just write www.url.com/favicon.ico and you'll (probably) see it. Stackoverflow's favicon is 16x16 pixels and Wikipedia is 32x32.
*: There's even a browser problem with no filesize limit. You could easily crash a browser with an exceedingly large favicon, more info here
It is called 'favicon' and you need to add below code to the header section of your website.
Simply add this to the <head> section.
<link rel="icon" href="/your_path_to_image/favicon.jpg">
This is the favicon and is explained in the link.
e.g. from W3C
<link rel="icon"
type="image/png"
href="http://example.com/myicon.png">
Plus, of course the image file in the appropriate place.
Add a icon file named "favicon.ico" to the root of your website.
<link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file:
'apple-touch-icon-retina.png')}">
or you can use this one
<link rel="shortcut icon" sizes="114x114" href="${resource(dir: 'images', file: 'favicon.ico')}"
type="image/x-icon">
ADD THIS
**<HEAD>**
< link rel="icon" href="directory/image.png">
Then run and enjoy it

Favicon ico doesn't work

<link rel='shortcut icon' href='img/favicon.ico'>
The above line is inside head part of page.
favicon.ico is inside img folder.
Doesn't work in Firefox and Chrome.
I restarted browsers, cleared the cache many times...
Any suggestion.
I also tried:
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
You forgot to self-close the link tag.
I think it is recommended to use double quotes as well:
<link rel="shortcut icon" href="img/favicon.ico"/>
If this doesn't work, have you tried to actually access the favicon image by typing the url like: http://example.org/img/favicon.ico to make sure it is reachable ?
Try using:
<link rel="icon" type="image/x-icon"
href="image/favicon.ico"/>
without the "shortcut"
if that doesn't help, you might find something in this
Wikipedia article on favicon
If any of the other answers don't work, just put ! in front of the tag.

Changing in the top of the browser using HTML (favicon)

How do you change the small image showed in a browsers tab when viewing image using HTML? Sorry, I am new to programming.
The small image is what I am talking about.
it's called a favicon:
place the favicon.ico file in the www root and use the following code:
<link rel="shortcut icon" href="/favicon.ico">
Insert the following line in <head> tag
<link href="Images/tsp1.png" rel="shortcut icon" type="image/x-icon" />
Replace Images/tsp1.png with an image of your choice, make it somting like a 16x16 image
This is the Favicon. Have a look at the whikipedia article: http://en.wikipedia.org/wiki/Favicon
Have an image in ico format with name favicon.ico in the root of your site. Search for favicon.ico for more information.
It's called a favicon.
<link rel="shortcut icon" href="http://www.example.com/myicon.ico">

Getting "there is no attribute 'REL'" on favicon tag when trying to validate page

When I try to validate my page using the W3C validation service, I'm getting this error:
Error Line 13, Column 11: there is no attribute "REL"
<LINK REL="SHORTCUT ICON" HREF="favicon.ico" />
Why does this happen?
This is the code I'm using on my site:
<link href="http://www.mysite.com/favicon.ico" rel="shortcut icon" />
It works and is valid according to http://validator.w3.org/.
I think the main problem with your code is that you're using uppercase letters. Use lowercase letters instead.
Since your favicon probably is used on many pages, I also suggest you use the full adress, like in the code above, so that all files on your site can find the favicon no matter what folder they are in.
The problem was fixed with
<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />