Inserting SVGs into your web pages
There are a number of things that you can do with SVG images that you can’t do with normal image formats (JPEG, GIF, and PNG). The range of what’s possible is largely dependent on the way that the SVG is inserted into the page.
So, before we get to what we can actually do with SVGs, we’ll consider the various ways we can actually get them on the page in the first place.
Using an img tag
The most straightforward way to use an SVG graphic is exactly how you would insert any image into an HTML document. We just use a good ol’ img
tag:
<img src="mySconeVector.svg" alt="Amazing line art of a scone" />
This makes the SVG behave more or less like any other image. There isn’t much else to say about that.
Using an object tag
The object
tag is the container recommended by the W3C for holding non-HTML content in a web page (the specification for object
is here: https:...