SVG

什么是SVG?

SVG(可缩放矢量图形)是一种基于XML的矢量图像格式,它使用数学形状而不是像素来描述图形,从而实现无限缩放而不会失去质量。

最后更新:

Year1999
Type矢量
UsageW3C

What is it?

SVG(可缩放矢量图形)是1999年推出的W3C标准格式。与将图像存储为像素网格的光栅格式(如JPG和PNG)不同,SVG将图像存储为使用XML标记的形状、路径和颜色的数学描述。

由于SVG使用数学而不是像素,SVG图像可以缩放到任何大小 - 从图标到广告牌 - 而不会失去质量。SVG文件也可以作为文本进行编辑,可以使用CSS进行样式设置,并可以使用JavaScript进行动画处理。

Technical Specifications

StandardW3C SVG Specification
File Extension.svg / .svgz
MIME Typeimage/svg+xml
Format TypeVector (XML-based)
ScalabilityInfinite - no quality loss
AnimationSupported (CSS and JS)

Pros & Cons

Advantages

Infinitely Scalable

Looks sharp at any size from 16x16 pixels to poster-sized without any pixelation.

Small File Size

Simple graphics like logos and icons are often smaller than equivalent PNG files.

CSS and JS Controllable

SVG elements can be styled, animated, and manipulated with code in the browser.

Accessible

SVG supports text descriptions and semantic markup for accessibility.

Disadvantages

Not for Photos

SVG cannot efficiently represent photographic images - use JPG or WebP instead.

Complex SVGs Can Be Slow

Very detailed SVG illustrations with thousands of paths can hurt rendering performance.

Security Concerns

SVG can contain scripts - untrusted SVG files should be sanitized before display.

Limited Print Support

Some print workflows require conversion to PDF or rasterization.

When to Use It

SVG是任何需要在网页上缩放或互动的图形的理想格式。

Logos and Branding

Company logos that appear in multiple sizes - from favicon to banner - stay crisp at every scale.

Icons

UI icons that need to work at 16px and 512px alike, with optional color theming via CSS.

Illustrations

Charts, diagrams, maps, and illustrations that need to be sharp on retina displays.

Animations

Lightweight animated graphics and transitions without video overhead.

Convert Your Files Online - Free

Our free online converter supports all major formats. No software to install, no registration required.

Start Converting Now

Frequently Asked Questions

Can I use SVG on any website?

Yes. All modern browsers support SVG natively in HTML. You can embed SVG inline, as an img src, or as a CSS background image.

Is SVG better than PNG for logos?

Yes, for web use. SVG logos stay sharp at any size and are often smaller in file size. PNG is a raster format - a PNG logo may look blurry when scaled up.

Can SVG files be animated?

Yes. SVG supports animation through CSS animations, CSS transitions, and JavaScript (GSAP, anime.js). SMIL animation is also part of the SVG spec but less commonly used.

Is SVG safe to use from untrusted sources?

Be careful. SVG files can contain embedded scripts. Never display SVG from untrusted sources without sanitizing it first. Use a library like DOMPurify to sanitize user-uploaded SVGs.

What is the difference between SVG and EPS?

Both are vector formats. SVG is designed for the web (browser-native, CSS/JS compatible). EPS is designed for print and professional publishing. SVG is the modern choice for most use cases.