You may be wondering which image format you should use when designing for the web. You have an array of formats to choose from, from PNG to JPEG to other vector and raster formats. There’s no single ideal format to use for all images, as each format out there comes with its pros and cons. In the following paragraphs, you shall come to understand SVG advantages and disadvantages. By knowing the benefits and disadvantages of SVG, you can decide on the right situation to use SVG over other formats like PNG.
When it comes to still detailed images like photographs, PNG, or JPEG is the image formats of choice. Raster images (like PNG and JPG) lose quality when resized or zoomed in the browser. When displaying simple 2D images or line drawings (such as logos) on the web, the ideal format should be a vector format. SVG (Scalable Vector Graphics) is the most popular vector format for the web. SVG is often associated with vector design programs like Inkscape and Adobe Illustrator and others. These programs make working with SVG easy, but there are other ways to work with SVG directly from its code, using a text editor and browser.
SVG is a graphic format created in 1999 and has since grown to be widely adopted. SVG files are based on XML and are used to display graphics on the web and other environments.
SVG Advantages and Disadvantages
Below are the most relevant SVG advantages and disadvantages we could find.
SVG Advantages / Benefits
There are several benefits to using SVG over other formats like JPEG and PNG. Although SVG is not meant to replace these raster formats, it is ideal when displaying vector graphics on the web. Below are 8 SVG benefits you should know about.
Unlike standard images, SVG images are vector and do not lose quality when resized or zoomed in the browser. This makes them accessible for many devices and browsers. Raster formats like PNG and JPG become pixilated when resized.
SVG graphics are resolution-independent. Other image formats may require extra assets/data to fix resolution-based issues, depending on the device. For example, in retina screens, a @2x hack is required to display higher-resolution images. SVG doesn’t have such hassles and can be resized easily no matter the device or resolution.
Below, you can see the same image when scaled in different formats. In SVG, the image retains its quality. When scaled in PNG, the image losses its quality and becomes pixilated.
Play around with the SVG image below by jumping to the CSS tab and modifying the fill color.
3. Can be animated
SVG graphics can be animated using JS and CSS. It is, therefore, a powerful format for web developers and animators.
Compared to other formats, SVG images are very small in size. Depending on the image, a PNG graphic can weigh as much as 50 times — more or less– its SVG counterpart.
SVG graphics can be printed at any resolution without a loss in image quality.
SVG graphics are indexed by search engines. Therefore, SVG images are good for SEO (Search Engine Optimization) purposes.
Like other image formats, SVG files can be scripted and compressed.
8. No unnecessary requests
SVG graphics do not need any unnecessary HTTP requests. Because they are made up of XML and CSS, they do not need the browser to request an image from a server, as is being done for standard images. This makes SVGs faster and user-friendlier for the web.
9. Easy to edit
With just a text editor, we can create SVG graphics. While vector graphic applications like Inkscape and Adobe Illustrator are easier to use, they are not necessary at all!
Below is an example SVG code that displays a circle as seen from a code editor.
1. Not detailed
The SVG format is great for 2D graphics like logos and icons but is not ideal for detailed pictures. SVG-based graphics can’t display as many details as standard image formats since they are rendered using points and paths instead of pixels
2. Not fully cross-platform
Cross-platform: Even though SVG has been around since 1999 and is supported by most modern browsers (both on desktop and mobile), it does not work on legacy browsers like IE8 and below. According to caniuse.com, about 5% of internet users surf the web with the browser that doesn’t support SVG. Therefore, by using SVG, you may miss out on 1 in 20 users who could be viewing your content. You should there learn how to implement an SVG fallback.
What is SVG used for?
You may be asking yourself: should I use SVG or PNG? Below are some of the best circumstances that will warrant the use of SVG over other image formats.
- SVG is ideal for displaying vector logos, icons, and other geometric designs.
- SVG should be used for graphics that will be displayed in multiple sizes, screens, and a variety of devices.
- SVG is great for graphics that need to be updated and edited.
When you need to create simple animations, SVG is an ideal format. SVG can interact with CSS and JS to make line animations, transitions, and other complex motions.
You can create appealing animations, and even special kinds of animation, including SVG line drawings. SVG can interact with CSS animation, as well as use its own built-in SMIL animation ability.