SVG File Format — Complete Reference Guide | Flipper File
File Format Encyclopedia

SVG (.svg) File Format

Scalable Vector Graphics — the web's XML-based, resolution-independent image format that scales to any size without losing quality.

.svg / .svgz image/svg+xml XML-Based W3C Standard Open Format Born 1999
1999 Year Introduced
Infinite Scalability
XML File Structure
97%+ Browser Support
Last updated: June 2026

What is SVG?

SVG stands for Scalable Vector Graphics. Unlike raster image formats such as PNG or JPEG, which store images as grids of pixels, SVG describes images using mathematical shapes — lines, curves, circles, and paths — defined in plain XML text. The result is an image that can be rendered at any size, from a 16×16 favicon to a 10,000-pixel billboard, without any loss of sharpness or quality.

SVG was developed by the World Wide Web Consortium (W3C) and first proposed in 1999. The SVG 1.1 specification became a W3C Recommendation in 2003 and remains the widely-deployed standard today. SVG 2.0 is an ongoing W3C specification that adds features including better text layout, new paint server types, and closer alignment with CSS.

Because SVG files are plain XML text, they are human-readable, editable in any text editor, crawlable by search engines, and accessible to screen readers — advantages that no raster format can match.

i
Vector vs. Raster: A raster image (PNG, JPEG) stores color values for each pixel. If you scale it up, the software has to guess what the extra pixels should look like — causing blur. A vector image (SVG) stores the mathematical description of every shape. At any scale, the shapes are redrawn from scratch at full precision.

Technical Specifications

PropertyValue
Full NameScalable Vector Graphics
File Extensions.svg (plain), .svgz (gzip-compressed)
MIME Typeimage/svg+xml
File StructureXML 1.0 document
Developed ByWorld Wide Web Consortium (W3C)
First ReleaseSeptember 4, 2001 (SVG 1.0)
Current StandardSVG 1.1 (2nd Edition, 2011); SVG 2.0 (draft)
Namespace URIhttp://www.w3.org/2000/svg
EncodingUTF-8 (recommended), UTF-16
CompressionNone (plain .svg) or gzip (.svgz); also compresses well via HTTP gzip/brotli
Color ModelRGB (sRGB by default); ICC color profiles supported
TransparencyFull alpha transparency via opacity, fill-opacity, RGBA
AnimationSMIL declarative animation, CSS animations, JavaScript
InteractivityFull DOM access — event listeners, hover states, JavaScript manipulation
Accessibility<title>, <desc>, ARIA attributes supported
ScriptingJavaScript via embedded <script> tags
StylingInline styles, internal <style>, or external CSS
LicenseOpen W3C standard — royalty-free

File Structure & Syntax

An SVG file is an XML document. At minimum it needs a root <svg> element with the W3C namespace declaration and a viewBox attribute. Everything inside is standard XML — tags are case-sensitive, all attributes must be quoted, and every opened tag must be closed.

<!-- Minimal valid SVG -->
<svg xmlns="http://www.w3.org/2000/svg"
     viewBox="0 0 100 100"
     width="100" height="100">
  <!-- A blue circle -->
  <circle cx="50" cy="50" r="40"
           fill="#2563eb" stroke="#1e40af" stroke-width="2"/>
  <!-- Centered white label -->
  <text x="50" y="55"
        text-anchor="middle"
        font-family="sans-serif"
        font-size="14" fill="white">Hello</text>
</svg>
*
Inline vs. external SVG: SVGs can be embedded directly inside HTML (inline SVG) or referenced via <img src="logo.svg"> or CSS background-image. Inline SVGs allow full CSS and JavaScript control; external SVGs are simpler to cache but isolated from the page's styles.

Common SVG Attributes

AttributeWhat it does
viewBoxDefines the internal coordinate system: "min-x min-y width height". Makes the SVG scale correctly at any display size.
width / heightThe rendered size on screen. Use CSS or omit for fluid scaling.
xmlnsRequired namespace declaration: http://www.w3.org/2000/svg
preserveAspectRatioControls how the content fits when the aspect ratio of viewBox and the container differ.
fillFill color for shapes. Accepts named colors, hex, rgb(), or none.
strokeBorder/outline color. Use with stroke-width.
opacityOverall element transparency (0–1).
transformTranslate, rotate, scale, or skew any element: transform="rotate(45 50 50)".

SVG Element Types

SVG provides a rich vocabulary of elements for drawing shapes, rendering text, grouping content, applying effects, and controlling reuse.

Basic Shapes

<rect>

Rectangle. Set x, y, width, height. Add rx/ry for rounded corners.

<circle>

Circle defined by center point (cx, cy) and radius (r).

<ellipse>

