Can a clean SVG document specify Favicon.ico?

Can a pure SVG document arrive in the browser to support the favicon.ico specification? My case is machine generated pure SVG, html> or <head> tags.

+6
source share
1 answer

Yes, since SVG is XML, you can add an (x) html link element anywhere in svg:

 <link xmlns="http://www.w3.org/1999/xhtml" rel="shortcut icon" href="favicon.ico" /> 

There is absolutely no need to wrap this in a foreignObject. I recommend placing the link element as a child of the <defs> element, although just to let svg engineers know that it can be skipped for actual svg rendering.

Note that this is not a “clean” svg, it is an xhtml / svg hybrid, but it should work in all browsers that support svg.

+8
source

All Articles