Jaanus
Jaanus

Reputation: 16561

SVG to HTML/CSS

Well I have an SVG file named 7.svg.

How can I display the image with HTML or CSS in my index.html?

Upvotes: 1

Views: 410

Answers (3)

doug65536
doug65536

Reputation: 6791

<img> tags support SVG. Just add <img src="/path/to/svg.svg"> to the page.

Example. Image of Tux

Take control of the size with CSS.

Upvotes: 1

Baz1nga
Baz1nga

Reputation: 15579

Well you can do this in three different ways.

Using the <embed> Tag

<embed src="7.svg" width="300" height="100"
type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/" />

Using the <object> Tag

<object data="7.svg" width="300" height="100"
type="image/svg+xml"
codebase="http://www.adobe.com/svg/viewer/install/" />

Using the <iframe> Tag

<iframe src="7.svg" width="300" height="100">
</iframe>

Tell me which one works out for you. Please run it on differnt browsers and let me know.

HTML 5 info:

Since your are using HTML 5 you probably wanna check out this: http://www.whatwg.org/specs/web-apps/current-work/#svg Its still under work and is partially implemented in Firefox, Safari, Opera (xhtml5 serialization only)

https://developer.mozilla.org/en/svg_in_html_introduction

Upvotes: 4

underdoeg
underdoeg

Reputation: 1911

Add this somehwere in your html file

<embed src="7.svg" width="300" height="100"
type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/" />

taken from w3schools

Upvotes: 1

Related Questions