I wanted to write a logo in svg, but surprisingly found that I could not re-use objects defined in <defs>...</defs>
. I tried them on Chrome.
Please see examples:
test1.html doesn't work, no rect was drawn.
<!DOCTTYPE html> <html> <body> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="480" height="360"> <defs> <rect id="helo" x="0" y="0" height="20" width="20" /> </defs> <use xlink:href="#helo" /> </svg> </body> </html>
BUT test2.svg works.
<?xml version="1.0"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="480" height="360"> <defs> <rect id="helo" x="0" y="0" height="20" width="20" /> </defs> <use xlink:href="#helo" /> </svg>
What's needed to make the test1.html work? Many thanks:)