Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For logos, icons, diagrams, charts, and other shape-based graphics on the web, SVG is usually the best format. It describes drawing instructions rather than a fixed grid of pixels, so it stays sharp at different sizes. For photographs and other continuous-tone images, use a raster format such as WebP, AVIF, JPEG, or PNG instead.

The right choice depends on what the image contains, how it will be displayed, whether it needs transparency or interaction, and which browsers your site supports. This guide explains those trade-offs and shows how to serve SVG with raster fallbacks.

What is a vector image format?

A vector image records shapes and instructions for drawing them—such as paths, lines, fills, and text—instead of saving a fixed grid of colored pixels. When the image is displayed, the browser renders those instructions at the requested size. That makes a vector image particularly useful when the same artwork must appear at different dimensions or resolutions.

SVG, or Scalable Vector Graphics, is the web’s principal vector image format. The World Wide Web Consortium describes SVG as “a language based on XML for describing two-dimensional vector and mixed vector/raster graphics.” An SVG file commonly uses the .svg extension and the image/svg+xml media type. SVG can be included as an external image or embedded directly in HTML.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Vector” does not mean that every part of an SVG must be made of vector shapes: SVG can also display raster images. It can additionally support CSS styling, scripting, and interaction, which makes it more capable—and potentially more security-sensitive—than a passive pixel image.

Vector vs. raster: what changes in practice?

Characteristic Vector (SVG) Raster (PNG, JPEG, WebP, AVIF)
What the file represents Drawing instructions, such as paths, shapes, and text A grid of pixels
What happens when enlarged The browser renders the drawing at the new size, so edges remain crisp The existing pixels are enlarged; at sufficiently large sizes they can look blocky or soft
Best suited to Logos, icons, diagrams, charts, line art, and other graphics made from defined shapes Photographs, textures, and other images with continuous-tone detail
Transparency Supported Supported by PNG, WebP, and AVIF; JPEG does not support transparency
How size is determined Can be rendered at varying dimensions; declare dimensions or a viewBox appropriate to the artwork and use Has a fixed pixel width and height; prepare suitable resolutions for the displayed size

These are format-family differences, not guarantees about file size. A simple logo may be represented compactly as SVG, but a complex SVG can be larger than a well-compressed raster version. Compare actual files after export and compression rather than assuming one format will always transfer faster.

Which image format should you use?

Choose SVG for shape-based artwork

SVG is generally a strong choice for a logo, interface icon, line illustration, diagram, or chart when crisp rendering at multiple sizes matters. It is also useful when the display size is unknown or may vary. MDN Web Docs describes SVG as an ideal choice for images representable as drawing commands, especially when the rendered size is unknown or variable.

Use a standalone SVG file for an image that can be treated as one graphic. Embed SVG inline when the page needs to style individual shapes or provide controlled interaction. Inline markup makes those parts available to the document’s CSS and scripting; an external SVG image is easier to cache separately and keeps the page markup more isolated.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a raster format for photographs

Photographs contain subtle tonal transitions and fine detail that are naturally represented by pixels. SVG is usually the wrong format for them: it does not turn photographic content into a compact set of meaningful shapes. MDN’s current image-format guidance favors WebP or AVIF for many raster-image uses. JPEG remains a common photographic fallback, while PNG is useful for lossless images such as screenshots and diagrams, especially when transparency is needed.

Pick among raster formats based on your requirements and the browsers you need to support. A photograph does not benefit from vector scaling in the way a simple logo does; instead, provide a sufficiently sized raster image and compress it appropriately.

Consider content, not just the file extension

A screenshot of a chart is still a raster image, even though the chart itself consists of shapes and text. If you control the chart output and want it to remain sharp or accessible at different sizes, exporting it as SVG may be preferable. Conversely, an SVG can contain an embedded raster image, so inspect how it was created if you are trying to reduce transfer size or understand its rendering behavior.

How to use SVG in a web page

Use an external SVG as an image

For a normal logo or icon, a standalone SVG referenced by an <img> is often the simplest option:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<img src="/images/site-logo.svg" alt="Acme home" width="180" height="48">

Use an informative alt value when the image communicates content or provides an action, as in a linked logo. For a purely decorative image, use alt="" so assistive technology can skip it. Set dimensions that match the intended display proportions; this helps the browser reserve space as the page loads. Ensure the server sends SVG with the image/svg+xml media type.

Embed SVG inline when the page needs access to its shapes

Inline SVG is useful if page CSS needs to style individual paths or if you need a controlled interaction. For example, a simple decorative symbol can be written directly into the document:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
  <path d="M4 12h16M12 4l8 8-8 8" fill="none" stroke="currentColor" stroke-width="2"/>
</svg>

