How to set-up a favicon?

前端 未结 11 2135
梦毁少年i
梦毁少年i 2020-12-02 15:34

I am trying to do a very simple preliminary exercise to setting up a website which is creating a favicon.

This is the code I am using:



        
相关标签:
11条回答
  • 2020-12-02 15:40

    This method is recommended

    <link rel="icon" 
      type="image/png" 
      href="/somewhere/myicon.png" />
    
    0 讨论(0)
  • 2020-12-02 15:42

    you could take a look at the w3 how to, i think you will find it helpful

    your link tag attribute should be rel="icon"

    0 讨论(0)
  • 2020-12-02 15:46

    In my site, I use this:

    <!-- for FF, Chrome, Opera -->
    <link rel="icon" type="image/png" href="/assets/favicons/favicon-16x16.png" sizes="16x16">
    <link rel="icon" type="image/png" href="/assets/favicons/favicon-32x32.png" sizes="32x32">
    
    <!-- for IE -->
    <link rel="icon" type="image/x-icon" href="/assets/favicons/favicon.ico" >
    <link rel="shortcut icon" type="image/x-icon" href="/assets/favicons/favicon.ico"/>
    

    To simplify your life, use this favicons generator http://realfavicongenerator.net

    0 讨论(0)
  • 2020-12-02 15:50
    <head>
        <link rel="shortcut icon" href="favicon.ico">
    </head>
    
    0 讨论(0)
  • 2020-12-02 15:51

    With the introduction of (i|android|windows)phones, things have changed, and to get a correct and complete solution that works on any device is really time-consuming.

    You can have a peek at https://realfavicongenerator.net/favicon_compatibility or http://caniuse.com/#search=favicon to get an idea on the best way to get something that works on any device.

    You should have a look at http://realfavicongenerator.net/ to automate a large part of this work, and probably at https://github.com/audreyr/favicon-cheat-sheet to understand how it works (even if this latter resource hasn't been updated in a loooong time).

    One complete solution requires to add to you header the following (with the corresponding pictures and files, of course) :

    <link rel="shortcut icon" href="favicon.ico">
    <link rel="apple-touch-icon" sizes="57x57" href="apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="144x144" href="apple-touch-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="60x60" href="apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="120x120" href="apple-touch-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="76x76" href="apple-touch-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon-180x180.png">
    <link rel="icon" type="image/png" href="favicon-192x192.png" sizes="192x192">
    <link rel="icon" type="image/png" href="favicon-160x160.png" sizes="160x160">
    <link rel="icon" type="image/png" href="favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16">
    <link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="mstile-144x144.png">
    <meta name="msapplication-config" content="browserconfig.xml">
    

    In June 2016, RealFaviconGenerator claimed that the following 5 lines of code were supporting as many devices as the previous 18 lines:

    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
    <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
    <link rel="manifest" href="/manifest.json">
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="theme-color" content="#ffffff">
    
    0 讨论(0)
  • 2020-12-02 15:52

    Try put this in the head of the document: <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>

    0 讨论(0)
提交回复
热议问题