Can pure SVG document specify a Favicon.ico?

和自甴很熟 提交于 2019-12-01 02:58:07

问题


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.


回答1:


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" />

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.

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.



来源:https://stackoverflow.com/questions/13324547/can-pure-svg-document-specify-a-favicon-ico

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!