Nodea — logo

SVG

SVG (Scalable Vector Graphics) is an XML-based vector graphics format. Instead of storing an image as a grid of pixels, SVG describes it mathematically — with points, lines, curves and shapes. As a result, SVG graphics can be enlarged and shrunk to any size without losing sharpness and without increasing file weight. The format is an open standard of the W3C and is natively supported by all modern browsers.

What the SVG format is

An SVG file is essentially a text document containing drawing instructions. Because the image is described in code, it can be edited in any text editor, styled with CSS and animated with JavaScript. This is the fundamental difference from raster graphics:

  • Scalability — the same graphic looks sharp on a small icon and on a large banner;
  • Small weight — simple illustrations and logos take up less than their raster equivalents;
  • Editability — colors, shapes and text can be changed directly in the code;
  • Accessibility — SVG objects can include text descriptions read by screen readers.

The format's limitation is photographs and complex photographic images — these are better saved in raster formats such as JPEG, PNG or WebP.

Practical application

SVG is today the standard for logos, icons, charts and simple illustrations on websites. The format works well in responsive interfaces, because a single graphic serves all screen resolutions, including high-pixel-density displays. SVG is also used for interactive maps, animations and as a favicon element.

By embedding SVG directly in the HTML code, you avoid extra server requests, which speeds up page loading. However, because an SVG file can contain scripts, uploading such files from external users requires sanitizing their content to prevent XSS attacks. Used correctly, the format combines low weight, sharpness on every screen and full control over the graphic's appearance.

Powiązane pojęcia

Najczęstsze pytania

How is SVG different from PNG or JPEG?

PNG and JPEG are raster formats — the image is stored as a grid of pixels, so enlarging it causes pixelation. SVG is vector-based: it describes shapes with mathematics, so it scales to any size without quality loss. SVG is great for logos and icons, less suited to photographs.

Is SVG safe to place on a website?

An SVG is a text file that can contain JavaScript, so uploading SVG files from untrusted users carries a risk of XSS attacks. Safe use requires sanitizing the SVG content of potentially harmful elements before embedding it on the page.