Like circle but with separate x-radius (rx) and y-radius (ry).

<line>

A straight line between two points (x1,y1) and (x2,y2).

<polyline>

A series of connected line segments. Defined by a points list.

<polygon>

Closed shape from a points list. Auto-closes the last point to the first.

Paths

The <path> element is the most powerful shape in SVG. Its d attribute accepts a mini-language of commands: M (move to), L (line to), C (cubic bezier), Q (quadratic bezier), A (arc), and Z (close path). Uppercase commands use absolute coordinates; lowercase use relative.

<!-- A simple arrow using path commands -->
<path d="M 10 50 L 80 50 M 65 35 L 80 50 L 65 65"
      stroke="#16a34a" stroke-width="4"
      fill="none" stroke-linecap="round"/>

Text Elements

<text>

Renders a text string at position x, y. Supports font-size, font-family, text-anchor, etc.

<tspan>

Sub-element of text for inline style changes or relative positioning within a text run.

<textPath>

Renders text that flows along the curve of a path element.

Structure & Reuse

<g>

Group element. Applies transforms and styles to all children at once.

<defs>

Container for reusable definitions (gradients, filters, symbols) that aren't rendered directly.

<symbol>

Defines a reusable graphic with its own viewBox. Rendered via <use>.

<use>

Stamps a copy of a <symbol> or any element at a new location.

<clipPath>

Defines a clipping region. Only the parts of an element inside the clip are visible.

<mask>

Like clipPath but uses luminance or alpha channel for soft-edged masking.

Paint Servers & Filters

<linearGradient>

Defines a linear color gradient, referenced by fill or stroke.

<radialGradient>

Defines a circular color gradient radiating from a focal point.

<pattern>

Tiles a graphic as a repeating fill pattern.

<filter>

Container for filter effects (blur, shadow, color matrix, composite, etc.).

<feGaussianBlur>

Filter primitive that applies a Gaussian blur to the source graphic.

<feDropShadow>

Shorthand filter for a drop shadow (dx, dy, stdDeviation, flood-color).

Animation Elements

<animate>

Animates a single attribute value over time (SMIL-based).

<animateTransform>

Animates a transform (translate, rotate, scale) on an element.

<animateMotion>

Moves an element along a motion path over time.

*
SMIL vs. CSS animation: SVG's built-in SMIL animation (animate, animateTransform) works even in <img> tags and email clients. CSS animation requires inline SVG inside HTML. For complex interactive animations, JavaScript (GSAP, Anime.js) offers the most control.

Coordinate System & viewBox

SVG uses a Cartesian coordinate system where the origin (0, 0) is at the top-left corner. X increases to the right; Y increases downward. The viewBox attribute is what makes SVG truly scalable.

<!-- viewBox="min-x min-y width height" -->
<!-- This SVG uses 0–200 internally but renders at any CSS size -->
<svg xmlns="http://www.w3.org/2000/svg"
     viewBox="0 0 200 100"
     width="100%">
  <!-- Shapes use 0-200 / 0-100 coordinates -->
  <rect x="10" y="10" width="180" height="80"
        rx="8" fill="#dcfce7" stroke="#22c55e"/>
</svg>

Without viewBox, the SVG renders at the pixel dimensions specified by width and height and will not scale. With viewBox, the SVG can be set to width="100%" and will fill any container at perfect sharpness.

The preserveAspectRatio attribute controls what happens when the viewBox aspect ratio doesn't match the container. The default, xMidYMid meet, centers and scales uniformly (letterboxing). Use none to stretch, or xMidYMid slice to crop-fill like CSS background-size: cover.

SVG vs. PNG vs. WebP vs. GIF

Choosing the right format comes down to what kind of image you have and how it will be used. SVG is unmatched for graphics defined by shapes; raster formats win for photographs and camera imagery.

FeatureSVGPNGWebPGIFJPEG
Scales to any sizeYesNoNoNoNo
Best for photosNoOKYesNoYes
Best for logos/iconsYesOKOKNoNo
Transparency (alpha)FullFullFull1-bitNo
AnimationYes (SMIL/CSS)NoVia APNG-like specYes (limited)No
CSS stylingFullNoNoNoNo
JavaScript interactionFull DOMNoNoNoNo
Editable as textYes (XML)NoNoNoNo
Search-engine indexableYes (inline)NoNoNoNo
File size (simple icon, 24px)~500 B~2 KB~1.5 KB~1 KB~3 KB
File size (photo, 1200px)Very large~800 KB~120 KB~2 MB+~180 KB
Accessibility supporttitle, desc, ARIAalt text onlyalt text onlyalt text onlyalt text only
Browser support97%+ (IE9+)Universal95%+ (no IE)UniversalUniversal
Email client supportPoorExcellentGoodExcellentExcellent
!
Don't use SVG for email: Gmail, Outlook, and most other email clients do not render SVG. Use PNG or JPEG for any images in HTML email campaigns.

