You added an SVG to your website. You open the page. Nothing — just a blank space where your image should be. Or a broken image icon. Or the dreaded alt text. SVG loading issues are frustrating because SVGs are supposed to "just work." Here's why they often don't, and how to fix each problem.
Your web server must tell the browser "this is an SVG file" by sending the correct Content-Type header. If the server sends the wrong type, the browser may refuse to render it.
How to check: Open DevTools (F12) → Network tab → find your SVG file → check the Response Headers for Content-Type: image/svg+xml.
Fix: Add this to your .htaccess (Apache) or nginx.conf:
AddType image/svg+xml .svg (Apache)
types { image/svg+xml svg; } (Nginx)
You can't put raw SVG code inside an <img src="..."> — the src attribute expects a URL, not XML code. This won't work:
<img src="<svg>...</svg>"> ❌
Fix: Either save the SVG as its own .svg file and link to it, or embed it inline directly in HTML without an <img> tag.
When embedding SVG inline in HTML, the SVG tag must include the namespace attribute:
<svg xmlns="http://www.w3.org/2000/svg">
Without xmlns, the browser treats your SVG as unknown custom HTML elements rather than vector graphics. This is the #1 cause of inline SVGs not rendering.
If your SVG is hosted on a different domain than your website, the browser may block it due to Cross-Origin Resource Sharing (CORS) policy. This is common when loading SVGs from a CDN or image hosting service.
Fix: Either host the SVG on the same domain as your site, or configure the external server to send Access-Control-Allow-Origin: * headers.
Your file is named logo.svg but it's actually a PNG or JPEG that someone renamed. This happens surprisingly often — especially with files from design tools that export with the wrong extension.
Fix: Open the file in a text editor. If it starts with <svg or <?xml, it's genuinely SVG. If it looks like garbled binary, it's a raster image with the wrong extension.
Your page's CSS might be hiding or overriding SVG styles. Common culprits:
img { display: none; } or img { width: 0; height: 0; }<svg> default dimensionsoverflow: hidden and zero heightFix: Give your SVG explicit width and height attributes, and check DevTools to see if CSS is hiding it.
Design software sometimes exports SVG with invalid XML — unclosed tags, illegal characters, or broken path data. Browsers are strict about SVG syntax.
Fix: Run your SVG through an SVG validator/optimizer like SVGO. It cleans up invalid markup automatically.
You fixed the SVG but you're still seeing the broken version. Clear cache (Ctrl+Shift+R) or open in an incognito window to rule out caching.
image/svg+xml? ✅ Server config OK → check markup<svg> have xmlns="http://www.w3.org/2000/svg"? ✅ Markup OK → check CSS