SVG files can be embedded in HTML documents with the following tags:
<
embed
>
,
<object>
or
<iframe>
.
The code for SVG can be embedded directly into the HTML page, or you can link directly to the SVG file. Advantages: all major browsers support it and allow scripting Cons: not recommended for use in HTML4 and XHTML (but allowed in HTML5) Syntax: Results: Advantages: all major browsers support HTML4,XHTML and HTML5 standards Cons: scripts are not allowed. Syntax: Results: Advantages: all major browsers support it and allow scripting Cons: not recommended for use in HTML4 and XHTML (but allowed in HTML5) Syntax: Results: In Firefox, Internet Explorer9, Google Chrome, and Safari, you can embed SVGcode directly in HTML. You can also use the You can also use the Result: view SVG fil 1.4.1. Use
<embed>
label ¶
<embed>
:<embed src="circle1.svg" type="image/svg+xml" />
1.4.2. Use
<object>
label ¶
<object>
:<object data="circle1.svg" type="image/svg+xml"></object>
1.4.3. Use
<iframe>
label ¶
<iframe>
:<iframe src="circle1.svg"></iframe>
1.4.4. Embed SVG code directly in HTML ¶
Example ¶
<svgxmlns="http://www.w3.org/2000/svg"version="1.1"><circlecx="100"cy="50"r="40"stroke="black"stroke-width="2"fill="red"/></svg>
1.4.5. Link to SVG file ¶
<a>
tag link to an SVG file: link to a SVG file
<a>
the tag links to an SVG file:<a href="circle1.svg">View SVG files</a>