Simply put, I have an SVG graphic embedded in HTML that refuses to display in Safari (although it works fine in Chrome, Firefox, and other browsers).
I'm using the following markup to accomplish this:
<img alt="grapefruit logo" src="/assets/better-gf-logo_red.svg" />
Here is a live link to the the page where the SVG is not displaying. The fruit logo in the top left corner does not display in Safari: https://grapefruit.cs.rpi.edu/.
I have verified the following line is also present in my nginx mime.types
:
image/svg+xml svg svgz;
However, I know that the issue is probably not related to mime types, since the SVG doesn't appear in Safari on my development machine either (I tested several web servers). I have also tried displaying the SVG file itself in Safari, and it looks fine. The image element has the right size and box model, but it is not displaying any content.
Like the <img> method described above, inserting SVGs using CSS background images means that the SVG can't be manipulated with JavaScript, and is also subject to the same CSS limitations. If your SVGs aren't showing up at all, it might be because your server isn't set up properly.
SVG (basic support) is Fully Supported on Safari 12, which means that any user who'd be accessing your page through Safari 12 can see it perfectly.
If you are trying to use SVG like <img src="image. svg"> or as a CSS background-image , and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type.
Turns out that <img src="image.svg">
will not work in Safari, I tried using <object>
and it worked. Give this a try: jsBin demo
<object
type="image/svg+xml"
height="70"
width="150"
data="/assets/better-gf-logo_red.svg">
</object>
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With