[whatwg] How to use SVG in HTML5?

Mathieu HENRI p01 at opera.com
Wed Jan 23 09:19:37 PST 2008


James Graham wrote:
> David Gerard wrote:
>> Forgive me if this is a simple and obvious question. I note that all
>> current browsers (except IE, of course) implement SVG rendering (to a
>> better or worse degree). I'd like to be able to drop SVG images into
>> an HTML page as easily as I can a JPEG or PNG. I read over the
>> recently-released HTML5 draft and couldn't work out how I'd do this.
>>
>> What would the HTML to do this look like? What's the equivalent of
>> <IMG SRC="foo.jpg"> for foo.svg?
> 
> In browsers which support it <img src="foo.svg"> will work (with certain 
> limitations for security reasons). If you want to embed svg inline like 
> you can with XHTML, that's not currently supported, although several 
> people have expressed an interest in changing that. However there are 
> significant technical barriers to overcome at the syntax/parser level.

Supporting <img src="foo.svg"> is a requirement of SVG 1.1 [1]

	" If the user agent includes an HTML or XHTML viewing capability or can apply 
CSS/XSL styling properties to XML documents, then a Conforming SVG Viewer 
*must* support resources of MIME type "image/svg+xml" wherever raster image 
external resources can be used, such as in the HTML or XHTML 'img' element and 
in CSS/XSL properties that can refer to raster image resources (e.g., 
'background-image') "



[1] http://www.w3.org/TR/2003/REC-SVG11-20030114/conform.html#ConformingSVGViewers


-- 
Mathieu 'p01' HENRI
JavaScript developer, Opera Software ASA



More information about the whatwg mailing list