Scalable Vector Graphics
lastmod 2026-03-05created 2015-06-1057 edits
Scalable Vector Graphics (SVG) is an XML-based file format for representing two-dimensional vector graphics. It is an open-standard vector graphics file format developed in 1999 under the lead of the W3C (World Wide Web Consortium). SVG images and their behavior are defined in XML text files, so they can be searched, indexed, and scripted, and compressed if needed.
SVG files can be edited with professional SVG-based graphics editing programs. Of course, since they are XML files, they can also be edited with a text editor.
Currently, most major web browsers support SVG, except Microsoft Internet Explorer 8 and earlier versions. In Internet Explorer, a separate plugin must be installed manually to view SVG files; otherwise, the web page author must include SVG Web, a JavaScript library under development on Google Code, in the web page code.
Categories
- Web typography#Inline SVG - How to inline SVG directly on the web. (related to v-icon)
Libraries
- SVG++
- nanosvg - https://github.com/memononen/nanosvg
- libsvgtiny
- Blend2D: http://blend2d.com/
- SVGInject - Helps inject SVG files into the DOM.
- TinyVG
- scour - An SVG optimizer/cleaner written in Python.
- SVGsplit - Tool for splitting svg files
- svg.py (python)
- svglib (python)
- CairoSVG (python)
- pynanosvg (python)
- svgpathtools (python)
- SVGO - Node.js-based open-source SVG optimization tool
Online tools
- Heazy - Vector design studio
- Create and easily edit vector visualizations
- Can export SVG/PNG or copy as a JS/TS React Snippet
- Can save as templates for reuse
- No sign-up required. Free
- Create SVG avatars
- Text-to-SVG AI
Vector graphics editor Projects
Plugins
Examples
Resources
- Tabler Icons 558 Fully customizable free SVG icons. (MIT license)
SVG Tag
The overall SVG canvas size is 200x200 pixels. However, using the viewBox attribute, a 100x100px view starting at (0,0) is displayed on a 200x200px screen.
viewBox
- viewBox - SVG: Scalable Vector Graphics | MDN
- Resizing SVG for developers
- [Recommended] 🎨 Working with SVG: a summary (changing size / color)
The viewBox attribute specifies that a given set of graphics stretch to fit a particular container element.
The value of the viewBox attribute is a list of four numbers: min-x, min-y, width, height.
It specifies a rectangle in user space that should be mapped to the bounds of the viewport established by the given element, and it is related to the preserveAspectRatio attribute.
Negative values for width or height are not allowed, and a value of zero disables rendering of the element.
Using components copied from icones
How to use it so that Tailwind font size classes apply properly. First, the component:
import {SVGProps} from 'react';
export function BiFileEarmarkPdf(props: SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 16 16"
{...props}
>
<g fill="currentColor">
<path d="M14 14V4.5L9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2M9.5 3A1.5 1.5 0 0 0 11 4.5h2V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h5.5z"></path>
</g>
</svg>
);
}
export default BiFileEarmarkPdf;
When using it, apply inline-block so the text aligns properly.
<BiFileEarmarkPdf
className="inline-block text-center text-lg"
onClick={e => onClickExportPdf(e, d)}
/>
Including SVG in HTML documents
SVG code can be used in a document with the following HTML elements.
- <img>
- [[HTML:embed|<embed>
]]
- <object>
- <iframe>
- [[HTML:svg|<svg>
]]
- [[HTML:canvas|<canvas>
]] (JavaScript)
Image
The easiest way to use an SVG file (*.svg) in an HTML document is to set the file's path in the src attribute of the <img> element. If the image carries meaning, provide appropriate alternative text.
Embed (embed)
The way to include an SVG element in an HTML document using the embed element is to set the file's path in the src attribute of the
<embed>
element. If the image needs to be described, provide appropriate alternative text through the aria-label attribute.
Object (object)
The way to include an SVG element in an HTML document using the object element is to set the file's path in the data attribute of the <object> element. If the image needs to be described, provide appropriate alternative text through the aria-label attribute.
Iframe (iframe)
The way to include an SVG element in an HTML document using the iframe element is to set the file's path in the src attribute of the <iframe> element. If the image needs to be described, provide appropriate alternative text through the aria-label attribute.
Inline SVG
The way to include an SVG element in an HTML document using the iframe element is to set the file's path in the src attribute of the <iframe> element. If the image needs to be described, you should provide the content with SVG accessibility in mind.
===
<svg>
element ===
<svg>element is the start of an inline SVG. Many attributes can be added to the svg element. Typically, the version, xmlns, xmlns:xlink, viewbox, width, and height attributes are set.
<svg
version="1.1"
xmlns=http://www.w3.org/2000/svg
xmlns:xlink="http://www.w3.org/1999/xlink"
width="520" height="520"
viewBox="0 0 520 520">
...
</svg>
However, for inline SVG code, the following attributes are not needed for rendering in a web browser.
- version
- xmlns
- xmlns:xlink
Therefore, when using inline SVG, you can write it concisely as in the code below.
Web canvas (canvas)
var example = document.getElementById('example');
var context = example.getContext('2d');
var img = new Image();
img.onload = function() {
context.drawImage(img, 0, 0);
}
img.src = "http://upload.wikimedia.org/wikipedia/commons/d/d2/Svg_example_square.svg";
Elements
Path
- Drawing SVG path shapes - Graphics ARIA Guidebook
- [Recommended] Paths - SVG: Scalable Vector Graphics | MDN
See also
Favorite site
- Wikipedia (en) description of SVG
- W3C: SCALABLE VECTOR GRAPHICS (SVG)
- An SVG Primer for Today's Browsers
- Scalable Vector Graphics (SVG) 1.1 (Second Edition)
- A Guide to SVG Animations (SMIL)
- SVG-Whiz! (SVG Wiki for the developer)
- Ryan login form made with SVG, JS, and CSS
Download Resources
- [Recommended] Pattern Monster - SVG Pattern Generator - Offers 194 free SVG design patterns; you can modify colors and patterns and download them
- [Recommended] Freepik: Download Free Videos, Vectors, Photos, and PSD
- Game-icons.net - 4131 free SVG and PNG icons for your games or apps
- Free SVG icons, instant downloads (no attribution) | Reshot
- icons8/flat-color-icons: Free Flat Color Icons
- svg-icon - An ultimate SVG icons collection DONE RIGHT.
- Noun Project: Free Icons & Stock Photos for Everything - Free, but seems to require sign-up
- Free SVG Illustrations (Free Illustrations) Vector Illustrations - CC0 downloads of illustration images made in SVG
- [Recommended] Free SVG Image & Icon. | SVG Silh - For use in games
- [Recommended] SVG Repo - Free SVG Vectors and Icons - 500.000+ Open-licensed SVG Vector and Icons
- https://www.svgrepo.com/collection/winter-town-filled-vectors/
- https://www.svgrepo.com/collection/pumpkin-emoji-vectors/
- https://www.svgrepo.com/collection/monster-character-avatars/
- https://www.svgrepo.com/collection/linea-thin-icons/
- https://www.svgrepo.com/collection/destiny-game-icons/
- https://www.svgrepo.com/collection/hearthsim-game-icons/
- https://www.svgrepo.com/collection/botanical-hand-drawn-vectors/
- https://www.svgrepo.com/collection/curved-interface-icons/
- https://www.svgrepo.com/collection/gems-and-crystal-line-vectors/ ~~ !!
- https://www.svgrepo.com/collection/middle-age-monocolor/
- https://www.svgrepo.com/collection/solid-line-icons/
- https://www.svgrepo.com/collection/role-playing-game/
- https://www.svgrepo.com/collection/dog-breed-illustration/
- https://www.svgrepo.com/collection/geometric-heart-icons/
- https://www.svgrepo.com/collection/building-line-icons/
- https://www.svgrepo.com/collection/human-organs-line-vectors/
- https://www.svgrepo.com/collection/animal-flat-vectors/
- https://www.svgrepo.com/collection/hand-drawn-arrow-vectors/
- https://www.svgrepo.com/collection/nature-logo-badges/
- https://www.svgrepo.com/collection/circular-avatar-vectors/
- https://www.svgrepo.com/collection/medical-health-icons/ ~~ !!
- https://www.svgrepo.com/collection/happy-trees-flat-vectors/ ~~ !!
- https://www.svgrepo.com/collection/happy-trees-outline/ ~~ !!
- https://www.svgrepo.com/collection/analytics-and-charts-line-icons/
- https://www.svgrepo.com/collection/tools-line-vectors/ ~~ !!
- https://www.svgrepo.com/collection/weather-forecast-glyphs-icons/ ~~ !!
- https://www.svgrepo.com/collection/astrology-symbols/ ~~ !!
- https://www.svgrepo.com/collection/fruits-and-vegetables-glyphs-icons/
- https://www.svgrepo.com/collection/flat-profile-avatar/
- https://www.svgrepo.com/collection/halloween-scary-vectors/
- https://www.svgrepo.com/collection/middle-age-weapon-vectors/ ~~ !!
- https://www.svgrepo.com/collection/origami-animal-line-vectors/ ~~ !!
- https://www.svgrepo.com/collection/vegetable-glyph-icons/ ~~ !!
- https://www.svgrepo.com/collection/building-landmark-vectors/
- https://www.svgrepo.com/collection/padlock-types-line-icons/ ~~ !!
- https://www.svgrepo.com/collection/adventure-and-camping-line-vectors/
- https://www.svgrepo.com/collection/fruits-glyph-icons/
- https://www.svgrepo.com/collection/weather-line-vectors-2/ ~~ !!
- https://www.svgrepo.com/collection/smiley-emoji-circular-vectors/ ~~ !!
- https://www.svgrepo.com/collection/animals-material-icons/
- https://www.svgrepo.com/collection/chess-vectors/ ~~ !!
- https://www.svgrepo.com/collection/people-icooon-mono-vectors/3 ~~ !!
- https://www.svgrepo.com/collection/doodle-basic-emoji-face-vectors/ ~~ !!
MSDN
- [https://msdn.microsoft.com/ko-kr/library/gg589525(v=vs.85.aspx MSDN: SVG]
- [https://msdn.microsoft.com/ko-kr/library/gg193979(v=vs.85.aspx MSDN: Basic SVG animation]
MDN
Tutorials
- [Recommended] SVG Graphics - Graphics ARIA Guidebook
Guides
- SVGs that feel like GIFs | GeekNews
- [Original] SVGs that feel like GIFs | Vincent D. Warmerdam
- Animated SVG images keep high resolution while having a very small file size (49KB)
- Gives a visual effect similar to conventional GIFs, but actually uses SVG animation features
- Can also be used directly in a Github README.md file
- Record terminal sessions with the asciinema and svg-term-cli tools → can convert to SVG animation
- Uses SVG animation elements (<animate>, <animateTransform>, <animateMotion>)
- 3D Modeling
- Asciinema
- Bespoken
- CanvasRenderingContext2D
- Computer animation
- Computer Graphics
- Computer Language
- CSS:@font-face
- Design:Resources
- Draw.io
- Game design
- Godot
- GUIDO music notation
- Guidolib
- Icon
- Illustration
- Inkscape
- Libmusicxml
- Markup Language
- Multimedia Codec
- MusicXML
- MusicXML:Scripts:Mxl2Svg
- Programming
- Python
- Python:Libraries
- React
- React:SVGProps
- Scour
- Shields.io
- SVG++
- Svg-term-cli
- SVGInject
- SVGO
- SVGsplit
- SVGSVGElement
- ThorVG
- TinyVG
- Typeface
- V-icon
- Vector graphics
- Vector Markup Language
- Verovio
- Vite
- Vite-plugin-svgr
- Vuetify
- Web typography