What Are CSS Sprites?
CSS sprites are a technique to reduce the number of HTTP requests for image resources. Multiple small images — like icons, buttons, and logos — are combined into a single larger image called a sprite sheet. Using CSS background-position, each individual image is displayed by shifting the visible area to the correct coordinates.
This technique is particularly effective when a page uses many small images. Major websites like Yahoo!, Google, and Amazon have used CSS sprites to optimize their page load times.
How to Use This Tool
-
Upload images — Drag and drop multiple image files onto the upload area, or click "Browse Files" to select them. Supported formats: PNG, JPG, GIF, WebP, SVG.
-
Choose layout — Select from four layout algorithms:
- Packed: Bin-packing for the smallest possible sprite (recommended for mixed sizes)
- Horizontal: Single row arrangement
- Vertical: Single column arrangement
- Grid: Uniform grid cells (best for same-sized icons)
-
Adjust settings — Set padding between images, choose output format (PNG or WebP), configure CSS class prefix/suffix, and enable retina @2x/@3x generation.
-
Preview and download — The right panel shows a live preview with the generated CSS, SCSS, and HTML code. Download everything as a ZIP file.
Retina / HiDPI Support
Modern displays have pixel ratios of 2x or 3x. To keep your sprites crisp on these screens, enable the @2x and @3x options. The tool will:
- Generate additional sprite sheets at higher resolutions
- Output CSS
@mediaqueries that detect the device pixel ratio - Use
background-sizeto scale the higher-resolution sprite down to the correct display size
Browser Compatibility Notes
- Opera: Versions up to 9.0 have a 2042px limit on
background-positionvalues. For very large sprites, consider using the packed or grid layout to minimize dimensions. - Safari: Repeating background images may cause issues. Ensure adequate padding between images.
Performance Benefits
Each HTTP request has overhead — DNS lookup, connection, TLS handshake. By combining 20 icon files into a single sprite, you eliminate 19 requests. This matters especially on mobile networks where latency is high.