A minimal valid SVG file
Every standalone SVG needs a root element with a namespace. A viewBox makes it scale cleanly:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <circle cx="12" cy="12" r="10" fill="#7c4dff"/> </svg>
Tips for clean SVG code
- Keep a
viewBoxand drop fixedwidth/heightwhen the SVG should scale with CSS. - Give meaningful
ids to groups you will target from CSS or JavaScript. In Vectopea, layer names become ids on export. - Put reusable gradients and filters in
<defs>and reference them withurl(#id). - Remove editor metadata and round coordinates to two decimals to cut file size. Vectopea writes rounded path data and offers a minified export.
Code or canvas?
Code is fastest for small tweaks: a colour, a stroke width, an attribute. For drawing, reshaping curves or aligning shapes, use the online SVG editor. For a single path's d attribute, the SVG path editor shows every node.