Should I use , , or for SVG files?

To add SVG files, you can use , or element in HTML. Choose any one of them according to your requirement. Here’s how you can add SVG,

element

Use the tag for images without interaction.

The disadvantage is you cannot manipulate images with JavaScript.

<img src = "new.svg" alt = "craft" height = "100px" width = "100px" />

element

The element is used to define an embedded object within an HTML document. Use it to embed multimedia like audio, video, flash, etc in the web page.

<object type = "image/svg+xml" data = "new.svg">
   Your browser does not support SVG
</object>

element

The tag wasn’t part of the HTML 4 specification and is new in HTML5. It validates in an HTML5 page.

<embed type = "image/svg+xml" src = "image.svg" />
Updated on: 2020-06-26T06:36:09+05:30

521 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements