FileExamples
.svg

SVG File Format

SVG (Scalable Vector Graphics) is an XML-based vector image format for two-dimensional graphics that scales to any size without quality loss.

Extension .svg
MIME image/svg+xml
Magic Bytes <?xml or <svg (text-based)
Encoding UTF-8 XML (can be gzipped as .svgz)
Compression None (text); Gzip for .svgz
Spec W3C SVG 1.1 / SVG 2.0 (draft)
Max Size No limit (practical: rendering performance)

Sample SVG Files

View all
File NameSizeDescriptionAction
Vector Icon Set25 KBDownload
SVG Illustration45 KBDownload

Overview

SVG (Scalable Vector Graphics) is a W3C standard for describing two-dimensional vector graphics using XML. Unlike raster formats (JPG, PNG), SVG images are resolution-independent and can scale to any size without pixelation or quality loss. SVG supports shapes, paths, text, gradients, filters, animations (SMIL and CSS), interactivity (JavaScript), and accessibility attributes. It is the standard for icons, logos, illustrations, data visualizations, and interactive graphics on the web.

History

SVG development began at the W3C in 1999 and SVG 1.0 was published in 2001. SVG 1.1 (2003) became the widely adopted version. Browser support was initially poor, but by 2011 all major browsers supported SVG natively. SVG 2.0 (in development) integrates more tightly with CSS and HTML. The rise of responsive web design, icon systems, and data visualization libraries (D3.js) accelerated SVG adoption. Today SVG is essential for modern web development.

File Structure

An SVG file is an XML document with a root <svg> element containing graphical elements: <rect>, <circle>, <ellipse>, <line>, <polyline>, <polygon>, <path>, <text>, <image>, <g> (group), and <use> (reuse). Styling uses CSS or presentation attributes. The viewBox attribute enables responsive scaling. Definitions (<defs>) contain reusable elements like gradients, patterns, and clip paths. SMIL or CSS can animate any attribute.

Common Use Cases

  • Icons and icon systems
  • Logos and branding assets
  • Data visualizations and charts (D3.js)
  • Illustrations and infographics
  • Interactive maps and diagrams
  • Animated web graphics
  • Print-ready vector artwork
  • Responsive design elements

Advantages

  • Infinite scalability — crisp at any size
  • Small file size for simple graphics
  • Editable with text editors and CSS
  • Supports animation and interactivity
  • Accessible — text is selectable and searchable
  • Can be inlined directly in HTML

Disadvantages

  • Not suitable for complex photographs
  • File size grows with complexity (many paths)
  • Performance issues with very complex SVGs
  • Inconsistent rendering across older browsers
  • Security concerns when accepting user-uploaded SVGs

Frequently Asked Questions

What is an SVG file?

An SVG file is a vector graphics format based on XML that describes shapes, text, and paths mathematically. Unlike JPG or PNG, SVG images can scale to any size without losing quality.

How do I open an SVG file?

SVG files can be opened in any web browser (Chrome, Firefox, Safari, Edge), vector editors (Illustrator, Inkscape, Figma), and many image viewers. They can also be opened in any text editor since they are XML.

SVG vs PNG — when should I use each?

Use SVG for icons, logos, illustrations, and graphics that need to scale. Use PNG for photographs, screenshots, and complex raster images. SVG is typically smaller for simple graphics.

Can I use SVG in HTML?

Yes. You can embed SVG inline in HTML, reference it with an <img> tag, use it as a CSS background-image, or load it with an <object> tag. Inline SVG allows CSS styling and JavaScript interaction.