SponsorHueclip · A moodboard maker for designers. Clip fonts, colors and screenshots. · Moodboard makerTry it
  1. Dashboard
  2. Svg Document Structure
Local Processing
MintConvertMintConvertMintConvert•100% Client-Side

© 2026 MintConvert. Files process locally in your browser and never touch a server.

All ToolsGuidesAboutFAQPrivacyTermsCookiesllms.txtDonate
Crafted byNikhil SaiNikhil Sai
MintConvertMintConvertMintConvert
Tools
PNG to SVGJPG to SVGWebP to SVGImage to SVGDXF to SVGGIF to SVGBMP to SVGICO to SVGTIFF to SVG
SVG to PNGSVG to JPGSVG to WebPSVG to ICOSVG Code to ImageSVG ConverterSVG to PDFSVG to STLSVG to DXFSVG to BMPSVG to GIFSVG to TIFF
SVG to CodeQR Code SVGBarcode Generator SVGSVG to Base64SVG FormatterSVG ValidatorSVG Sprite GeneratorBase64 to SVG
SVG ViewerSVG AnimatorSVG EditorSVG Background RemoverSVG CompressorSVG MakerSVG ResizerSVG CropperSVG Color ChangerSVG Rotate & FlipSVG MergerSVG Path EditorText to SVGSVG Wave GeneratorSVG Blob GeneratorSVG Pattern Generator
GuidesAboutDonate

SVG Documents Explained: Structure, Elements and Examples

How SVG documents are structured: the root element, namespace, viewBox, groups, definitions, reuse, drawing order and the errors that stop a file rendering.

November 27, 2026 · MintConvert Team

"Open an exported graphic in a text editor and you may see a wall of tags. Once you know how the parts fit together, you can find the shape you want and spot why something is broken.

This guide is about what's inside the markup. For the basics of the format, read what an SVG file is.

A complete example

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 60" role="img" aria-labelledby="t d">
  <title id="t">Two leaves</title>
  <desc id="d">Two green circles side by side</desc>
  <defs>
    <circle id="dot" r="20" />
  </defs>
  <g fill="#10b981">
    <use href="#dot" x="35" y="30" />
    <use href="#dot" x="85" y="30" />
  </g>
</svg>

The root element

Everything sits inside <svg>. The W3C specification calls an svg element and its contents an SVG document fragment. It can be a standalone file or part of another document.

AttributeWhat it does
xmlnsDeclares the SVG namespace. Standalone files need it
viewBoxSets the internal coordinates: min-x, min-y, width, height
width, heightSet the size of the outermost graphic. CSS can also size it
preserveAspectRatioControls the fit when the box and viewBox shapes differ

When SVG markup is written inline in an HTML page, the HTML parser handles the namespace for you.

Title and description

<title> gives the graphic a short name, and <desc> adds detail. Connecting them with aria-labelledby, as above, helps assistive technology. Test with a screen reader if the graphic carries important information, since support varies.

Groups, definitions and reuse

  • `<g>` groups elements. Presentation attributes such as fill can be inherited by its children, and a transform moves the whole group.
  • `<defs>` holds things you define now and use later, such as gradients and clip paths. Its contents aren't drawn directly.
  • `<symbol>` is a reusable template that can have its own viewBox.
  • `<use>` draws a copy of an element you reference by id.

An id should be unique. This matters when you place several graphics inline on one page, because repeated IDs can make a gradient or clip path point to the wrong definition.

Drawing order

Elements are painted in document order. In general, a later element appears on top of an earlier one. If a shape is hidden, check whether something after it covers it.

Styling

You can set appearance with attributes (fill="red"), a style attribute, or a <style> block. CSS rules override presentation attributes, which explains why changing fill sometimes does nothing. Inline <style> rules can also affect other elements on the same HTML page, so use specific class names.

Reading a messy file

Exports are often minified or full of editor data. An SVG formatter adds indentation so you can follow the nesting. Keep an untouched copy before editing.

Why a document fails to render

SymptomLikely cause
XML parsing errorUnclosed tag, unquoted attribute or a bare & (write &amp;)
Works inline but not as a fileMissing xmlns
Blank areaShapes fall outside the viewBox or have no visible paint
Gradient or clip is missingThe referenced id doesn't exist or is duplicated
Picture or font is missingThe file depends on an external resource

An SVG validator checks syntax and references. To see the result as you work, use an SVG viewer.

Key takeaways

Start at the root, check xmlns and viewBox, then follow the groups and references. Keep IDs unique and remember that later shapes are painted over earlier ones.

Frequently asked questions

More articles

November 27, 2026

SVG Files for Cricut: Free Downloads, Licenses and Uploading

Using SVG files for Cricut? Learn where to get free downloads, how to check the license, how to upload to Design Space and how to fix files that look wrong.

Read article
November 27, 2026

SVG Image Element: How to Add Pictures Inside an SVG

Use the SVG image element to place PNG, JPG or SVG pictures inside a graphic. Covers href, sizing, cropping, shaped clips, embedding and missing images.

Read article
November 27, 2026

How to Use an SVG Shape as a Background Image in CSS

Use an SVG shape as a background image in CSS. Covers sizing, stretching, placement, data URIs, changing color with masks and fixes for common problems.

Read article
All articles

On this page