Give a meaningful inline graphic an accessible name or provide an equivalent text description in the page. Do not add unnecessary interactive behavior to an image that is only meant to illustrate content.

Prefer an external SVG when independent caching or isolation is more important than styling its internal shapes from the page. Inline SVG adds markup to the document and should be used deliberately rather than as a default for every asset.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to provide an SVG fallback

For a mixed browser audience, the HTML <picture> element can offer an SVG first, then raster alternatives, with an <img> as the final fallback. Put sources in the order you want the browser to try them, and keep the <img> element’s alternative text and dimensions aligned with the graphic.

<picture>
  <source srcset="/images/diagram.svg" type="image/svg+xml">
  <source srcset="/images/diagram.webp" type="image/webp">
  <img src="/images/diagram.png" alt="Diagram showing the three deployment stages" width="900" height="520">
</picture>

The browser uses a supported matching <source> and otherwise reaches the <img>. This pattern is useful when you have a real need to accommodate browsers that cannot render the preferred source. It is not automatically necessary for every site: test against the browsers and assistive-technology requirements you actually support, and do not maintain redundant variants without a compatibility reason.

When an SVG fails to display, check both the URL and the response’s media type. A server returning an HTML error page, or serving SVG with an incorrect type, can prevent it from being handled as expected.

Security and reliability considerations for SVG

SVG is an active document format when it includes scripts, external resources, or interaction. Treat untrusted SVG uploads accordingly: validate and sanitize them before use, and review your content-security rules. Do not assume that an uploaded SVG is equivalent to a simple, inert PNG just because both appear as images on a page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For graphics you create or control, keep the markup focused on the image’s purpose and avoid unnecessary external dependencies. If your page only needs a static logo, an external image reference is usually a simpler integration than adding interactive SVG markup to the document.

Check how your graphics render in a real browser

A format choice is only part of the result: fonts, CSS, viewport size, and page layout can affect how a logo, chart, or illustration appears. For a manual check, open the page in the browser and inspect it at the viewport sizes and display scales relevant to your users. Confirm that the SVG loads, the intended dimensions are used, text remains legible, and any fallback works in the browsers you support.

Or skip the browser setup

ScreenshotNeo can return a screenshot of a web page as PNG, JPEG, or WebP, or a PDF. Its one-call API is useful when you want a rendered page capture without setting up a browser locally:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common image problems

The SVG looks blurry

SVG artwork should render sharply when the browser can use its vector instructions, but an SVG may contain a raster image, or the page may be displaying a different asset than expected. Check the loaded file and whether the artwork itself embeds pixels. Also verify that CSS has not scaled the graphic in an unintended way.

The SVG is missing or downloads instead of displaying

Check that the path resolves to the intended file, that the server returns the SVG rather than an error page, and that its media type is image/svg+xml. If the image is selected through <picture>, verify that the source URL and declared type match the file.

The graphic is clipped or has unexpected whitespace

Inspect the SVG’s viewBox and its dimensions, then compare them with the CSS width and height on the page. A viewBox that excludes part of the drawing can clip it; extra empty space in the viewBox can make the visible artwork appear too small even when the image box has the expected size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The fallback never appears

Confirm the order and URLs in <picture>, and test in a browser that does not support the preferred source if that is the fallback behavior you intend to verify. A fallback is not a substitute for checking that the primary SVG is valid and served with the right media type.

The SVG is larger than a raster alternative

Complex paths and embedded image data can make an SVG relatively large. Compare the actual compressed files at the intended display size. For photographic content, select and optimize a suitable raster format instead of wrapping the photo in SVG.

Quick decision guide

  • Logo or icon shown at different sizes: use SVG if the artwork is shape-based.
  • Photo or other continuous-tone image: use an optimized raster format such as WebP or AVIF; consider JPEG as a fallback where needed.
  • Lossless screenshot or transparent diagram: PNG can be appropriate; use SVG instead when the diagram is available as scalable shapes and text.
  • Page CSS must style individual drawing elements: consider inline SVG and keep interaction controlled.
  • Need broad audience coverage: use <picture> with a suitable raster fallback, then test the source order in the browsers you support.
  • Accepting SVG uploads: validate and sanitize them, and review the security implications of scripts and external resources.

Frequently Asked Questions

Does SVG work on modern web browsers?

SVG is a web-native standard, but a site should still test its chosen rendering and fallback behavior against its own browser-support requirements.

Can I use an SVG for a photo?

An SVG can contain raster content, but it does not make a photograph meaningfully vector. Use an appropriate raster format for photographic imagery.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I always add PNG as an SVG fallback?

No. Add a fallback when your audience or browser-support requirements call for one; otherwise it can create extra assets without a practical benefit.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.