When to Use SVG (and When Not To)

Use SVG for...
Logos that appear at multiple sizes (favicon, header, print)
UI icons and icon systems
Data visualizations and charts (D3.js, etc.)
Illustrations with flat or gradient color fills
Animated graphics and microinteractions
Interactive infographics
Backgrounds, patterns, and decorative shapes
Any graphic that needs to look sharp on retina/HiDPI screens without serving multiple resolution files
Don't use SVG for...
Photographs and camera images (use JPEG or WebP)
Complex artwork with millions of anchor points (file will be huge and slow)
Email newsletter images (poor client support)
Raster-heavy effects like photo filters or halftones
Images shown in non-browser contexts (native iOS/Android, some office tools)
Screenshots and UI mockups (PNG is the right call)
*
Performance tip: Run SVG files through an optimizer (SVGO) before deploying. Design tools like Figma and Illustrator export SVGs with verbose metadata, editor annotations, and redundant attributes that can often be stripped to reduce file size by 30–70% while preserving visual output perfectly.

Browser & Platform Support

SVG 1.1 is supported in all modern browsers and has been since Internet Explorer 9 (released 2011). CSS animations and transitions work in all evergreen browsers. SMIL animation support dropped in Blink-based browsers (Chrome/Edge) for a period but has since been retained. JavaScript DOM manipulation of inline SVG works everywhere modern.

✓ Chrome v4+ (2010)
✓ Firefox v3+ (2010)
✓ Safari v3.1+ (2008)
✓ Edge v12+ (2015)
✓ IE v9+ (2011)
SVG FeatureChromeFirefoxSafariEdge
Basic shapes & pathsFullFullFullFull
CSS animationFullFullFullFull
SMIL animationFullFullFullFull
Filters (blur, shadow)FullFullFullFull
Inline SVG in HTML5FullFullFullFull
foreignObjectFullFullPartialFull
SVG in CSS backgroundFullFullFullFull
SVG fontsDroppedDroppedPartialDropped
!
SVG in <img> tags is sandboxed: When used via <img src="file.svg">, the browser blocks scripts and external references. Use inline SVG to access the DOM, run JavaScript, or load external fonts inside the graphic.

Creating & Editing SVG Files

SVG can be created by hand in any text editor, exported from a vector design application, or generated programmatically by code. Each approach has its place.

Design Tools (GUI)

ToolTypeNotes
FigmaWeb app (free/paid)Clean SVG export; use "Include id attribute" for JS targeting. Strips unnecessary metadata well.
Adobe IllustratorDesktop (paid)Industry standard. Use "SVG 1.1" profile on export. Verbose output — run SVGO after.
InkscapeDesktop (free)Open-source, full-featured. Native format is SVG. Good for hand-editing complex paths.
Affinity DesignerDesktop (paid)Clean exports, good value alternative to Illustrator.
SketchDesktop (paid, macOS)Good SVG export; popular for icon libraries.
CanvaWeb app (free/paid)Exports SVG for Pro users. Output tends to be verbose.

Code & Libraries

LibraryLanguageBest For
D3.jsJavaScriptData-driven SVG charts and visualizations. The gold standard for complex SVG generation.
Snap.svgJavaScriptSVG manipulation and animation library. Like jQuery for SVG.
GSAP (SVG plugin)JavaScriptHigh-performance animation of SVG elements with fine timeline control.
SVG.jsJavaScriptLightweight library for SVG creation and manipulation.
CairoSVGPythonConverts SVG to PNG/PDF on the server side.
Sharp (via resvg)Node.jsFast server-side SVG rasterization to PNG/JPEG.

Optimizing SVG

Design tools export SVG with editor metadata, unused definitions, verbose decimal precision, and attribute duplication that inflates file size. Always optimize before deploying.

ToolTypeNotes
SVGOCLI / Node.jsThe standard SVG optimizer. Dozens of configurable plugins. Typical savings: 20–60%.
SVGOMGWeb appGUI wrapper around SVGO. Paste SVG and toggle plugins visually. Free at jakearchibald.github.io/svgomg/
Vecta NanoWeb appAlternative optimizer; sometimes smaller than SVGO on complex paths.

Converting SVG Files

SVG to PNG / JPEG (Rasterizing)

Converting SVG to a raster format is called rasterizing. You'll want to do this when you need a fixed-size image for a context that doesn't support SVG — such as email, Open Graph (social share) images, app store screenshots, or Microsoft Office.

