Course contentsShow
← Web Development
Lesson 1239 of 2,98222. Responsive Images and MediaFree lesson

Understanding Raster vs Vector Image Formats

Learn the fundamental differences between raster (pixel-based) and vector (path-based) formats and when to use each type.

Understanding Raster vs Vector Image Formats

What you'll learn: You'll discover the core differences between pixel-based and path-based image formats and how to choose the right type for your responsive web projects.

Two Fundamentally Different Approaches

Images on the web fall into two categories based on how they store visual information.

Raster images are made of a fixed grid of colored pixels, like a mosaic or digital photograph. Common formats include JPEG, PNG, GIF, and WebP. Think of them as a checkerboard where each square has a specific color — if you zoom in far enough, you'll see individual pixels become visible and edges look jagged.

Vector images store mathematical instructions describing shapes, lines, and curves — not pixels. The SVG format is the web's primary vector format. Imagine a recipe that tells the browser how to draw the image each time: "Draw a circle at this point with this radius, fill it blue." No matter how large you scale the image, the browser recalculates and renders it perfectly sharp.

When to Use Each Type

Use raster formats for:

  • Photographs and complex images with subtle color variations
  • Images where detail matters more than scalability
  • When you already have pixel-based source files

Use vector formats (SVG) for:

  • Logos, icons, and simple illustrations
  • Diagrams, charts, and geometric shapes
  • Images that need to scale infinitely without quality loss
  • When file size and crisp rendering at any size are priorities

The Responsive Image Connection

Understanding this distinction matters because raster images require multiple resolutions (srcset) to look sharp on different screens, while vectors scale perfectly with no extra work. A 5KB SVG logo looks pristine on both phones and billboards — a raster version would need multiple file sizes.

Key Takeaway: Raster images are pixel grids best for photos; vector images are scalable instructions best for graphics. Choose based on content type and scaling needs.