There are five elements for embedding objects in HTML.
there are two tags that look plausible for SVG:
<embed src="..." />, the old-style plug-in syntax; and
<object data="..." >...</object>, the HTML 4 syntax.
embed syntax was introduced with Netscape
Navigator 2, but has never been part of any HTML standard.
This is partly because it cannot fit in to XML (or SGML) because
its syntax depends on the type of the embedded content. The
object tag is much better thought out,
works with all modern browsers (such as Microsoft Internet Explorer
3.0 and later, Mozilla, Netscape Navigator 6.x, Opera, et al.).
According to Netscape’s documentaion,
it also works for NN 4.x, but in tests it seems to get
confused if there is no
embed within it.
Does this mean that, as suggested by the SVG Wiki,
one must choose which tag to use according to what browsers will be used?
Well, no. The
to embed an
tag within it, to be rendered if the
object tag is
<object data="foo.svgz" type="image/svg+xml" width="400" height="300"> <embed src="foo.svgz" type="image/svg+xml" width="400" height="300" pluginspage="http://www.adobe.com/svg/viewer/install/" /> </object>
Netscape Navigator 2.0 and 3.0 will ignore the
tags (because they do not understand them),
and instead attempt to render its contents (the
Newer browsers will render the
(if they think they know how to), and fall back on the
inner tag if they cannot.
Remember that this only applies if you want to support really quite old web browsers—didn’t NN 4 come out in 1996?.
Well-formed vs. valid (X)HTML
embed tag can be made
by inserting a space and a slash before the closing
(as described in Appendix C of the XHTML Recommendation):
<embed ... />
For many applications (and existing web browsers), being
well-formed is good enough. It is, however, not valid HTML or
XHTML. This is because
embed is not included in the DTDs
that specify standard HTML 4.
Of course one can supply one’s own DTD and thus change the definition of ‘valid’: either by editing the DTD, or by adding definitions in the internal DTD subset (outlined in the SVGWiki entry cited above).
Neither of these are necessary for current web browsers;
they do not validate HTML against its DTD explicitly.
In the future, when XHTML validity matters more,
embed tag is probably best consigned to the
dustbin of history.
On this site...
My readers will have noticed I often use
without anything inside it except a petulant message; I did this
because that way my friends will be able to tell whether their browser
groks SVG by seeing if an image appears at all... Some time
I should change it to use an inner
content in a different format entirely, such as PNG.
Update (14 February 2004). Safari 1.0 crashes when I use
SVG embedded with the
object tag. For this reason,
I have removed
object tags from this
site; I will reconsider this decision in 2008, when we can
assume that the vast majority of Safari users will have upgraded their
Macs beyond Mac OS X 10.2 (you cannot get Safari 1.1 or 1.2 for 10.2).
In the meantime, the
embed tag works fine in Safari, and in all other browsers.