MethodQualityNotes
Browser screenshotGoodOpen SVG in browser, screenshot. Simple but no resolution control.
Inkscape CLIExcellentinkscape input.svg --export-filename out.png --export-width 1200
Sharp (Node)ExcellentVia resvg-js: high-fidelity, fast, runs server-side or in CI.
CairoSVG (Python)Very goodcairosvg input.svg -o out.png --output-width 1200
Figma / IllustratorExcellentExport at any resolution with full font/effect rendering.

PNG / Illustrator / Other Formats to SVG (Vectorizing)

Converting a raster image to SVG is called vectorizing or auto-tracing. Results vary dramatically based on the complexity and content of the source image. Simple flat-color logos trace well; photographs generally do not.

ToolNotes
Inkscape (Trace Bitmap)Free; uses potrace. Good for logos and silhouettes. Path > Trace Bitmap.
Adobe Illustrator (Image Trace)Industry standard. Multiple presets for logos, photos, line art.
Vector MagicWeb/desktop app, paid. Among the best automated vectorization quality.
Vectorizer.ioFree web app. Fast AI-based vectorization for simple graphics.
!
Vectorization is not magic: Auto-tracing a photo will produce a huge SVG file with hundreds of complex paths — far larger than the original JPEG and slow to render. Vectorization works well only for clean, flat-color artwork. For photos, stick with WebP or JPEG.

Frequently Asked Questions

What does SVG stand for?

SVG stands for Scalable Vector Graphics. "Scalable" refers to the fact that the image can be displayed at any size without losing quality. "Vector" means the image is described with mathematical shapes (lines, curves, polygons) rather than a grid of pixels. "Graphics" is simply the output format — a 2D image.

Why is my SVG blurry?

A blurry SVG is almost always caused by a missing or incorrect viewBox attribute. Without viewBox, the browser renders the SVG at fixed pixel dimensions and scales it up pixel-by-pixel like a raster image. Fix: add viewBox="0 0 W H" where W and H match your internal coordinate space. Then set width="100%" or a CSS size — the browser will re-render it at crisp resolution.

Can SVG files contain malware?

Yes — SVG files can contain embedded JavaScript via <script> tags, which is why many file upload systems block SVG by default. When an SVG is rendered inline in a webpage it shares the document's JavaScript execution context, so malicious scripts inside it could run. Mitigations: serve SVGs from a separate CDN domain, use <img> tags (which sandbox scripts), sanitize uploaded SVGs with a library like DOMPurify's SVG mode, or disallow SVG uploads in your CMS entirely.

What is the difference between .svg and .svgz?

An .svgz file is simply an SVG file that has been gzip-compressed. The contents are identical to a .svg file; the file is just smaller on disk. Servers must send the Content-Encoding: gzip header when serving .svgz so that browsers decompress it correctly. In practice, most servers now apply gzip or Brotli compression on the fly to .svg responses, making .svgz files largely unnecessary — a plain .svg served with HTTP compression achieves the same transfer size.

Can I use SVG in a CSS background-image?

Yes. Both external file references (background-image: url('icon.svg')) and inline data URIs (background-image: url("data:image/svg+xml,...")) work in all modern browsers. However, SVG used via CSS background-image is fully sandboxed — scripts won't run and external references (fonts, images) won't load. For decorative background shapes and patterns this is ideal.

How do I make an SVG responsive?

Three things are needed: (1) add a viewBox attribute to the root <svg> element; (2) remove any fixed width and height attributes, or set them to width="100%"; (3) optionally set max-width in CSS to cap the maximum display size. The SVG will then scale fluidly to fill its container. If you're using inline SVG, also make sure no outer wrapper has a fixed width that prevents the container from shrinking.

Does Google index text inside SVG files?

Google can index text content in inline SVG (embedded directly in HTML) and in .svg files that are linked from pages. However, text in SVG is not treated the same as body HTML — it doesn't carry the same ranking weight and may not appear in featured snippets. For SEO-critical text, always use actual HTML text alongside or instead of SVG text. SVG files can also carry <title> and <desc> elements that Google reads.

What is the best way to use SVG icons on a website?

The recommended approach in modern web development is an SVG sprite: define all icons as <symbol> elements inside a hidden <svg> block in the page (or a separate file loaded once), then reference each icon anywhere on the page with <use href="#icon-name">. This approach gives you one HTTP request for all icons, easy CSS color control via currentColor, and no duplication. The alternative — individual inline SVGs — works fine for small icon counts but becomes verbose at scale.

Cite or link to this page

Flipper File. "SVG File Format — Complete Reference Guide." Flipperfile.com, June 2026. https://flipperfile.com/file-formats/svg/

Leave a Reply

Your email address will not be published. Required fields are marked *

Flipper File