Favicon Standard - 2021 - svg、ico、png 和尺寸? [英] Favicon Standard - 2021 - svg, ico, png and dimensions?

查看:34
本文介绍了Favicon Standard - 2021 - svg、ico、png 和尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到 2021 年应使用哪些网站图标尺寸、文件格式和元/链接标签?这包括苹果图标、Windows、Android 和人们今天使用的其他设备.

What favicon dimensions, file formats and meta/link tags should be used as of 2021? This includes apple icon, windows, android and other devices people use today.

我使用 Opera,我可以看到它支持 svg 格式.它是当今使用 svg 的最佳解决方案吗?有没有一个文件适合所有"的选项?

I use Opera and I can see it supports svg format. Is it the best solution to use svg nowadays? Is there any option "one file fits all"?

我浏览了许多网站并检查了不同的网站图标生成器".所有这些都已有多年历史,并且主要使用 png 文件.

I've been browsing many websites and checked different "favicon generators". All of them are years old and work mostly with png files.

例如:ico和svg应该用什么代码?

For example: What code should be used for ico and svg?

<link rel="icon" href="favicon.ico" type="image/ico">
<link rel="icon" href="favicon.svg" type="image/svg+xml">

或者如果 ico 包含更多尺寸,是否应该指定尺寸?我没有找到一个好的答案.

or should dimensions be specified if ico contains more sizes? I didn't find one good answer.

<link rel="icon" sizes="16x16 24x24 32x32 48x48 64x64" href="favicon.ico">

请提供应使用哪些网站图标的尺寸、文件格式和元/链接标签.

Please provide dimensions, file formats and meta/link tags of what favicons should be used.

推荐答案

免责声明:我是 RealFaviconGenerator 的作者,我希望它是最新的(主要是,见下文).因此,如果此答案与 RFG 生成的内容相符,请不要感到惊讶.

Disclaimer: I'm the author of RealFaviconGenerator, which I expect to be up-to-date (mostly, see below). So don't be surprised if this answer matches what RFG generates.

没有一刀切"图标.您不能创建单个 SVG 图标并期望它在任何地方都能使用.

There is no "one size fits all" icon. You can't create a single SVG icon and expect it to work everywhere.

从技术角度来看,单个 SVG 图标将是一件好事.但从 UI 和 UX 的角度来看,这不是一个理想的结果.比较 iOS 和 Android.在 iOS 上,所有主屏幕图标都是带圆角的正方形 (iOS用黑色填充触摸图标的透明区域).在 Android 上,主屏幕图标通常使用非方形和透明度(包括 Google 应用程序图标).提交一个触摸图标,Android Chrome 就会使用它.但是您将无法匹配 Android 图标指南,而专用图标可以.

From a technical point of view, a single SVG icon would be a good thing. But from a UI and UX point of view, this is not a desirable outcome. Compare iOS and Android. On iOS, all home screen icons are squares with rounded corners (iOS fills transparent regions of Touch icons with black). On Android, home screen icons often use non-square shapes and transparency (including Google app icons). Submit a single touch icon and Android Chrome will use it. But you won't be able to match Android icon guidelines, whereas a dedicated icon could.

所以我建议刻意避免使用单个图标.尽可能单独针对每个平台(情况并非总是如此).

So I advice to deliberately avoid using a single icon. Rather target each platform individually, when possible (this is not always the case).

iOS Safari 需要 触摸图标.截至今天,这是一个 180x180 的 PNG 图像.此图像不应使用透明度,当添加到主屏幕时,其角将自动变圆.声明:

iOS Safari expects a touch icon. As of today, this is a 180x180 PNG image. This image should not use transparency and its corners will be automatically rounded when added to home screen. Declared with:

<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">

多年来,此图标已成为许多浏览器的默认高分辨率图标".所以你会在别处找到它,当添加到书签等时.

Over the years, this icon has become the "default high resolution icon" for many browsers. So you will find it elsewhere, when adding to bookmark, etc.

Android Chrome 依赖于 网络应用清单.尽管此清单并非专用于 Android Chrome,但它目前是其主要支持者.因此,目前将 Web App Manifest 中的图标考虑为适用于 Android Chrome 仍然是非常安全的.

Android Chrome relies on the Web App Manifest. Although this manifest is not dedicated to Android Chrome, it is currently its main supporter. So at the moment, it is still quite safe to consider the icons from the Web App Manifest to be for Android Chrome.

顾名思义,Web App Manifest 适用于 Web 应用程序.但是任何网站都可以将其用作引用某些图标的方式.

As the name suggests, the Web App Manifest is for, well, web apps. But any web site can use it as a way to reference some icons.

Android 需要 192x192 PNG 图标,允许并鼓励使用透明度.

Android expects a 192x192 PNG icon, transparency allowed and encouraged.

清单声明为:

<link rel="manifest" href="/icons/site.webmanifest">

Edge 和 IE 12

微软推出了browserconfig,一个 XML 文档,其中列出了适合 Metro UI 的各种图标.

Edge and IE 12

Microsoft introduced the browserconfig, an XML document which lists various icons that fit the Metro UI.

文件和背景颜色声明为:

<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/icons/browserconfig.xml">

经典桌面浏览器

Windows/macOS Chrome、Windows/macOS Firefox、Safari、IE...这些东西有点模糊.从历史上看,仍然支持单个 favicon.ico 文件.然而,最近的浏览器更倾向于选择更轻的 PNG 图标.加上有些浏览器无法在ICO文件中选择合适的图标(这种格式可以嵌入多个版本的图标),导致低分辨率图标被误用.

Classic desktop browsers

Windows/macOS Chrome, Windows/macOS Firefox, Safari, IE... This is were things are a little more blurry. Historically, there was a single favicon.ico file, still supported. However, most recent browsers rather pick PNG icons, which are lighter. Plus some browsers are not able to select the proper icon in the ICO file (this format can embed several versions of an icon), leading a low resolution icon being wrongly used.

人们可能会想完全放弃旧的 favicon.ico.虽然我想在 RFG 中实现这一飞跃,但我没有运行必要的测试来评估对旧浏览器的影响.

One could be tempted to drop the old favicon.ico entirely. Although I would like to make this leap in RFG, I didn't run the necessary tests to evaluate the impact on the old browsers.

因此,我今天仍然推荐使用 favicon.ico 嵌入 16x16、32x32 和 48x48 图标的组合:

Thus the combo I still recommend today, with favicon.ico embedding 16x16, 32x32 and 48x48 icons:

<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
<link rel="shortcut icon" href="/icons/favicon.ico">

其他浏览器

其他浏览器可能有专用图标.例如,Coast by Opera 正在寻找一个 228x228 的图标.关注这些浏览器的必要性并不明显.当他们找不到他们的"图标时,他们通常会使用触摸图标或其他图标.

Other browsers

Other browsers may have dedicated icons. For example Coast by Opera is looking for a 228x228 icon. The need to focus on these browsers is not obvious. They usually use the touch icon or other icons when they cannot find "their" icon.

正如开头所宣布的,这正是 RealFaviconGenerator 创建的内容.

As announced at the beginning, this is exactly what RealFaviconGenerator creates.

这篇关于Favicon Standard - 2021 - svg、ico、png 和尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