纯SVG文件可以指定Favicon.ico吗? [英] Can pure SVG document specify a Favicon.ico?
问题描述
到达浏览器的纯SVG文档可以支持favicon.ico规范吗?我的情况是机器生成的纯SVG,没有可用的html>
或<head>
标签.
Can a pure SVG document arriving at a browser, support a favicon.ico specification? My case is machine generated pure SVG, no html>
or <head>
tags available.
推荐答案
是的,由于SVG是XML,因此您可以在svg中的任意位置添加(x)html链接元素:
Yes, since SVG is XML, you can add the (x)html link element anywhere in the svg:
<link xmlns="http://www.w3.org/1999/xhtml" rel="shortcut icon"
href="favicon.ico" />
绝对不需要将其包装在foreignObject中.我建议尽管将link元素作为< defs>元素的子元素,只是为了让svg引擎知道可以为实际的svg渲染而跳过它.
There's absolutely no need to wrap this in foreignObject. I recommend putting the link element as a child of a <defs> element though, just to let the svg engines know that it can be skipped for the actual svg rendering.
请注意,这不是纯" svg,它是xhtml/svg混合体-但它应在所有支持svg的浏览器中都可以使用.
Do note that this isn't "pure" svg, it's an xhtml/svg hybrid - but it should work in all the browsers that support svg.
这篇关于纯SVG文件可以指定Favicon.ico吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!