Debugging inline SVG: six places to look
Because an inline SVG lives in the DOM, any browser DevTools can inspect it, which makes it possible to trace what's going wrong and where. When an SVG isn't visible at all, these are the six things worth checking first.
1. Check the viewBox
Inline SVG works without a viewBox, but you lose its biggest advantage: scaling with the container. Configured incorrectly, it also works against you and clips content. Clipped elements haven't disappeared — they sit in a part of the coordinate system the viewport doesn't show. The quick fix is overflow="visible" on the SVG, added through the stylesheet, the inline style attribute, or as a presentation attribute. If the SVG carries a background-color or sits near other elements, that approach can look off; editing the viewBox to include the hidden region is the better option.

How the coordinate system works
SVG renders on an infinite canvas, and two things govern what you see. The viewport is the window onto that canvas, sized by the width and height attributes or the matching CSS properties; any length unit works, and unitless values default to pixels. The viewBox takes four values: the first two are the x and y starting point at the upper-left corner (negative values allowed), the last two are the width and height of the coordinate system inside the viewport — the pair that controls scale.
<svg viewBox="0 0 700 700" width="700" height="700">
<!-- etc. -->
</svg>
Reframing versus zooming
By default the viewport begins where 0 on the x-axis meets 0 on the y-axis. Changing the first two viewBox values to 300 and 200 keeps the width and height at 700 units each but shifts the origin to that point. A red <circle> centered at 300, 200 then moves to the frame's upper-left corner, while the SVG still renders at 700×700. That is reframing: no scaling, just a different window.
<svg viewBox="0 0 700 700">
<svg viewBox="300 200 700 700">
The last two values do the zooming. Larger numbers mean more SVG units fit into the viewport, so the image gets smaller. A 1:1 ratio requires the viewBox width and height to match the viewport's. In Illustrator the artboard stands in for the viewport; a blue dot at 900, 900 sits outside a 700px artboard and gets clipped. Change those values from 700 to 900 and the dot returns almost fully to view: the image scales down, the actual width and height stay the same, and a pink square shows the grid scaling — smaller units, more grid lines inside the same area.
<svg viewBox="300 200 900 900" width="700" height="700">
2. Supply width and height
Missing width or height attributes often cause no trouble, but inside an absolutely positioned or flexible container they prevent the full image from showing — Safari computes the SVG width as 0px rather than auto. Adding a width or height fixes it, whether as a presentation attribute, in the style attribute, or in CSS. Steer clear of setting height alone, especially to 100% or auto; defining both the left and right values is another workaround.
3. Clear conflicting fill and stroke
Coloring the <svg> tag through inline style or CSS is fine, but color values elsewhere in the markup or styles can conflict with it and make parts of the graphic invisible. Looking for fill and stroke attributes in the markup and removing them is a reliable step. In a demonstration, an SVG styled red via CSS had a few white fills hardcoded in the markup; stripping those revealed the missing pieces.
4. Verify that IDs still match
Naming layers in Illustrator so the exported markup has matching IDs, then styling through those IDs, is a sound workflow — until an SVG is exported again to the same location and the IDs change. Adding a layer, renaming one, or copy-pasting vectors directly can all do it, and the CSS rules silently stop matching, changing how the SVG renders. In large files the mismatched IDs are hard to spot by hand, so inspect the failing part of the graphic in DevTools. Before swapping a file, open the exported SVG in a code editor and compare it with the original; Illustrator, Figma and Sketch are smart tools, but vetting their output is still on you.

5. Work through clipping and masking
When an SVG is unexpectedly clipped and the viewBox is correct, check the CSS for clip-path or mask — the relevant styling may not live in the inline markup at all. <clipPath> is a vector operation that cuts with no partial results, while <mask> is a pixel operation supporting transparency, semi-transparency and blurred edges. For either, work through this list:
- The clipping path or mask and the graphic must overlap; only the overlapping parts display. For a complex path that doesn't intersect the graphic, apply transforms until they do.
- DevTools can still inspect the inner code even though
<clipPath>or<mask>elements aren't rendered. - Copy the markup inside
<clipPath>or<mask>, paste it before the closing</svg>tag, and give those shapes afillto check coordinates and dimensions. If nothing appears, tryoverflow="hidden"on the<svg>tag. - Use a unique ID for the
<clipPath>or<mask>and reference that same ID from the clipped or masked shapes; a mismatch breaks the appearance. Also check for typos between the tags. - Styles inside
<clipPath>such asfill,strokeoropacityhave no effect — only the fill-region geometry counts. A<polyline>behaves like a<polygon>, and a<line>produces no clipping at all. - A mask whose content is entirely black makes the image disappear: the masking element's luminance sets the final opacity, so brighter parts show through and darker parts hide content.
6. Declare the namespace
SVG is XML-based, and its namespace lives on the xmlns attribute.
<svg xmlns="http://www.w3.org/2000/svg">
<!-- etc. -->
</svg>
The namespace tells the browser the markup is specifically SVG and helps avoid conflicts when more than one XML type shares a file, such as SVG and XHTML — rare in modern browsers, but a possible explanation for rendering problems in older ones or in strict engines like Gecko when doctypes and namespaces are defined. SVG 2 does not require namespacing in HTML syntax, but it is crucial if legacy browser support matters, and adding it costs nothing: when the <html> element's xmlns attribute is defined, conflicts won't arise. The same holds for SVG inlined in CSS, such as a background image.
textarea:valid {
background: white url('data:image/svg+xml,\
<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26">\
<circle cx="13" cy="13" r="13" fill="%23abedd8"/>\
<path fill="none" stroke="white" stroke-width="2" d="M5 15.2l5 5 10-12"/>\
</svg>') no-repeat 98% 5px;
}
Another common prefix is xlink:href, widely used to reference patterns, filters, animations and gradients. Since SVG 2 it is deprecated in favor of href, though older browsers may have compatibility issues, so using both is an option — provided you add xmlns:xlink="http://www.w3.org/1999/xlink".
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<body>
<svg xmlns="http://www.w3.org/2000/svg" width="700px" height="700px">
<!-- etc. -->
</svg>
</body>
</html>


