views:

340

answers:

3

Hi, I want to know how can one actually use a .svg file In a web page?

Thanks, Parastar

+1  A: 

http://www.w3schools.com/svg/svg_inhtml.asp

The best example:

<embed src="rect.svg" width="300" height="100"
type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/" /> 
Brian McKenna
would this actually show the svg image on any browser?Thanks?
Parastar
It should show on all the major browsers.
Brian McKenna
Thanks,but whats the 'pluginspage' all about?can't catchup with that one?
Parastar
pluginspage tells the browser where to get a plugin if it can't display SVG files natively (e.g. Internet Explorer).
Brian McKenna
so the image would not be visiable If the user doesn't download the plugin?
Parastar
It would be visible to Firefox, Chrome and Safari users but Internet Explorer users will need to have to plugin installed. If that's a problem then code-zoop's solution does some fancy work to remove the plugin dependency.
Brian McKenna
Note that code-zoop's solution (RaphaelJS) "removes the plugin dependency" by not actually using SVG at all on IE. If you're looking specifically to display an "svg file", that is probably not going to help you. For SVG + all major browsers, IE users will need a plugin.
Ken
+2  A: 

Raphaël—JavaScript Library. Nice javascript library that is using svg, and gives you a large range of effects!

Also supports most browsers, including IE

code-zoop
+1  A: 

See svgweb quickstart and the svgweb project homepage for something that works in all browsers including IE (requires flash plugin).

There are many ways to include an existing svg file:

  • <img src="your.svg"/> [webkit, opera]
  • <object data="your.svg"/>
  • <iframe src="your.svg"/>
  • <embed src="your.svg"/>
  • <div style="background:url(your.svg)">...</div> [webkit, opera]
Erik Dahlström