html - 在 HTML head 中排序图标 <link> 标签的最佳实践

标签 html icons meta favicon

我想包括 <link>我的 HTML 中的标签指向各种不同大小的图标。订购图标的最佳做法是什么 <link><head> 中标签?我将它们包含在什么顺序中重要吗?从最小到最大?从大到小?

最佳答案

我想你只想知道关于网站图标的信息,因为你的问题有标签favicon。在其他情况下,我可以写一本关于它的书。 :-) 我没有找到关于尺寸顺序的信息,但我会从最小到最大的顺序来做,因为可以节省服务器资源。

Internet Explorer 9 uses site icons in the following places:

  • Address bar (16x16)
  • New Tab page (32x32)
  • Taskbar button (32x32)
  • Pinned site browser UI (24x24)

As you create your Pinned site, you might need additional icons to use in the following ways:

  • Jump List tasks (16x16)
  • Thumbnail Toolbar buttons (16x16)
  • Overlay icons (16x16)

To achieve the best experience in Internet Explorer 9, your icons should support the following image sizes:

  • Recommended 16x16, 32x32, 48x48
  • Optimal 16x16, 24x24, 32x32, 64x64

一个 ICO 文件可以包含多张图片,Microsoft 建议将 16x1632x3248x48 版本的图标放在 favicon.ico 中。例如,IE 将为地址栏使用 16x16 版本,为任务栏快捷方式使用 32x32

你可以像下面这样写图标:

<link rel="icon" href="/path/to/icons/favicon.ico">

现代桌面浏览器(IE11、Chrome、Opera、Firefox...)更喜欢使用 PNG 图标。通常的预期大小是 16x1632x32 和“尽可能大”。例如,MacOS/Safari 使用 196x196 图标,如果它是它能找到的最大的话。

PNG 图标声明为:

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

文档: <link>: The External Resource Link element在 MDN 上

推荐的尺寸是多少?选择您最喜欢的平台:

关于经典和非经典网站图标的附加信息:

关于html - 在 HTML head 中排序图标 <link> 标签的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53464667/

相关文章:

php - WordPress 创建新的帖子状态?

html - 需要背景颜色来填充空间

xcode - Xcode 4 中的自定义图标存储在哪里?

c# - 从代码 (C#) 使用 FontIcon Glyph

javascript - 将Js变量转化为元数据

html - html 文件中的 UTF-8 字符编码错误

html - 使用 css linear-gradient 创建一条虚线对 Angular 线

javascript - Jquery:如何在保留文本的同时解开字符串的所有跨度标签

javascript - 使用复选框更新 MySQL 值

java - 如何更改最近查询旁边的时钟图标颜色 android